aboutsummaryrefslogtreecommitdiff
path: root/views/script/core_chart.js
blob: d34ce21367b6ae38b806a37fe8586cdd47e3aeb2 (plain)
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
76
77
78
79
80
81
82
83
84
85
setInterval(() => {
    try {
        currentMemory = process.memoryUsage().rss;
        currentMemoryMib = (((currentMemory)/1024)/1024).toFixed(2);
        if ((((currentMemory)/1024)/1024) > 250) {
            throw new Error("Out of memory");
        }

        file = webview.getURL().split("/")[webview.getURL().split("/").length - 1];
        activity = lang.discord.game[0];
        enableActivity = false;
        eaid = "";

        switch (file) {
            case "game.html?online":
                enableActivity = true;
                activity = lang.online.discord;
                break;
            case "game.html?sp":
                enableActivity = true;
                activity = lang.discord.game[1];
                break;
            case "game.html":
                enableActivity = true;
                activity = lang.discord.game[2];
                break;
            case "intro.html":
                enableActivity = true;
                activity = lang.discord.intro[1];
                break;
            case "settings.html":
            case "stats.html":
                enableActivity = true;
                activity = lang.discord.settings[1];
                break;
            case "credits.html":
                enableActivity = true;
                activity = lang.discord.credits[1];
                break;
            case "online.html":
                enableActivity = true;
                activity = lang.online.discord2;
                break;
            case "menu.html":
            case "win.html":
                enableActivity = true;
                activity = lang.discord.credits[0];
                break;
            case "loader.html":
                enableActivity = false;
                break;
        }

        if (file.includes("online.html")) {
            activity = lang.online.discord2;
        }

        if (enableActivity) {
            eaid = " - " + activity;
        } else {
            eaid = "";
        }

        if (require('./package.json').channel === "git") {
            if (currentMemory < 100) {
                document.getElementById('experimental-ramusage').innerText = "0" + currentMemoryMib;
            } else {
                document.getElementById('experimental-ramusage').innerText = currentMemoryMib;
            }
            buff = Buffer.from(activity, 'utf-8').toString("hex");
            document.title="Kartik Trunk " +require('./package.json').version + "-" + require('./package.json').serial.toLowerCase() + "-debugkeys - <Debugging On>";
        } else {
            if (require('./package.json').channel !== "stable") {
                if (currentMemory < 100) {
                    document.getElementById('experimental-ramusage').innerText = "0" + currentMemoryMib;
                } else {
                    document.getElementById('experimental-ramusage').innerText = currentMemoryMib;
                }
                document.title="Kartik"+require('@electron/remote').getCurrentWindow().channel+require('./package.json').version + eaid;
            } else {
                document.title="Kartik"+require('@electron/remote').getCurrentWindow().channel+require('./package.json').version + eaid;
            }
        }
    } catch (e) {}
}, 1000)