summary refs log tree commit diff
diff options
context:
space:
mode:
authorTheArcaneBrony <myrainbowdash949@gmail.com>2022-09-04 13:20:19 +0200
committerTheArcaneBrony <myrainbowdash949@gmail.com>2022-09-04 15:15:25 +0200
commit88b04adab255eba1cb020a73742f770232e904ad (patch)
tree3b4c25d2e1cb2702d9493721a8e7f2ef56f61dd7
parentBasic client patching system (diff)
downloadserver-88b04adab255eba1cb020a73742f770232e904ad.tar.xz
More patches
-rw-r--r--assets/index.html3
-rw-r--r--src/api/util/TestClientPatcher.ts16
2 files changed, 18 insertions, 1 deletions
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)}!`);