diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index ffa43f4..0000000 --- a/.eslintignore +++ /dev/null @@ -1 +0,0 @@ -src/lib/*.js \ No newline at end of file diff --git a/.eslintrc.yml b/.eslintrc.yml index 13cc1be..508dc83 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -30,6 +30,9 @@ rules: node/no-unpublished-require: off node/shebang: off no-process-exit: off + no-undef: off + no-unused-vars: off + "@typescript-eslint/no-unused-vars": error overrides: - files: "**/*.ts" diff --git a/manifest.json b/manifest.json index 8ef9a3a..7a6ea99 100644 --- a/manifest.json +++ b/manifest.json @@ -7,7 +7,7 @@ "discordID": "372148345894076416", "github": "SammCheese" }, - "version": "1.0.5", + "version": "1.0.6", "updater": { "type": "github", "id": "SammCheese/invisible-chat" diff --git a/package.json b/package.json index 860907f..47a3f8a 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "eslint-plugin-node": "^11.1.0", "eslint-plugin-react": "^7.31.10", "prettier": "^2.8.1", - "replugged": "4.0.0-beta0.18", + "replugged": "4.0.0-beta0.19", "tsx": "^3.10.3", "typescript": "^4.8.4" } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 1a66fd2..c9c726f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -13,7 +13,7 @@ specifiers: eslint-plugin-node: ^11.1.0 eslint-plugin-react: ^7.31.10 prettier: ^2.8.1 - replugged: 4.0.0-beta0.18 + replugged: 4.0.0-beta0.19 tsx: ^3.10.3 typescript: ^4.8.4 @@ -30,7 +30,7 @@ devDependencies: eslint-plugin-node: 11.1.0_eslint@8.25.0 eslint-plugin-react: 7.31.10_eslint@8.25.0 prettier: 2.8.1 - replugged: 4.0.0-beta0.18 + replugged: 4.0.0-beta0.19 tsx: 3.10.4 typescript: 4.8.4 @@ -1546,8 +1546,8 @@ packages: engines: {node: '>=8'} dev: true - /replugged/4.0.0-beta0.18: - resolution: {integrity: sha512-PNUyZAQdcOvkEDsG/8CFTocPjlLQnE0wMZlBDUTNSW+nIP67SpZwAdnu+BAgs6qO6a3z5qk3OGzHTSY1WPZgIQ==} + /replugged/4.0.0-beta0.19: + resolution: {integrity: sha512-OuOQt1QMTxe3mhhXyGrmbRc/Ipq56RAXIEA2mqsJFiZKCBFgR5erOWFLHygC9ZiXZnRnq8f76m3VeHFaREyIFA==} engines: {node: '>=14.0.0'} dev: true diff --git a/scripts/build.ts b/scripts/build.ts index 21bad13..4850833 100644 --- a/scripts/build.ts +++ b/scripts/build.ts @@ -66,8 +66,8 @@ const watch = process.argv.includes("--watch"); const common: esbuild.BuildOptions = { absWorkingDir: path.join(__dirname, ".."), bundle: true, - minify: false, - sourcemap: true, + minify: true, + sourcemap: false, format: "cjs" as esbuild.Format, logLevel: "info", watch, diff --git a/src/assets/indicator.tsx b/src/assets/indicator.tsx index b03fe97..fad28a0 100644 --- a/src/assets/indicator.tsx +++ b/src/assets/indicator.tsx @@ -3,7 +3,7 @@ const { React } = common; export const Indicator = ( ); diff --git a/src/index.ts b/src/index.ts index 69c4085..00dac01 100644 --- a/src/index.ts +++ b/src/index.ts @@ -13,6 +13,8 @@ const getStegCloak: Promise = import( "https://unpkg.com/stegcloak-dist@1.0.0/index.js" ); +// TYPES + type Constructor = new (encrypt: boolean, useHmac: boolean) => Promise; interface StegCloak { @@ -24,6 +26,23 @@ interface StegCloakImport { default: Constructor; } +interface DiscordEmbed { + title: string; + type: string; + description: string; + url?: string; + timestamp?: EpochTimeStamp; + color?: number; + footer?: object; + image?: object; + thumbnail?: object; + video?: object; + provider?: object; + author?: object; +} + +// CONSTANTS + const EMBED_URL = "https://embed.sammcheese.net"; const INV_DETECTION = new RegExp(/( \u200c|\u200d |[\u2060-\u2064])[^\u200b]/); const URL_DETECTION = new RegExp( @@ -52,8 +71,6 @@ export async function start(): Promise { chatbarLock, Indicator, }; - - console.log("%c [Invisible Chat] Started!", "color: aquamarine"); } // Grab the data from the above Plantext Patches @@ -62,7 +79,8 @@ function receiver(message: unknown): void { } // Gets the Embed of a Link -async function getEmbed(url: URL): Promise { +async function getEmbed(url: URL): Promise { + // Timeout after 5 seconds const controller = new AbortController(); const _timeout = setTimeout(() => controller.abort(), 5000); @@ -84,7 +102,7 @@ async function getEmbed(url: URL): Promise { export async function buildEmbed(message: unknown, revealed: string): Promise { const urlCheck = revealed.match(URL_DETECTION) || []; - let attachment; + let attachment: DiscordEmbed; if (urlCheck[0]) attachment = await getEmbed(new URL(urlCheck[0])); let embed = { diff --git a/src/plaintextPatches.ts b/src/plaintextPatches.ts index e5d00f0..a4468a6 100644 --- a/src/plaintextPatches.ts +++ b/src/plaintextPatches.ts @@ -11,7 +11,7 @@ const patches: types.PlaintextPatch[] = [ }, { // Chatbar Lock - match: /.=.\.activeCommand,.=.\.activeCommandOption,.{0,155}(.)=\[\];/, + match: /,.=.\.activeCommand,.=.\.activeCommandOption,.{0,255},(.)=\[\];/, replace: "$&;try{$1.push(window.invisiblechat.chatbarLock)}catch{};", }, { diff --git a/src/updater.ts b/src/updater.ts deleted file mode 100644 index 54d42e9..0000000 --- a/src/updater.ts +++ /dev/null @@ -1,56 +0,0 @@ -import { createWriteStream } from "fs"; -import { get } from "https"; -import { plugins } from "replugged"; -import { CONFIG_PATHS } from "replugged/dist/util"; -import { join } from "path"; - -const GITAPI_LINK = "https://api.github.com/repos/SammCheese/invisible-chat/releases/latest"; -const FILENAME = "dev.sammcheese.InvisibleChat.asar"; - -async function fetchGithub(): Promise { - return new Promise((resolve, reject) => { - fetch(GITAPI_LINK) - .then((resp) => resolve(resp.json())) - .catch((rej) => { - console.log(rej); - reject(rej); - }); - }); -} - -// eslint-disable-next-line @typescript-eslint/explicit-function-return-type -const downloadFile = (url: string, path: string) => { - const file = createWriteStream(path); - get(url, (res) => { - res.pipe(file); - - file.on("finish", () => { - file.close(); - }); - }); -}; - -export async function checkUpdate(): Promise { - const gitResult = await fetchGithub(); - // @ts-expect-error response type not declared - const localVersion = await plugins.get("dev.sammcheese.InvisibleChat")?.manifest?.version; - - // @ts-expect-error type not declared - if (isNewAvailable(localVersion, gitResult.tag_name)) { - // @ts-expect-error type not declared - downloadFile(gitResult.assets.browser_download_url, join(CONFIG_PATHS.plugins, FILENAME)); - /*rename(join(CONFIG_PATHS.plugins, FILENAME), `${FILENAME}.update`, (e) => { - // @ts-expect-error type not declared - if (e) unlinkSync(file); - });*/ - } -} - -function isNewAvailable(localVersion: string, remoteVersion: string): boolean { - if (!localVersion || !remoteVersion) return false; - - localVersion.replaceAll(".", "").replace("v", ""); - remoteVersion.replaceAll(".", "").replace("v", ""); - - return parseInt(remoteVersion, 10) > parseInt(localVersion, 10); -} diff --git a/tsconfig.json b/tsconfig.json index bba99e4..660ba85 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -47,7 +47,7 @@ // "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */ // "declarationMap": true, /* Create sourcemaps for d.ts files. */ // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ - // "sourceMap": true, /* Create source map files for emitted JavaScript files. */ + "sourceMap": false /* Create source map files for emitted JavaScript files. */, // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */ // "outDir": "./", /* Specify an output folder for all emitted files. */ // "removeComments": true, /* Disable emitting comments. */