forked from zyr17/MajsoulPaipuAnalyzer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
browseinject.js
73 lines (68 loc) · 2.96 KB
/
browseinject.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
var electron = require("electron");
var ipcr = electron.ipcRenderer;
function getAccountID(){
if (global.GameMgr == undefined || GameMgr.Inst == undefined || GameMgr.Inst.account_id == -1)
setTimeout(getAccountID, 1000);
else ipcr.send('userid', GameMgr.Inst.account_id);
}
setTimeout(getAccountID, 1000);
ipcr.on('collectpaipu', (event, operation) => {
if (global.GameMgr == undefined || GameMgr.Inst == undefined || GameMgr.Inst.account_id == -1){
ipcr.send('collectpaipucallback', { type: 'UserID' });
return;
}
if (global.uiscript == undefined || uiscript.UI_PaiPu == undefined){
ipcr.send('collectpaipucallback', { type: 'uisciprt' });
return;
}
collectallpaipu(null, function () {
let res = [];
for (let i in uiscript.UI_PaiPu.record_map)
res.push(uiscript.UI_PaiPu.record_map[i]);
ipcr.send('collectpaipucallback', undefined, operation, res);
});
});
ipcr.on('fetchpaipudata', (event, uuid) => {
//console.log('fetching paipu, uuid=' + uuid);
app.NetAgent.sendReq2Lobby("Lobby","fetchGameRecord", {game_uuid: uuid}, function (t, a) {
ipcr.send('fetchpaipudatacallback', a.error, a.data, a.data_url);
//console.log('fetch result:', a.data, a.data_url);
});
});
function collectallpaipu(event, callback) {
// alert("将开始自动收集牌谱基本数据!如果牌谱较多需要一定时间。");
const get_more = function (result,start,type="ALL",count=30) {
app.NetAgent.sendReq2Lobby("Lobby", "fetchGameRecordList", {
start,
count,
type
},
function(n, {record_list}) {
console.log(start,record_list);
m = uiscript.UI_PaiPu.record_map;
if(record_list.length>0 && !m[record_list[0].uuid]){
get_more(result.concat(record_list),start+count)
}else{
result.forEach((item)=>{
m[item.uuid] = item
});
let count = 0;
for (let i in uiscript.UI_PaiPu.record_map)
count ++ ;
// alert("已自动收集牌谱基本数据!牌谱个数:" + count);
callback && callback();
}
});
}
get_more([], 0);
}
ipcr.on('collectallpaipu', collectallpaipu);
var InjectOverNode = document.createElement('p');
InjectOverNode.innerHTML = '脚本加载完成,点击隐藏';
InjectOverNode.setAttribute('style', 'color: #2D2;z-index: 999;position: absolute;left: 0px;top: 0px;font-weight: bold;');
InjectOverNode.setAttribute('id', 'InjectOverNode');
InjectOverNode.onclick = function () {
this.setAttribute('style', 'visibility: collapse');
};
document.getElementsByTagName('body')[0].appendChild(InjectOverNode);
ipcr.send('bwindowinjectfinish');