summaryrefslogtreecommitdiff
path: root/index.js
blob: 752ca2373f39858dc6830f56d5ad296b7633c29e (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
// noinspection HttpUrlsUsage

const { app, BrowserWindow, ipcMain } = require('electron');

const createWindow = () => {
    global.mainWindow = new BrowserWindow({
        width: 1200,
        height: 700,
        title: "Bits",
        fullscreenable: false,
        backgroundColor: "#222",
        webPreferences: {
            nodeIntegration: true,
            nodeIntegrationInSubFrames: true,
            contextIsolation: false,
            enableRemoteModule: true
        }
    })

    mainWindow.loadFile('index.html')
    mainWindow.menuBarVisible = false;
}

process.on('uncaughtException', (error) => {
    console.error(error);
})

app.whenReady().then(() => {
    createWindow()
})

app.on('window-all-closed', () => {
    app.quit()
})

global.authenticationSucceeded = false;

ipcMain.on("login", () => {
    const loginWindow = new BrowserWindow({
        width: 500,
        height: 800,
        parent: mainWindow,
        title: "Bits",
        show: false,
        fullscreenable: false,
        backgroundColor: "#fff",
        webPreferences: {
            nodeIntegration: false,
            nodeIntegrationInSubFrames: false,
            contextIsolation: true,
            enableRemoteModule: false
        }
    });

    global.authenticationCheckInterval = setInterval(() => {
        let url = loginWindow.webContents.getURL();

        if (url.startsWith("https://auth.equestria.horse") || url.includes("Disallowed")) {
            loginWindow.show();
        }

        if (url === "https://money-v1.equestria.dev/Authentication/Success/" || url === "https://money-v2.equestria.dev/Authentication/Success/") {
            clearInterval(authenticationCheckInterval);
            global.authenticationSucceeded = true;
            loginWindow.close();
            mainWindow.webContents.reload();
        }
    }, 100);

    loginWindow.on('close', () => {
        if (!authenticationSucceeded) mainWindow.close();
    })

    loginWindow.loadURL("https://money.equestria.dev/Authentication/Start");
})