更新
This commit is contained in:
parent
925056d674
commit
1347dea770
2
build.js
2
build.js
@ -1,7 +1,7 @@
|
|||||||
let fs = require('fs');
|
let fs = require('fs');
|
||||||
|
|
||||||
let date = new Date();
|
let date = new Date();
|
||||||
let version = '0.3.39';
|
let version = process.env.npm_package_version;
|
||||||
let head = `// ==UserScript==
|
let head = `// ==UserScript==
|
||||||
// @lastmodified ${date.getFullYear()}${('0' + (date.getMonth() + 1)).slice(-2)}${('0' + date.getDate()).slice(-2)}${('0' + date.getHours()).slice(-2)}${('0' + date.getMinutes()).slice(-2)}
|
// @lastmodified ${date.getFullYear()}${('0' + (date.getMonth() + 1)).slice(-2)}${('0' + date.getDate()).slice(-2)}${('0' + date.getHours()).slice(-2)}${('0' + date.getMinutes()).slice(-2)}
|
||||||
// @name 芜湖助手
|
// @name 芜湖助手
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "wuhu-torn-helper",
|
"name": "wuhu-torn-helper",
|
||||||
"version": "",
|
"version": "0.4.1",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"uglify-js": "^3.16.1"
|
"uglify-js": "^3.16.1"
|
||||||
},
|
},
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@ -4109,6 +4109,7 @@ div#wh-popup::after {
|
|||||||
color: black;
|
color: black;
|
||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
}
|
}
|
||||||
|
#wh-popup-cont button[disabled]{opacity: 0.5;}
|
||||||
#wh-popup-cont input{
|
#wh-popup-cont input{
|
||||||
padding: 2px;
|
padding: 2px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
@ -10093,22 +10094,36 @@ z-index:100001;
|
|||||||
attackers.obj = {};
|
attackers.obj = {};
|
||||||
let records = document.createElement('div');
|
let records = document.createElement('div');
|
||||||
records.list = [];
|
records.list = [];
|
||||||
|
records.details = {};
|
||||||
|
// interval loop_id
|
||||||
|
let loop_id = null;
|
||||||
let updateAttackersDOM = function () {
|
let updateAttackersDOM = function () {
|
||||||
let html = '进攻者:<br/>'
|
let html = '进攻者:<br/>';
|
||||||
attackers.obj.keys().forEach(id => html += `${id}<br/>`);
|
Object.keys(attackers.obj).forEach(id => html += `[${id}]<br/>`);
|
||||||
attackers.innerHTML = html;
|
attackers.innerHTML = html;
|
||||||
};
|
};
|
||||||
let updateRecordsDOM = function () {
|
let updateRecordsDOM = function () {
|
||||||
|
let html = '战斗记录:<br/>';
|
||||||
|
records.list.forEach(rid => {
|
||||||
|
let { TimeCreated, attackID, attackerID, attackerItemID, result, text } = records.details[rid];
|
||||||
|
html += `[${TimeCreated}] [${attackerID}] [${attackerItemID}] ${result} ${text}<br/>`;
|
||||||
|
});
|
||||||
|
records.innerHTML = html;
|
||||||
};
|
};
|
||||||
|
|
||||||
let count = 0;
|
|
||||||
let id = null;
|
|
||||||
|
|
||||||
uid.type = 'text';
|
uid.type = 'text';
|
||||||
|
uid.placeholder = '目标ID';
|
||||||
start.innerHTML = '开启';
|
start.innerHTML = '开启';
|
||||||
stop.innerHTML = '关闭';
|
stop.innerHTML = '关闭';
|
||||||
|
stop.disabled = true;
|
||||||
self_target.innerHTML = '填入自己';
|
self_target.innerHTML = '填入自己';
|
||||||
p.innerHTML = '状态:已关';
|
// p.innerHTML = '状态:已关';
|
||||||
|
// 弹出窗口关闭时结束
|
||||||
|
let popup_close = popup.close;
|
||||||
|
popup.close = () => {
|
||||||
|
if (loop_id === null) popup_close();
|
||||||
|
else WHNotify('守望者运行中,请先停止', { timeout: 2 });
|
||||||
|
}
|
||||||
|
|
||||||
popup.appendChild(p);
|
popup.appendChild(p);
|
||||||
popup.appendChild(uid);
|
popup.appendChild(uid);
|
||||||
@ -10119,53 +10134,73 @@ z-index:100001;
|
|||||||
popup.appendChild(records);
|
popup.appendChild(records);
|
||||||
|
|
||||||
start.addEventListener('click', () => {
|
start.addEventListener('click', () => {
|
||||||
if (id !== null) return;
|
if (loop_id !== null || !uid.value) return;
|
||||||
start.disabled = true;
|
start.disabled = true;
|
||||||
stop.disabled = false;
|
stop.disabled = false;
|
||||||
uid.readOnly = true;
|
uid.readOnly = true;
|
||||||
p.innerHTML = '状态:已开';
|
p.innerHTML = '状态:已开 ✅';
|
||||||
id = setInterval(async () => {
|
let count = 0;
|
||||||
|
loop_id = setInterval(async () => {
|
||||||
|
// 记录当前循环的id
|
||||||
|
let that_id = loop_id;
|
||||||
let res = await (await fetch(url + uid.value, {
|
let res = await (await fetch(url + uid.value, {
|
||||||
headers: { 'X-Requested-With': 'XMLHttpRequest' },
|
headers: { 'X-Requested-With': 'XMLHttpRequest' },
|
||||||
referrer: "loader.php?sid=attack&user2ID=" + uid.value
|
referrer: "loader.php?sid=attack&user2ID=" + uid.value
|
||||||
})).text();
|
})).text();
|
||||||
|
if (loop_id !== that_id) return;
|
||||||
let data = JSON.parse(res.split('<div')[0]);
|
let data = JSON.parse(res.split('<div')[0]);
|
||||||
log(count++, data);
|
log(count++, data);
|
||||||
let { DB, currentFightStatistics } = data;
|
let { DB, currentFightStatistics, histLog } = data;
|
||||||
// 攻击历史
|
|
||||||
if (DB['currentFightHistory']) {
|
|
||||||
let { currentFightHistory } = DB;
|
|
||||||
}
|
|
||||||
// 攻击人
|
// 攻击人
|
||||||
// 格式:currentFightStatistics = {uid: {...}, uid2: {...}}
|
// 格式:currentFightStatistics = {uid: {...}, uid2: {...}}
|
||||||
if (currentFightStatistics) {
|
Object.keys(currentFightStatistics || {}).forEach(id => {
|
||||||
currentFightStatistics.keys().forEach(id => {
|
|
||||||
if (id === uid.value) return;
|
if (id === uid.value) return;
|
||||||
if (!attackers.obj[id]) {
|
if (!attackers.obj[id]) {
|
||||||
attackers.obj[id] = true;
|
attackers.obj[id] = true;
|
||||||
updateAttackersDOM();
|
updateAttackersDOM();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
// 攻击历史
|
||||||
}, 200);
|
(DB['currentFightHistory'] || []).forEach(record => {
|
||||||
|
if (records.list.includes(record['ID'])) return;
|
||||||
|
let { ID, TimeCreated, attackID, attackerID, attackerItemID, result, text } = record;
|
||||||
|
records.list.push(ID);
|
||||||
|
records.details[ID] = { TimeCreated, attackID, attackerID, attackerItemID, result, text };
|
||||||
|
updateRecordsDOM();
|
||||||
|
});
|
||||||
|
// 攻击历史日志
|
||||||
|
if (histLog && histLog[uid.value]) histLog[uid.value].forEach(log => {
|
||||||
|
if (records.list.includes(log['ID'])) return;
|
||||||
|
let { ID, TimeCreated, attackID, attackResult, userID } = log;
|
||||||
|
records.list.push(ID);
|
||||||
|
records.details[ID] = {
|
||||||
|
TimeCreated,
|
||||||
|
attackID,
|
||||||
|
attackerID: userID,
|
||||||
|
attackerItemID: 0,
|
||||||
|
result: attackResult,
|
||||||
|
text: ''
|
||||||
|
};
|
||||||
|
updateRecordsDOM();
|
||||||
|
});
|
||||||
|
}, 500);
|
||||||
});
|
});
|
||||||
|
|
||||||
stop.addEventListener('click', () => {
|
stop.addEventListener('click', () => {
|
||||||
if (id === null) return;
|
if (loop_id === null) return;
|
||||||
start.disabled = false;
|
start.disabled = false;
|
||||||
stop.disabled = true;
|
stop.disabled = true;
|
||||||
uid.readOnly = false;
|
uid.readOnly = false;
|
||||||
clearInterval(id);
|
clearInterval(loop_id);
|
||||||
id = null;
|
loop_id = null;
|
||||||
count = 0;
|
p.innerHTML = '状态:已关 ❎';
|
||||||
p.innerHTML = '状态:已关';
|
|
||||||
});
|
});
|
||||||
self_target.addEventListener('click', () => uid.value = getPlayerInfo()['userID']);
|
self_target.addEventListener('click', () => uid.value = getPlayerInfo()['userID']);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 更新词库
|
// 更新词库
|
||||||
function updateTransDict() {
|
function updateTransDict() {
|
||||||
popupMsg('计划中');
|
WHNotify('计划中');
|
||||||
}
|
}
|
||||||
|
|
||||||
$zhongNode.initTimer.innerHTML = `助手加载时间 ${Date.now() - start_timestamp}ms`;
|
$zhongNode.initTimer.innerHTML = `助手加载时间 ${Date.now() - start_timestamp}ms`;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user