-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f820196
commit 6627292
Showing
14 changed files
with
102 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
type Patched = 1 | 0 | -1; | ||
|
||
export default class AppPatch { | ||
appName: string; | ||
appPath: string; | ||
constructor(appPath: string) { | ||
this.appPath = appPath; | ||
this.appName = appPath.split("/").pop()!.replace(/.app/g, ''); | ||
} | ||
patched(): Patched { | ||
throw new Error(`Method "patched" must be implemented on class ${this.constructor.name}`); | ||
} | ||
patch() { | ||
throw new Error(`Method "patch" must be implemented on class ${this.constructor.name}`); | ||
} | ||
supported(): boolean { | ||
throw new Error(`Method "supported" must be implemented on class ${this.constructor.name}`); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import AppPatch from "@patches/apppatch"; | ||
import path from "path"; | ||
import {homedir} from "os"; | ||
import {isRoot, patchOptions, searchFile} from "@src/utils"; | ||
import fs from "fs"; | ||
import {patchFile} from "amdfriend/src"; | ||
|
||
const discordPath = path.join(homedir(), "Library", "Application Support", "discord") | ||
export default class Discord extends AppPatch { | ||
patchedPath: string; | ||
krispPath: string; | ||
constructor(appPath: string) { | ||
super(appPath); | ||
this.krispPath = path.join( | ||
discordPath, | ||
fs.readdirSync(discordPath) | ||
.filter(a => a != ".DS_Store") | ||
.sort((a, b) => a.localeCompare(b))[0] | ||
, "modules", "discord_krisp", "discord_krisp.node"); | ||
this.patchedPath = path.join(this.krispPath, "..", ".amdhelper"); | ||
} | ||
patched() { | ||
const fileExists = fs.existsSync(this.patchedPath); | ||
return (fileExists ? 1 : 0); | ||
} | ||
supported(): boolean { | ||
return this.appName === "Discord"; | ||
} | ||
|
||
async patch(){ | ||
if(this.patched() === 1) return console.log(`${this.appName} already patched. Ignoring...`); | ||
await patchFile(this.krispPath, patchOptions); | ||
|
||
fs.writeFileSync(this.patchedPath, ""); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import {exec} from "./utils"; | ||
import {exec} from "@src/utils"; | ||
|
||
interface UpdateResponse { | ||
tag_name: string | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,27 @@ | ||
// @ts-ignore | ||
import {promisify} from "util"; | ||
import child_process from "child_process"; | ||
import type {PatchOptions} from "amdfriend/src/types"; | ||
import fs from "fs"; | ||
import path from "path"; | ||
|
||
export const isRoot = () => process!.getuid() === 0 ; | ||
|
||
export const exec = promisify(child_process.exec); | ||
export const patchOptions: PatchOptions = {backup: false, clearXA: false, dryRun: false, inPlace: true, sign: true }; | ||
|
||
export function searchFile(dirPath: string, fileName: string): string | null { | ||
const files = fs.readdirSync(dirPath); | ||
for (const file of files) { | ||
const filePath = path.join(dirPath, file); | ||
|
||
const fileStat = fs.statSync(filePath); | ||
if (fileStat.isDirectory()) { | ||
const result = searchFile(filePath, fileName); | ||
if (result) return result; | ||
} else if (file === fileName) { | ||
return filePath; | ||
} | ||
} | ||
return null; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters