rearrange test client's index a bit

This commit is contained in:
Madeline 2022-10-24 18:59:53 +11:00
parent ce14760c2b
commit 56444d1942
7 changed files with 136 additions and 198 deletions

View File

@ -183,3 +183,8 @@ dbdc2f57ed1a7f2f01a342ab2e6fb032.svg
9a31e0f65d520cc12d7f42374d59a2d1.svg 9a31e0f65d520cc12d7f42374d59a2d1.svg
d759f3acc6286c964cc8118d7f68b374.svg d759f3acc6286c964cc8118d7f68b374.svg
eeacc28d3c62a7cf1154a2bc11968ad8.svg eeacc28d3c62a7cf1154a2bc11968ad8.svg
9fa091f676e4451ee5946fed948cb8fe.svg
7c010dc6da25c012643ea22c1f002bb4.svg
9ea87b934848cd1f5c4bc7f1fcdac803.png
626aaed496ac12bbdb68a86b46871a1f.svg
66f6c781fe86c346fbaf3390618668fc.svg

View File

@ -26,7 +26,6 @@
ALGOLIA_KEY: "aca0d7082e4e63af5ba5917d5e96bed0" ALGOLIA_KEY: "aca0d7082e4e63af5ba5917d5e96bed0"
}; };
GLOBAL_ENV.MEDIA_PROXY_ENDPOINT = location.protocol + "//" + GLOBAL_ENV.CDN_HOST; GLOBAL_ENV.MEDIA_PROXY_ENDPOINT = location.protocol + "//" + GLOBAL_ENV.CDN_HOST;
const localStorage = window.localStorage;
// TODO: remote auth // TODO: remote auth
// window.GLOBAL_ENV.REMOTE_AUTH_ENDPOINT = window.GLOBAL_ENV.GATEWAY_ENDPOINT.replace(/wss?:/, ""); // window.GLOBAL_ENV.REMOTE_AUTH_ENDPOINT = window.GLOBAL_ENV.GATEWAY_ENDPOINT.replace(/wss?:/, "");
localStorage.setItem("gatewayURL", window.GLOBAL_ENV.GATEWAY_ENDPOINT); localStorage.setItem("gatewayURL", window.GLOBAL_ENV.GATEWAY_ENDPOINT);

View File

@ -1,17 +1,14 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head>
<head>
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Discord Test Client</title> <title>Discord Test Client</title>
<link rel="stylesheet" href="/assets/fosscord.css" /> <link rel="stylesheet" href="/assets/fosscord.css" />
<link id="logincss" rel="stylesheet" href="/assets/fosscord-login.css" /> <link id="logincss" rel="stylesheet" href="/assets/fosscord-login.css" />
<link id="customcss" rel="stylesheet" href="/assets/user.css" /> <link id="customcss" rel="stylesheet" href="/assets/user.css" />
<!-- preload plugin marker -->
</head>
<body>
<div id="app-mount"></div>
<script> <script>
window.__OVERLAY__ = /overlay/.test(location.pathname); window.__OVERLAY__ = /overlay/.test(location.pathname);
window.__BILLING_STANDALONE__ = /^\/billing/.test(location.pathname); window.__BILLING_STANDALONE__ = /^\/billing/.test(location.pathname);
@ -33,7 +30,7 @@
STRIPE_KEY: "pk_live_CUQtlpQUF0vufWpnpUmQvcdi", STRIPE_KEY: "pk_live_CUQtlpQUF0vufWpnpUmQvcdi",
NETWORKING_ENDPOINT: "//router.discordapp.net", NETWORKING_ENDPOINT: "//router.discordapp.net",
RTC_LATENCY_ENDPOINT: "//${location.hostname}/rtc", RTC_LATENCY_ENDPOINT: "//${location.hostname}/rtc",
PROJECT_ENV: "production", PROJECT_ENV: "Slowcord",
REMOTE_AUTH_ENDPOINT: "//localhost:3020", REMOTE_AUTH_ENDPOINT: "//localhost:3020",
SENTRY_TAGS: { buildId: "75e36d9", buildType: "normal" }, SENTRY_TAGS: { buildId: "75e36d9", buildType: "normal" },
MIGRATION_SOURCE_ORIGIN: "https://${location.hostname}", MIGRATION_SOURCE_ORIGIN: "https://${location.hostname}",
@ -42,7 +39,6 @@
ALGOLIA_KEY: "aca0d7082e4e63af5ba5917d5e96bed0" ALGOLIA_KEY: "aca0d7082e4e63af5ba5917d5e96bed0"
}; };
GLOBAL_ENV.MEDIA_PROXY_ENDPOINT = location.protocol + "//" + GLOBAL_ENV.CDN_HOST; GLOBAL_ENV.MEDIA_PROXY_ENDPOINT = location.protocol + "//" + GLOBAL_ENV.CDN_HOST;
const localStorage = window.localStorage;
// TODO: remote auth // TODO: remote auth
// window.GLOBAL_ENV.REMOTE_AUTH_ENDPOINT = window.GLOBAL_ENV.GATEWAY_ENDPOINT.replace(/wss?:/, ""); // window.GLOBAL_ENV.REMOTE_AUTH_ENDPOINT = window.GLOBAL_ENV.GATEWAY_ENDPOINT.replace(/wss?:/, "");
localStorage.setItem("gatewayURL", window.GLOBAL_ENV.GATEWAY_ENDPOINT); localStorage.setItem("gatewayURL", window.GLOBAL_ENV.GATEWAY_ENDPOINT);
@ -51,6 +47,8 @@
`{"trace":false,"canary":false,"logGatewayEvents":true,"logOverlayEvents":true,"logAnalyticsEvents":true,"sourceMapsEnabled":false,"axeEnabled":false}` `{"trace":false,"canary":false,"logGatewayEvents":true,"logOverlayEvents":true,"logAnalyticsEvents":true,"sourceMapsEnabled":false,"axeEnabled":false}`
); );
/*
// Not required because slowcord has its own logic server
setInterval(() => { setInterval(() => {
var token = JSON.parse(localStorage.getItem("token")); var token = JSON.parse(localStorage.getItem("token"));
if (token) { if (token) {
@ -62,19 +60,19 @@
} }
} }
}, 1000) }, 1000)
*/
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));
}
</script> </script>
<script src="/assets/checkLocale.js"></script>
<!-- preload plugin marker -->
</head>
<body>
<div id="app-mount"></div>
<script src="/assets/83ace7450e110d16319e.js"></script> <script src="/assets/83ace7450e110d16319e.js"></script>
<script src="/assets/e02290aaa8dac5d195c2.js"></script> <script src="/assets/e02290aaa8dac5d195c2.js"></script>
<script src="/assets/4f3b3c576b879a5f75d1.js"></script> <script src="/assets/4f3b3c576b879a5f75d1.js"></script>
<script src="/assets/699456246fdfe7589855.js"></script> <script src="/assets/699456246fdfe7589855.js"></script>
<!-- plugin marker --> <!-- plugin marker -->
</body> </body>
</html> </html>

View File

@ -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();
}
});
}

View File

@ -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));
}

View File

@ -1,17 +1,16 @@
if (window.location.hostname == "127.0.0.1" || window.location.hostname == "localhost") if (window.location.hostname !== "127.0.0.1" && window.location.hostname !== "localhost") {
throw "disabling loginRedirect because localhost"; const redirectIfOnLogin = () => {
const redirectIfOnLogin = () => {
const path = window.location.pathname; const path = window.location.pathname;
if (path == "/login" || path == "/register" || !localStorage.getItem("token")) { if (path == "/login" || path == "/register" || !localStorage.getItem("token")) {
window.location.pathname = "/login"; window.location.pathname = "/login";
//window.location.reload(); //window.location.reload();
} }
}; };
const observer = new MutationObserver((mutations) => { const observer = new MutationObserver((mutations) => {
redirectIfOnLogin(); redirectIfOnLogin();
}); });
observer.observe(document, { subtree: true, childList: true }); observer.observe(document, { subtree: true, childList: true });
redirectIfOnLogin(); redirectIfOnLogin();
}

View File

@ -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));
}