summary refs log tree commit diff
path: root/ReferenceClientProxyImplementation/Resources/Pages/index-template.html
blob: ef77e225d0afab9e72710c5001e60ddb8b6ebba3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8"/>
        <meta content="width=device-width, initial-scale=1.0" name="viewport"/>
        <title>Discord Test Client</title>
        <link href="/assets/fosscord.css" rel="stylesheet"/>
        <link href="/assets/fosscord-login.css" id="logincss" rel="stylesheet"/>
        <link href="/assets/user.css" id="customcss" rel="stylesheet"/>
        <!-- preload plugin marker -->
    </head>

    <body>
        <div id="app-mount"></div>
        <script>
            window.__OVERLAY__ = /overlay/.test(location.pathname);
            window.__BILLING_STANDALONE__ = /^\/billing/.test(location.pathname);

            var xmlhttp = new XMLHttpRequest();
            var url = "/api/_fosscord/v1/global_env";
            xmlhttp.onreadystatechange = function () {
                if (this.readyState == 4 && this.status == 200) {
                    window.GLOBAL_ENV = JSON.parse(this.responseText);
                }
            }

            xmlhttp.open("GET", url, false);
            xmlhttp.send();


            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",
                JSON.stringify({
                    trace: false,
                    canary: true,
                    logGatewayEvents: true,
                    logOverlayEvents: true,
                    logAnalyticsEvents: true,
                    sourceMapsEnabled: false,
                    axeEnabled: true,
                    bugReporterEnabled: true,
                    idleStatusIndicatorEnabled: false
                })
            );

            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)

            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>
        <!--prefetch_script-->
        <!--client_css-->
        <script src="/assets/checkLocale.js"></script>
        <!--client_script-->
        <!-- plugin marker -->
    </body>
</html>