This commit is contained in:
李万一 2022-10-26 01:37:54 +08:00
parent 8b22f3615b
commit d7e678b6dd
4 changed files with 46 additions and 32 deletions

View File

@ -4,6 +4,14 @@
# CHANGE # CHANGE
## 0.6.5
2022年10月26日
### 修改
- 寻找木桩逻辑优化
## 0.6.4 ## 0.6.4
2022年10月25日 2022年10月25日

View File

@ -1,6 +1,6 @@
{ {
"name": "wuhu-torn-helper", "name": "wuhu-torn-helper",
"version": "0.6.4", "version": "0.6.5",
"description": "芜湖助手", "description": "芜湖助手",
"dependencies": {}, "dependencies": {},
"scripts": { "scripts": {

File diff suppressed because one or more lines are too long

View File

@ -5,6 +5,7 @@ import Log from "../Log";
import CommonUtils from "../utils/CommonUtils"; import CommonUtils from "../utils/CommonUtils";
import XUNZHAOMUZHUANG_CSS from "../../static/css/xunzhaomuzhuang.css"; import XUNZHAOMUZHUANG_CSS from "../../static/css/xunzhaomuzhuang.css";
import TornStyleBlock from "../utils/TornStyleBlock"; import TornStyleBlock from "../utils/TornStyleBlock";
import MathUtils from "../utils/MathUtils";
/** /**
* *
@ -40,20 +41,20 @@ export default class XZMZ extends WuhuBase {
this.counter = this.IDList.length; this.counter = this.IDList.length;
const tips = this.tips; const tips = this.tips;
tips.innerText = "---寻找中,长按目标名字弹出迷你档案---"; tips.innerText = "---寻找中,长按目标名字弹出迷你档案---";
window.setTimeout(async () => {
for (const id of this.IDList) { for (const id of this.IDList) {
this.SearchDeadman(id); await this.SearchDeadman(id);
} }
}, 1);
} }
private SearchDeadman(id) { private async SearchDeadman(id) {
CommonUtils.ajaxFetch({ CommonUtils.ajaxFetch({
url: window.addRFC('https://www.torn.com/profiles.php?step=getProfileData&XID=' + id), url: window.addRFC('https://www.torn.com/profiles.php?step=getProfileData&XID=' + id),
method: 'GET' method: 'GET'
}).then((res) => }).then((o) => {
res.json() this.counterHandler();
) o.json().then((res) => {
.then((res) => {
this.counter--;
if (res.userStatus.status.type === 'ok') { if (res.userStatus.status.type === 'ok') {
this.addRow({ this.addRow({
player_id: res.user.userID, player_id: res.user.userID,
@ -61,6 +62,25 @@ export default class XZMZ extends WuhuBase {
level: res.userInformation.level level: res.userInformation.level
}); });
} }
}).catch(e => {
Log.error('[XZMZ] [CommonUtils.ajaxFetch]错误: ', e.message, '错误堆栈: ', e.stack);
});
})
await CommonUtils.getInstance().sleep(MathUtils.getInstance().getRandomInt(100, 200));
}
private addRow(data) {
let $parentNode = this.mainRoleContainer.querySelector('#table-body'),
$node = '<tr data-id="' + data.player_id + '"></tr>';
$node += '<td style="border: 1px solid darkgray;padding:5px;text-align:center;">' + data.player_id + '</td>'
$node += `<td style="border: 1px solid darkgray;padding:5px;text-align:center;"><a href="/profiles.php?XID=${ data.player_id }">${ data.name }</a></td>`;
$node += '<td style="border: 1px solid darkgray;padding:5px;text-align:center;">' + data.level + '</td>'
$node += '<td style="border: 1px solid darkgray;padding:5px;text-align:center;"><a href="https://www.torn.com/loader.php?sid=attack&user2ID=' + data.player_id + '" target="_blank" class="torn-btn">攻击</a></td>'
$parentNode.insertAdjacentHTML('beforeend', $node)
}
private counterHandler(): void {
this.counter--;
if (this.counter === 0) { if (this.counter === 0) {
this.tips.innerText = "---寻找结束,等待60秒后重试---"; this.tips.innerText = "---寻找结束,等待60秒后重试---";
let countdown = 60; let countdown = 60;
@ -73,19 +93,5 @@ export default class XZMZ extends WuhuBase {
} }
}, 1000) }, 1000)
} }
})
.catch(e => {
Log.error(e)
});
}
private addRow(data) {
let $parentNode = this.mainRoleContainer.querySelector('#table-body'),
$node = '<tr data-id="' + data.player_id + '"></tr>';
$node += '<td style="border: 1px solid darkgray;padding:5px;text-align:center;">' + data.player_id + '</td>'
$node += `<td style="border: 1px solid darkgray;padding:5px;text-align:center;"><a href="/profiles.php?XID=${ data.player_id }">${ data.name }</a></td>`;
$node += '<td style="border: 1px solid darkgray;padding:5px;text-align:center;">' + data.level + '</td>'
$node += '<td style="border: 1px solid darkgray;padding:5px;text-align:center;"><a href="https://www.torn.com/loader.php?sid=attack&user2ID=' + data.player_id + '" target="_blank" class="torn-btn">攻击</a></td>'
$parentNode.insertAdjacentHTML('beforeend', $node)
} }
} }