summary refs log tree commit diff
diff options
context:
space:
mode:
authorMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2022-10-24 18:59:53 +1100
committerMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2022-10-24 18:59:53 +1100
commit6a09c230d1f6cc5b67539dba88e1c2f24fa71b28 (patch)
treecf10965550e860d338e1143c18af9537db6b1d83
parentFix server -> guild patch and add status.discord.com -> status.understars.dev... (diff)
downloadserver-6a09c230d1f6cc5b67539dba88e1c2f24fa71b28.tar.xz
rearrange test client's index a bit
-rw-r--r--assets/cacheMisses5
-rw-r--r--assets/client_test/developers.html1
-rw-r--r--assets/client_test/index.html146
-rw-r--r--assets/preload-plugins/autoRegister.js62
-rw-r--r--assets/preload-plugins/checkLocale.js46
-rw-r--r--assets/preload-plugins/loginRedirect.js27
-rw-r--r--assets/public/checkLocale.js47
7 files changed, 136 insertions, 198 deletions
diff --git a/assets/cacheMisses b/assets/cacheMisses
index 056f4d66..2f68a713 100644
--- a/assets/cacheMisses
+++ b/assets/cacheMisses
@@ -183,3 +183,8 @@ dbdc2f57ed1a7f2f01a342ab2e6fb032.svg
 9a31e0f65d520cc12d7f42374d59a2d1.svg
 d759f3acc6286c964cc8118d7f68b374.svg
 eeacc28d3c62a7cf1154a2bc11968ad8.svg
+9fa091f676e4451ee5946fed948cb8fe.svg
+7c010dc6da25c012643ea22c1f002bb4.svg
+9ea87b934848cd1f5c4bc7f1fcdac803.png
+626aaed496ac12bbdb68a86b46871a1f.svg
+66f6c781fe86c346fbaf3390618668fc.svg
diff --git a/assets/client_test/developers.html b/assets/client_test/developers.html
index 2a4402d7..1673e982 100644
--- a/assets/client_test/developers.html
+++ b/assets/client_test/developers.html
@@ -26,7 +26,6 @@
 				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);
diff --git a/assets/client_test/index.html b/assets/client_test/index.html
index 7a3e4695..da6e2854 100644
--- a/assets/client_test/index.html
+++ b/assets/client_test/index.html
@@ -1,80 +1,78 @@
 <!DOCTYPE html>
 <html lang="en">
-	<head>
-		<meta charset="UTF-8" />
-		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
-		<title>Discord Test Client</title>
-		<link rel="stylesheet" href="/assets/fosscord.css" />
-		<link id="logincss" rel="stylesheet" href="/assets/fosscord-login.css" />
-		<link id="customcss" rel="stylesheet" href="/assets/user.css" />
-		<!-- preload plugin marker -->
-	</head>
 
-	<body>
-		<div id="app-mount"></div>
-		<script>
-			window.__OVERLAY__ = /overlay/.test(location.pathname);
-			window.__BILLING_STANDALONE__ = /^\/billing/.test(location.pathname);
-			window.GLOBAL_ENV = {
-				API_ENDPOINT: "/api",
-				API_VERSION: 9,
-				GATEWAY_ENDPOINT: `${location.protocol === "https:" ? "wss://" : "ws://"}${location.hostname}:3002`,
-				WEBAPP_ENDPOINT: "",
-				CDN_HOST: `${location.hostname}:3003`,
-				ASSET_ENDPOINT: "",
-				MEDIA_PROXY_ENDPOINT: "https://media.discordapp.net",
-				WIDGET_ENDPOINT: `//${location.host}/widget`,
-				INVITE_HOST: `${location.hostname}/invite`,
-				GUILD_TEMPLATE_HOST: "${location.host}",
-				GIFT_CODE_HOST: "${location.hostname}",
-				RELEASE_CHANNEL: "stable",
-				MARKETING_ENDPOINT: "//discord.com",
-				BRAINTREE_KEY: "production_5st77rrc_49pp2rp4phym7387",
-				STRIPE_KEY: "pk_live_CUQtlpQUF0vufWpnpUmQvcdi",
-				NETWORKING_ENDPOINT: "//router.discordapp.net",
-				RTC_LATENCY_ENDPOINT: "//${location.hostname}/rtc",
-				PROJECT_ENV: "production",
-				REMOTE_AUTH_ENDPOINT: "//localhost:3020",
-				SENTRY_TAGS: { buildId: "75e36d9", buildType: "normal" },
-				MIGRATION_SOURCE_ORIGIN: "https://${location.hostname}",
-				MIGRATION_DESTINATION_ORIGIN: "https://${location.hostname}",
-				HTML_TIMESTAMP: Date.now(),
-				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}`
-			);
+<head>
+	<meta charset="UTF-8" />
+	<meta name="viewport" content="width=device-width, initial-scale=1.0" />
+	<title>Discord Test Client</title>
+	<link rel="stylesheet" href="/assets/fosscord.css" />
+	<link id="logincss" rel="stylesheet" href="/assets/fosscord-login.css" />
+	<link id="customcss" rel="stylesheet" href="/assets/user.css" />
 
-			setInterval(() => {
-				var token = JSON.parse(localStorage.getItem("token"));
-				if (token) {
-					var logincss = document.querySelector('#logincss'),
-					canRemove = logincss ? logincss: "";
-					if(canRemove !== "") {
-					document.querySelector("#logincss").remove();
-					canRemove = "";
-					}
-				}
-			}, 1000)
+	<script>
+		window.__OVERLAY__ = /overlay/.test(location.pathname);
+		window.__BILLING_STANDALONE__ = /^\/billing/.test(location.pathname);
+		window.GLOBAL_ENV = {
+			API_ENDPOINT: "/api",
+			API_VERSION: 9,
+			GATEWAY_ENDPOINT: `${location.protocol === "https:" ? "wss://" : "ws://"}${location.hostname}:3002`,
+			WEBAPP_ENDPOINT: "",
+			CDN_HOST: `${location.hostname}:3003`,
+			ASSET_ENDPOINT: "",
+			MEDIA_PROXY_ENDPOINT: "https://media.discordapp.net",
+			WIDGET_ENDPOINT: `//${location.host}/widget`,
+			INVITE_HOST: `${location.hostname}/invite`,
+			GUILD_TEMPLATE_HOST: "${location.host}",
+			GIFT_CODE_HOST: "${location.hostname}",
+			RELEASE_CHANNEL: "stable",
+			MARKETING_ENDPOINT: "//discord.com",
+			BRAINTREE_KEY: "production_5st77rrc_49pp2rp4phym7387",
+			STRIPE_KEY: "pk_live_CUQtlpQUF0vufWpnpUmQvcdi",
+			NETWORKING_ENDPOINT: "//router.discordapp.net",
+			RTC_LATENCY_ENDPOINT: "//${location.hostname}/rtc",
+			PROJECT_ENV: "Slowcord",
+			REMOTE_AUTH_ENDPOINT: "//localhost:3020",
+			SENTRY_TAGS: { buildId: "75e36d9", buildType: "normal" },
+			MIGRATION_SOURCE_ORIGIN: "https://${location.hostname}",
+			MIGRATION_DESTINATION_ORIGIN: "https://${location.hostname}",
+			HTML_TIMESTAMP: Date.now(),
+			ALGOLIA_KEY: "aca0d7082e4e63af5ba5917d5e96bed0"
+		};
+		GLOBAL_ENV.MEDIA_PROXY_ENDPOINT = location.protocol + "//" + GLOBAL_ENV.CDN_HOST;
+		// 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 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));
+		/*
+		// Not required because slowcord has its own logic server
+		setInterval(() => {
+			var token = JSON.parse(localStorage.getItem("token"));
+			if (token) {
+				var logincss = document.querySelector('#logincss'),
+				canRemove = logincss ? logincss: "";
+				if(canRemove !== "") {
+				document.querySelector("#logincss").remove();
+				canRemove = "";
+				}
 			}
-		</script>
-	 	<script src="/assets/checkLocale.js"></script>
-		 <script src="/assets/83ace7450e110d16319e.js"></script>
-		 <script src="/assets/e02290aaa8dac5d195c2.js"></script>
-		 <script src="/assets/4f3b3c576b879a5f75d1.js"></script>
-		 <script src="/assets/699456246fdfe7589855.js"></script>
-		<!-- plugin marker -->
-	</body>
-</html>
+		}, 1000)
+		*/
+	</script>
+
+	<!-- preload plugin marker -->
+</head>
+
+<body>
+	<div id="app-mount"></div>
+	<script src="/assets/83ace7450e110d16319e.js"></script>
+	<script src="/assets/e02290aaa8dac5d195c2.js"></script>
+	<script src="/assets/4f3b3c576b879a5f75d1.js"></script>
+	<script src="/assets/699456246fdfe7589855.js"></script>
+	<!-- plugin marker -->
+</body>
+
+</html>
\ No newline at end of file
diff --git a/assets/preload-plugins/autoRegister.js b/assets/preload-plugins/autoRegister.js
deleted file mode 100644
index bb0b903d..00000000
--- a/assets/preload-plugins/autoRegister.js
+++ /dev/null
@@ -1,62 +0,0 @@
-// 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/assets/preload-plugins/checkLocale.js b/assets/preload-plugins/checkLocale.js
new file mode 100644
index 00000000..0fbc73ee
--- /dev/null
+++ b/assets/preload-plugins/checkLocale.js
@@ -0,0 +1,46 @@
+// 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/assets/preload-plugins/loginRedirect.js b/assets/preload-plugins/loginRedirect.js
index c527d79d..cda4da44 100644
--- a/assets/preload-plugins/loginRedirect.js
+++ b/assets/preload-plugins/loginRedirect.js
@@ -1,17 +1,16 @@
-if (window.location.hostname == "127.0.0.1" || window.location.hostname == "localhost")
-	throw "disabling loginRedirect because localhost";
+if (window.location.hostname !== "127.0.0.1" && window.location.hostname !== "localhost") {
+	const redirectIfOnLogin = () => {
+		const path = window.location.pathname;
+		if (path == "/login" || path == "/register" || !localStorage.getItem("token")) {
+			window.location.pathname = "/login";
+			//window.location.reload();
+		}
+	};
 
-const redirectIfOnLogin = () => {
-	const path = window.location.pathname;
-	if (path == "/login" || path == "/register" || !localStorage.getItem("token")) {
-		window.location.pathname = "/login";
-		//window.location.reload();
-	}
-};
+	const observer = new MutationObserver((mutations) => {
+		redirectIfOnLogin();
+	});
+	observer.observe(document, { subtree: true, childList: true });
 
-const observer = new MutationObserver((mutations) => {
 	redirectIfOnLogin();
-});
-observer.observe(document, { subtree: true, childList: true });
-
-redirectIfOnLogin();
\ No newline at end of file
+}
\ No newline at end of file
diff --git a/assets/public/checkLocale.js b/assets/public/checkLocale.js
deleted file mode 100644
index 016d66c8..00000000
--- a/assets/public/checkLocale.js
+++ /dev/null
@@ -1,47 +0,0 @@
-			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