aboutsummaryrefslogtreecommitdiff
path: root/views/script/core_viewer.js
blob: a538b9982068bc3b22e3f89ec346e3335abab9c1 (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
const webview = document.getElementById('wb');

try {
    webview.addEventListener('dom-ready', () => {
        setTimeout(() => {
            document.getElementById('dummyloader').style.display = "none";
        }, 5000)
        require('@electron/remote').getCurrentWindow().log(" * " + webview.getURL());
        require('@electron/remote').getCurrentWindow().focus();
        if (location.hash === "#ready") {
            require('@electron/remote').webContents.fromId(webview.getWebContentsId()).send("ready", true);
        }
        webview.focus();
        try {
            if (require('@electron/remote').getCurrentWindow().debug) {
                info("MainWindow", "Opening debugging tools...");
                webview.openDevTools();
            }
        } catch (e) {}
    })

    webview.addEventListener('dom-ready', () => {
        setInterval(() => {
            try {
                if (webview.isCrashed() && !gameCrashed) {
                    require('@electron/remote').getCurrentWindow().log(" * Compositing engine crashed!");
                    error("MainWindow", "Subcontainer crashed");
                    crash(new Error("Webview crashed"));
                }
            } catch (e) {}
        }, 2000)
    })
} catch (e) {}