forked from xh321/LiteLoaderQQNT-Kill-Update
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
57 lines (50 loc) · 1.89 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
const { BrowserWindow, ipcMain } = require("electron");
function onBrowserWindowCreated(window) {
const original_send =
(window.webContents.__qqntim_original_object &&
window.webContents.__qqntim_original_object.send) ||
window.webContents.send;
const patched_send = function (channel, ...args) {
if (args.length >= 2) {
//更新 IPC
if (
args.some(
(item) =>
item instanceof Array &&
item.length > 0 &&
item[0] &&
item[0].cmdName != null
)
) {
var args1 = args[1][0];
if (args1.cmdName.indexOf("onUnitedConfigUpdate") != -1) {
try {
var isUpdate = args1.payload?.configData?.content;
var realUpdateObj = JSON.parse(isUpdate);
var updateVal =
realUpdateObj instanceof Array &&
realUpdateObj?.some(
(item) =>
item &&
item.releaseVersion &&
item.lowestVersion &&
item.jumpUrl
);
if (updateVal) {
args[1][0].payload = [];
}
} catch {}
}
}
}
return original_send.call(window.webContents, channel, ...args);
};
if (window.webContents.__qqntim_original_object)
window.webContents.__qqntim_original_object.send = patched_send;
else window.webContents.send = patched_send;
}
function onLoad(plugin) {}
module.exports = {
onLoad,
onBrowserWindowCreated
};