From 88b04adab255eba1cb020a73742f770232e904ad Mon Sep 17 00:00:00 2001 From: TheArcaneBrony Date: Sun, 4 Sep 2022 13:20:19 +0200 Subject: More patches --- assets/index.html | 3 +++ src/api/util/TestClientPatcher.ts | 16 +++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/assets/index.html b/assets/index.html index 0cd90c8e..11e16272 100644 --- a/assets/index.html +++ b/assets/index.html @@ -42,6 +42,9 @@ SENTRY_TAGS: { instance: document.location.host }, PROJECT_ENV: "development", RELEASE_CHANNEL: "staging", + + //custom + PLAINTEXT_GATEWAY: true }; GLOBAL_ENV.MEDIA_PROXY_ENDPOINT = location.protocol + "//" + GLOBAL_ENV.CDN_HOST; const localStorage = window.localStorage; diff --git a/src/api/util/TestClientPatcher.ts b/src/api/util/TestClientPatcher.ts index 2e9bfafe..09b8e408 100644 --- a/src/api/util/TestClientPatcher.ts +++ b/src/api/util/TestClientPatcher.ts @@ -64,7 +64,10 @@ function prettier(filePath: string, content: string): string{ return content; } -function autoPatch(filePath: string, content: string): string{ +function autoPatch(filePath: string, content: string): string { + //patches + content = content.replaceAll('isDiscordGatewayPlaintextSet = function () {' , 'isDiscordGatewayPlaintextSet = function () { return window.GLOBAL_ENV.PLAINTEXT_GATEWAY;'); + //remove nitro references content = content.replace(/Discord Nitro/g, "Fosscord Premium"); content = content.replace(/"Nitro"/g, "\"Premium\""); @@ -84,6 +87,13 @@ function autoPatch(filePath: string, content: string): string{ //content = content.replace(/DiscordTag/g, "FosscordTag"); content = content.replace(/\*Discord\*/g, "*Fosscord*"); + //server -> guild + content = content.replace(/"Server"/g, "\"Guild\""); + content.replaceAll("server.\"","guild.\""); + content.replaceAll(" server "," guild "); + content.replaceAll(" Server "," Guild "); + content.replaceAll("\"Server","\"Guild"); + //change some vars content = content.replace('dsn: "https://fa97a90475514c03a42f80cd36d147c4@sentry.io/140984"', "dsn: (/true/.test(localStorage.sentryOptIn)?'https://6bad92b0175d41a18a037a73d0cff282@sentry.thearcanebrony.net/12':'')"); content = content.replace('t.DSN = "https://fa97a90475514c03a42f80cd36d147c4@sentry.io/140984"', "t.DSN = (/true/.test(localStorage.sentryOptIn)?'https://6bad92b0175d41a18a037a73d0cff282@sentry.thearcanebrony.net/12':'')"); @@ -100,6 +110,10 @@ function autoPatch(filePath: string, content: string): string{ content = content.replace(/!1/g, "false"); // - real esmodule defs content = content.replace(/Object.defineProperty\((.), "__esModule", { value: (.*) }\);/g, '\$1.__esModule = \$2;'); + + //save some time on load resolving asset urls... + content = content.replaceAll('e.exports = n.p + "', 'e.exports = "/assets/'); + content = content.replaceAll('e.exports = r.p + "', 'e.exports = "/assets/'); console.log(`[TestClient] Autopatched ${path.basename(filePath)}!`); -- cgit 1.4.1