From e83b50da8ab3c98a654e2e404d3208045266a2b8 Mon Sep 17 00:00:00 2001 From: Thesourtimes Date: Thu, 11 Nov 2021 11:29:08 +0300 Subject: Put autoregister scripts on a seperate asset file --- api/assets/autoRegister.js | 57 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 api/assets/autoRegister.js (limited to 'api/assets') diff --git a/api/assets/autoRegister.js b/api/assets/autoRegister.js new file mode 100644 index 00000000..29f93370 --- /dev/null +++ b/api/assets/autoRegister.js @@ -0,0 +1,57 @@ + // Auto register guest account: + const prefix = [ + "mysterious", + "adventurous", + "courageous", + "precious", + "cynical", + "despicable", + "suspicious", + "gorgeous", + "lovely", + "stunning", + "based", + "keyed", + "ratioed", + "twink", + "phoned" + ]; + const suffix = [ + "Anonymous", + "Lurker", + "User", + "Enjoyer", + "Hunk", + "Top", + "Bottom", + "Sub", + "Coolstar", + "Wrestling", + "TylerTheCreator", + "Ad" + ]; + + Array.prototype.random = function () { + return this[Math.floor(Math.random() * this.length)]; + }; + + function _generateName() { + return `${prefix.random()}${suffix.random()}`; + } + + const token = JSON.parse(localStorage.getItem("token")); + if (!token && location.pathname !== "/login" && location.pathname !== "/register") { + fetch(`${window.GLOBAL_ENV.API_ENDPOINT}/auth/register`, { + method: "POST", + headers: { "content-type": "application/json" }, + body: JSON.stringify({ username: `${_generateName()}`, consent: true }) //${Date.now().toString().slice(-4)} + }) + .then((x) => x.json()) + .then((x) => { + localStorage.setItem("token", `"${x.token}"`); + if (!window.localStorage) { + // client already loaded -> need to reload to apply the newly registered user token + location.reload(); + } + }); + } -- cgit 1.5.1 From 22084bae4e5c35412342e5e6015611faeb6fddd3 Mon Sep 17 00:00:00 2001 From: Thesourtimes Date: Thu, 11 Nov 2021 11:49:56 +0300 Subject: move checLocale and other js tp checkLocale --- api/assets/checkLocale.js | 47 +++++++++++++++++++++++++++++++++++++++++++++ api/client_test/index.html | 48 +--------------------------------------------- 2 files changed, 48 insertions(+), 47 deletions(-) create mode 100644 api/assets/checkLocale.js (limited to 'api/assets') diff --git a/api/assets/checkLocale.js b/api/assets/checkLocale.js new file mode 100644 index 00000000..016d66c8 --- /dev/null +++ b/api/assets/checkLocale.js @@ -0,0 +1,47 @@ + const localStorage = window.localStorage; + // TODO: remote auth + // window.GLOBAL_ENV.REMOTE_AUTH_ENDPOINT = window.GLOBAL_ENV.GATEWAY_ENDPOINT.replace(/wss?:/, ""); + localStorage.setItem("gatewayURL", window.GLOBAL_ENV.GATEWAY_ENDPOINT); + localStorage.setItem( + "DeveloperOptionsStore", + `{"trace":false,"canary":false,"logGatewayEvents":true,"logOverlayEvents":true,"logAnalyticsEvents":true,"sourceMapsEnabled":false,"axeEnabled":false}` + ); + + const supportedLocales = [ + "bg", + "cs", + "da", + "de", + "el", + "en-GB", + "es-ES", + "fi", + "fr", + "hi", + "hr", + "hu", + "it", + "ja", + "ko", + "lt", + "nl", + "no", + "pl", + "pt-BR", + "ro", + "ru", + "sv-SE", + "th", + "tr", + "uk", + "vi", + "zh-CN", + "zh-TW" + ]; + + const settings = JSON.parse(localStorage.getItem("UserSettingsStore")); + if (settings && !supportedLocales.includes(settings.locale)) { + // fix client locale wrong and client not loading at all + settings.locale = "en-US"; + localStorage.setItem("UserSettingsStore", JSON.stringify(settings)); + } \ No newline at end of file diff --git a/api/client_test/index.html b/api/client_test/index.html index 7e40d573..92499034 100644 --- a/api/client_test/index.html +++ b/api/client_test/index.html @@ -38,55 +38,9 @@ ALGOLIA_KEY: "aca0d7082e4e63af5ba5917d5e96bed0" }; GLOBAL_ENV.MEDIA_PROXY_ENDPOINT = location.protocol + "//" + GLOBAL_ENV.CDN_HOST; - const localStorage = window.localStorage; - // TODO: remote auth - // window.GLOBAL_ENV.REMOTE_AUTH_ENDPOINT = window.GLOBAL_ENV.GATEWAY_ENDPOINT.replace(/wss?:/, ""); - localStorage.setItem("gatewayURL", window.GLOBAL_ENV.GATEWAY_ENDPOINT); - localStorage.setItem( - "DeveloperOptionsStore", - `{"trace":false,"canary":false,"logGatewayEvents":true,"logOverlayEvents":true,"logAnalyticsEvents":true,"sourceMapsEnabled":false,"axeEnabled":false}` - ); - - const supportedLocales = [ - "bg", - "cs", - "da", - "de", - "el", - "en-GB", - "es-ES", - "fi", - "fr", - "hi", - "hr", - "hu", - "it", - "ja", - "ko", - "lt", - "nl", - "no", - "pl", - "pt-BR", - "ro", - "ru", - "sv-SE", - "th", - "tr", - "uk", - "vi", - "zh-CN", - "zh-TW" - ]; - - const settings = JSON.parse(localStorage.getItem("UserSettingsStore")); - if (settings && !supportedLocales.includes(settings.locale)) { - // fix client locale wrong and client not loading at all - settings.locale = "en-US"; - localStorage.setItem("UserSettingsStore", JSON.stringify(settings)); - } + -- cgit 1.5.1 From d57cd783ac664c95c5d915d9399033c671c1bfbb Mon Sep 17 00:00:00 2001 From: The Arcane Brony Date: Wed, 20 Oct 2021 17:54:54 +0200 Subject: Add plugin & css support, add styling to differentiate from discord.com --- .gitignore | 2 + api/assets/autoRegister.js | 57 -------------------- api/assets/preload-plugins/autoRegister.js | 62 ++++++++++++++++++++++ api/client_test/index.html | 27 +++++++++- bundle/scripts/build.js | 84 +++++++++++++++--------------- 5 files changed, 132 insertions(+), 100 deletions(-) delete mode 100644 api/assets/autoRegister.js create mode 100644 api/assets/preload-plugins/autoRegister.js (limited to 'api/assets') diff --git a/.gitignore b/.gitignore index 6e6de8d2..ca5886e1 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,5 @@ tsconfig.tsbuildinfo files/ .env config.json + +.vscode/settings.json diff --git a/api/assets/autoRegister.js b/api/assets/autoRegister.js deleted file mode 100644 index 29f93370..00000000 --- a/api/assets/autoRegister.js +++ /dev/null @@ -1,57 +0,0 @@ - // Auto register guest account: - const prefix = [ - "mysterious", - "adventurous", - "courageous", - "precious", - "cynical", - "despicable", - "suspicious", - "gorgeous", - "lovely", - "stunning", - "based", - "keyed", - "ratioed", - "twink", - "phoned" - ]; - const suffix = [ - "Anonymous", - "Lurker", - "User", - "Enjoyer", - "Hunk", - "Top", - "Bottom", - "Sub", - "Coolstar", - "Wrestling", - "TylerTheCreator", - "Ad" - ]; - - Array.prototype.random = function () { - return this[Math.floor(Math.random() * this.length)]; - }; - - function _generateName() { - return `${prefix.random()}${suffix.random()}`; - } - - const token = JSON.parse(localStorage.getItem("token")); - if (!token && location.pathname !== "/login" && location.pathname !== "/register") { - fetch(`${window.GLOBAL_ENV.API_ENDPOINT}/auth/register`, { - method: "POST", - headers: { "content-type": "application/json" }, - body: JSON.stringify({ username: `${_generateName()}`, consent: true }) //${Date.now().toString().slice(-4)} - }) - .then((x) => x.json()) - .then((x) => { - localStorage.setItem("token", `"${x.token}"`); - if (!window.localStorage) { - // client already loaded -> need to reload to apply the newly registered user token - location.reload(); - } - }); - } diff --git a/api/assets/preload-plugins/autoRegister.js b/api/assets/preload-plugins/autoRegister.js new file mode 100644 index 00000000..bb0b903d --- /dev/null +++ b/api/assets/preload-plugins/autoRegister.js @@ -0,0 +1,62 @@ +// Auto register guest account: +const prefix = [ + "mysterious", + "adventurous", + "courageous", + "precious", + "cynical", + "flamer ", + "despicable", + "suspicious", + "gorgeous", + "impeccable", + "lovely", + "stunning", + "keyed", + "phoned", + "glorious", + "amazing", + "strange", + "arcane" +]; +const suffix = [ + "Anonymous", + "Boy", + "Lurker", + "Keyhitter", + "User", + "Enjoyer", + "Hunk", + "Coolstar", + "Wrestling", + "TylerTheCreator", + "Ad", + "Gamer", + "Games", + "Programmer" +]; + +Array.prototype.random = function () { + return this[Math.floor(Math.random() * this.length)]; +}; + +function _generateName() { + return `${prefix.random()}${suffix.random()}`; +} + +var token = JSON.parse(localStorage.getItem("token")); +if (!token && location.pathname !== "/login" && location.pathname !== "/register") { + fetch(`${window.GLOBAL_ENV.API_ENDPOINT}/auth/register`, { + method: "POST", + headers: { "content-type": "application/json" }, + body: JSON.stringify({ username: `${_generateName()}`, consent: true }) //${Date.now().toString().slice(-4)} + }) + .then((x) => x.json()) + .then((x) => { + localStorage.setItem("token", `"${x.token}"`); + if (!window.localStorage) { + // client already loaded -> need to reload to apply the newly registered user token + location.reload(); + } + }); +} diff --git a/api/client_test/index.html b/api/client_test/index.html index 92499034..2ff0b469 100644 --- a/api/client_test/index.html +++ b/api/client_test/index.html @@ -4,6 +4,10 @@ Discord Test Client + + + + @@ -38,12 +42,33 @@ ALGOLIA_KEY: "aca0d7082e4e63af5ba5917d5e96bed0" }; GLOBAL_ENV.MEDIA_PROXY_ENDPOINT = location.protocol + "//" + GLOBAL_ENV.CDN_HOST; + const localStorage = window.localStorage; + // TODO: remote auth + // window.GLOBAL_ENV.REMOTE_AUTH_ENDPOINT = window.GLOBAL_ENV.GATEWAY_ENDPOINT.replace(/wss?:/, ""); + localStorage.setItem("gatewayURL", window.GLOBAL_ENV.GATEWAY_ENDPOINT); + localStorage.setItem( + "DeveloperOptionsStore", + `{"trace":false,"canary":false,"logGatewayEvents":true,"logOverlayEvents":true,"logAnalyticsEvents":true,"sourceMapsEnabled":false,"axeEnabled":false}` + ); + + + const token = JSON.parse(localStorage.getItem("token")); + if(token) { + document.querySelector("#logincss").remove(); + } + + const settings = JSON.parse(localStorage.getItem("UserSettingsStore")); + if (settings && settings.locale.length <= 2) { + // fix client locale wrong and client not loading at all + settings.locale = "en-US"; + localStorage.setItem("UserSettingsStore", JSON.stringify(settings)); + } - + diff --git a/bundle/scripts/build.js b/bundle/scripts/build.js index affd7892..c00c2eaa 100644 --- a/bundle/scripts/build.js +++ b/bundle/scripts/build.js @@ -9,57 +9,57 @@ const dirs = ["api", "util", "cdn", "gateway", "bundle"]; const verbose = argv.includes("verbose") || argv.includes("v"); if (argv.includes("clean")) { - dirs.forEach((a) => { - var d = "../" + a + "/dist"; - if (fse.existsSync(d)) { - fse.rmSync(d, { recursive: true }); - if (verbose) console.log(`Deleted ${d}!`); - } - }); + dirs.forEach((a) => { + var d = "../" + a + "/dist"; + if (fse.existsSync(d)) { + fse.rmSync(d, { recursive: true }); + if (verbose) console.log(`Deleted ${d}!`); + } + }); } fse.copySync( - path.join(__dirname, "..", "..", "api", "assets"), - path.join(__dirname, "..", "dist", "api", "assets") + path.join(__dirname, "..", "..", "api", "assets"), + path.join(__dirname, "..", "dist", "api", "assets") ); fse.copySync( - path.join(__dirname, "..", "..", "api", "client_test"), - path.join(__dirname, "..", "dist", "api", "client_test") + path.join(__dirname, "..", "..", "api", "client_test"), + path.join(__dirname, "..", "dist", "api", "client_test") ); fse.copySync( - path.join(__dirname, "..", "..", "api", "locales"), - path.join(__dirname, "..", "dist", "api", "locales") + path.join(__dirname, "..", "..", "api", "locales"), + path.join(__dirname, "..", "dist", "api", "locales") ); dirs.forEach((a) => { - fse.copySync("../" + a + "/src", "dist/" + a + "/src"); - if (verbose) - console.log( - `Copied ${"../" + a + "/dist"} -> ${"dist/" + a + "/src"}!` - ); + fse.copySync("../" + a + "/src", "dist/" + a + "/src"); + if (verbose) + console.log(`Copied ${"../" + a + "/dist"} -> ${"dist/" + a + "/src"}!`); }); -console.log("[1/2] Copying src files done"); -console.log("[2/2] Compiling src files ..."); +console.log("Copying src files done"); +if (!argv.includes("copyonly")) { + console.log("Compiling src files ..."); -console.log( - execSync( - 'node "' + - path.join( - __dirname, - "..", - "node_modules", - "typescript", - "lib", - "tsc.js" - ) + - '" -p "' + - path.join(__dirname, "..") + - '"', - { - cwd: path.join(__dirname, ".."), - shell: true, - env: process.env, - encoding: "utf8", - } - ) -); + console.log( + execSync( + 'node "' + + path.join( + __dirname, + "..", + "node_modules", + "typescript", + "lib", + "tsc.js" + ) + + '" -p "' + + path.join(__dirname, "..") + + '"', + { + cwd: path.join(__dirname, ".."), + shell: true, + env: process.env, + encoding: "utf8", + } + ) + ); +} -- cgit 1.5.1 From 062fe0769578e41895024534d8b2eae2bbbd9959 Mon Sep 17 00:00:00 2001 From: The Arcane Brony Date: Thu, 11 Nov 2021 22:14:33 +0100 Subject: Fix autoregister, add inline plugins --- .vscode/settings.json | 4 ++++ api/assets/dff87c953f43b561d71fbcfe8a93a79a.png | 0 2 files changed, 4 insertions(+) create mode 100644 .vscode/settings.json create mode 100644 api/assets/dff87c953f43b561d71fbcfe8a93a79a.png (limited to 'api/assets') diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..46e4e52f --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,4 @@ +{ + "awooga.originalColorCustomizations": {}, + "workbench.colorCustomizations": {} +} \ No newline at end of file diff --git a/api/assets/dff87c953f43b561d71fbcfe8a93a79a.png b/api/assets/dff87c953f43b561d71fbcfe8a93a79a.png new file mode 100644 index 00000000..e69de29b -- cgit 1.5.1 From 74d6290f3350fc98cbee69262f5aeaa95df93e2c Mon Sep 17 00:00:00 2001 From: The Arcane Brony Date: Sun, 14 Nov 2021 16:30:12 +0100 Subject: Add user.css --- api/assets/user.css | 1 + 1 file changed, 1 insertion(+) create mode 100644 api/assets/user.css (limited to 'api/assets') diff --git a/api/assets/user.css b/api/assets/user.css new file mode 100644 index 00000000..a7e5c4f3 --- /dev/null +++ b/api/assets/user.css @@ -0,0 +1 @@ +/* Your custom CSS goes here, enjoy! */ \ No newline at end of file -- cgit 1.5.1