diff options
author | Minteck <contact@minteck.org> | 2022-06-06 17:11:17 +0200 |
---|---|---|
committer | Minteck <contact@minteck.org> | 2022-06-06 17:11:17 +0200 |
commit | 1d0620122f7648495c65fc58d6309eb8ad65bffc (patch) | |
tree | 16d57cdc993b0516aba0c4f8f754e45bdafcc0b9 /index.js | |
download | bits-client-1d0620122f7648495c65fc58d6309eb8ad65bffc.tar.gz bits-client-1d0620122f7648495c65fc58d6309eb8ad65bffc.tar.bz2 bits-client-1d0620122f7648495c65fc58d6309eb8ad65bffc.zip |
Initial commit
Diffstat (limited to 'index.js')
-rw-r--r-- | index.js | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/index.js b/index.js new file mode 100644 index 0000000..360f3ca --- /dev/null +++ b/index.js @@ -0,0 +1,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://account.minteck.org") || url.includes("Disallowed")) { + loginWindow.show(); + } + + if (url === "https://money.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"); +})
\ No newline at end of file |