-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
79 lines (63 loc) · 2.29 KB
/
main.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
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
const { app, BrowserWindow } = require('electron');
const { session } = require("electron");
const path = require("path");
let win;
const isDev = process.env.NODE_ENV === "development";
const userAgent = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.124 Safari/537.36 qblink wegame.exe WeGame/5.3.0.3250 QBCore/3.70.107.400 QQBrowser/9.0.2524.400";
const createWindow = () => {
win = new BrowserWindow({
width: 1920,
height: 1080,
webPreferences: {
webSecurity: false
}
});
if (isDev) {
win.loadURL("http://localhost:3000", {
userAgent,
});
win.webContents.openDevTools();
} else {
win.loadFile(path.resolve(__dirname, "dist/index.html"), {
userAgent
});
}
}
const filter = {
urls: [
"https://www.wegame.com.cn/*",
"https://*.qq.com/*"
]
};
app.whenReady()
.then(() => {
session.defaultSession.webRequest.onBeforeSendHeaders(filter, (detail, cb) => {
win.webContents
.executeJavaScript('localStorage.getItem("COOKIE_KEY");', true)
.then(cookies => {
const headers = {
Referer: "https://www.wegame.com.cn/helper/lol/record/profile.html",
Accept: "application/json, text/plain, */*",
'trpc-caller': "wegame.pallas.web.LolBattle",
'content-type': "application/json;charset=UTF-8",
'cookie': cookies
};
Object.keys(headers)
.forEach(k => {
detail.requestHeaders[k] = headers[k];
});
cb({
requestHeaders: detail.requestHeaders
});
});
});
createWindow();
app.on('activate', () => {
// On macOS it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open.
if (BrowserWindow.getAllWindows().length === 0) createWindow()
})
});
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') app.quit()
})