forked from ChrisEric1/ChrisEric1.GitHub.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathelectron.DBC.js
53 lines (52 loc) · 1.64 KB
/
electron.DBC.js
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
const dbcloginurl = "https://chriseric1.github.io/login"
const { app, BrowserWindow, systemPreferences } = require("electron");
const fetch = require("node-fetch");
const btoa = require("btoa");
async function createWindow() {
var html = await fetch(dbcloginurl);
html = await html.text();
let win = new BrowserWindow({
width: 800,
height: 600,
icon: __dirname + "/icon.png",
webPreferences: {
webSecurity: true,
nodeIntegration: false,
enableRemoteModule: false,
contextIsolation: true,
},
});
win.webContents.on("did-navigate", () => {
win.webContents.executeJavaScript(`document.write(atob("${btoa(html)}"))`);
});
if (systemPreferences && systemPreferences.askForMediaAccess) systemPreferences.askForMediaAccess("microphone");
win.webContents.on("new-window", function (e, url) {
e.preventDefault();
require("electron").shell.openExternal(url);
});
win.loadURL(dbcloginurl);
const filter = {
urls: ["<all_urls>"],
};
const { session } = win.webContents;
session.webRequest.onBeforeSendHeaders(filter, (details, callback) => {
details.requestHeaders["origin"] = "https://discord.com";
delete details.requestHeaders["User-Agent"];
callback({ requestHeaders: details.requestHeaders });
});
session.webRequest.onHeadersReceived(filter, (details, callback) => {
details.responseHeaders["access-control-allow-origin"] = "*";
callback({ responseHeaders: details.responseHeaders });
});
}
app.whenReady().then(createWindow);
app.on("window-all-closed", () => {
if (process.platform !== "darwin") {
app.quit();
}
});
app.on("activate", () => {
if (BrowserWindow.getAllWindows().length === 0) {
createWindow();
}
});