更新
This commit is contained in:
parent
be9e202802
commit
0b6c2cda4f
12
CHANGELOG.md
12
CHANGELOG.md
@ -4,6 +4,18 @@
|
|||||||
|
|
||||||
# CHANGE
|
# CHANGE
|
||||||
|
|
||||||
|
## 0.6.6
|
||||||
|
|
||||||
|
2022年10月31日
|
||||||
|
|
||||||
|
### 修改
|
||||||
|
|
||||||
|
- 寻找木桩添加停止操作
|
||||||
|
|
||||||
|
### 添加
|
||||||
|
|
||||||
|
- 个人资料隐藏头像、显示曾用名
|
||||||
|
|
||||||
## 0.6.5
|
## 0.6.5
|
||||||
|
|
||||||
2022年10月26日
|
2022年10月26日
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "wuhu-torn-helper",
|
"name": "wuhu-torn-helper",
|
||||||
"version": "0.6.5",
|
"version": "0.6.6",
|
||||||
"description": "芜湖助手",
|
"description": "芜湖助手",
|
||||||
"dependencies": {},
|
"dependencies": {},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@ -17,6 +17,7 @@ import PTHelper from "./action/PTHelper";
|
|||||||
import StackHelper from "./action/StackHelper";
|
import StackHelper from "./action/StackHelper";
|
||||||
import BuyBeerHelper from "./action/BuyBeerHelper";
|
import BuyBeerHelper from "./action/BuyBeerHelper";
|
||||||
import XZMZ from "./action/XZMZ";
|
import XZMZ from "./action/XZMZ";
|
||||||
|
import ProfileHelper from "./action/ProfileHelper";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO 去除jq
|
* TODO 去除jq
|
||||||
@ -178,6 +179,9 @@ export default class UrlPattern extends WuhuBase {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 个人资料
|
||||||
|
if (href.includes('profiles.php?XID=')) ProfileHelper.getInstance();
|
||||||
|
|
||||||
// 圣诞小镇
|
// 圣诞小镇
|
||||||
if (href.contains(/christmas_town\.php/) && new Date().getMonth() > 9) christmasTownHelper();
|
if (href.contains(/christmas_town\.php/) && new Date().getMonth() > 9) christmasTownHelper();
|
||||||
|
|
||||||
|
|||||||
@ -102,6 +102,10 @@ export default class WuhuConfig extends WuhuBase {
|
|||||||
{ key: 'CHTrainsDetect', val: 0 },
|
{ key: 'CHTrainsDetect', val: 0 },
|
||||||
// 火车提醒开关
|
// 火车提醒开关
|
||||||
{ key: 'CHTrainsDetectSwitch', val: true },
|
{ key: 'CHTrainsDetectSwitch', val: true },
|
||||||
|
// 隐藏个人资料头像
|
||||||
|
{ key: 'HideProfileImg', val: false },
|
||||||
|
// 显示曾用名
|
||||||
|
{ key: 'ShowNameHistory', val: true },
|
||||||
|
|
||||||
// 危险行为⚠️
|
// 危险行为⚠️
|
||||||
{ key: 'dangerZone', val: false },
|
{ key: 'dangerZone', val: false },
|
||||||
|
|||||||
51
src/class/action/ProfileHelper.ts
Normal file
51
src/class/action/ProfileHelper.ts
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
import WuhuBase from "../WuhuBase";
|
||||||
|
import Log from "../Log";
|
||||||
|
import WuhuConfig from "../WuhuConfig";
|
||||||
|
import CommonUtils from "../utils/CommonUtils";
|
||||||
|
import TornStyleBlock from "../utils/TornStyleBlock";
|
||||||
|
import TornStyleSwitch from "../utils/TornStyleSwitch";
|
||||||
|
|
||||||
|
export default class ProfileHelper extends WuhuBase {
|
||||||
|
className = 'ProfileHelper';
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
CommonUtils.addStyle('body.wh-hide_profile_img .profile-image a.profile-image-wrapper .img-wrap img{display:none;}');
|
||||||
|
let id = document.querySelector('link[rel="canonical"]').getAttribute('href').split('=')[1];
|
||||||
|
// id获取格式判断
|
||||||
|
if (!/^[0-9]{1,7}$/.test(id)) {
|
||||||
|
Log.error('[ProfileHelper] id格式错误');
|
||||||
|
}
|
||||||
|
if (WuhuConfig.get('HideProfileImg')) {
|
||||||
|
Log.info('[ProfileHelper] 隐藏头像');
|
||||||
|
document.body.classList.toggle('wh-hide_profile_img');
|
||||||
|
}
|
||||||
|
let block = new TornStyleBlock('芜湖助手').insert2Dom();
|
||||||
|
// 隐藏头像
|
||||||
|
let hideImgSwitch = new TornStyleSwitch('隐藏头像', WuhuConfig.get('HideProfileImg'));
|
||||||
|
block.append(hideImgSwitch.getBase());
|
||||||
|
hideImgSwitch.getInput().addEventListener('change', () => {
|
||||||
|
document.body.classList.toggle('wh-hide_profile_img');
|
||||||
|
WuhuConfig.set('HideProfileImg', hideImgSwitch.getInput().checked, true);
|
||||||
|
});
|
||||||
|
// 曾用名
|
||||||
|
let nameHistoryNode;
|
||||||
|
if (WuhuConfig.get('ShowNameHistory')) {
|
||||||
|
nameHistoryNode = document.createElement('p');
|
||||||
|
nameHistoryNode.innerHTML = '曾用名:';
|
||||||
|
block.append(nameHistoryNode);
|
||||||
|
CommonUtils.ajaxFetch({
|
||||||
|
url: window.addRFC('https://www.torn.com/profiles.php?step=getProfileData&XID=' + id),
|
||||||
|
method: 'GET'
|
||||||
|
}).then((o) => {
|
||||||
|
o.json().then((res) => {
|
||||||
|
if (res.userInformation.previousAliases.length > 0) {
|
||||||
|
res.userInformation.previousAliases.forEach(item => nameHistoryNode.innerHTML += item + ' ');
|
||||||
|
} else {
|
||||||
|
nameHistoryNode.innerHTML += '暂无';
|
||||||
|
}
|
||||||
|
}).catch(e => Log.error('[ProfileHelper] 错误: ', e.message, '错误堆栈: ', e.stack));
|
||||||
|
}).catch(e => Log.error('[ProfileHelper] 错误: ', e.message, '错误堆栈: ', e.stack));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -16,25 +16,31 @@ export default class XZMZ extends WuhuBase {
|
|||||||
private readonly mainRoleContainer: HTMLElement;
|
private readonly mainRoleContainer: HTMLElement;
|
||||||
private readonly IDList: number[];
|
private readonly IDList: number[];
|
||||||
private readonly btn: HTMLButtonElement;
|
private readonly btn: HTMLButtonElement;
|
||||||
|
private readonly stopBtn: HTMLButtonElement;
|
||||||
|
private stopSignal: boolean = false;
|
||||||
private readonly tips: HTMLElement;
|
private readonly tips: HTMLElement;
|
||||||
private counter: number;
|
private counter: number;
|
||||||
|
|
||||||
public constructor() {
|
public constructor() {
|
||||||
super();
|
super();
|
||||||
CommonUtils.addStyle(XUNZHAOMUZHUANG_CSS);
|
CommonUtils.addStyle(XUNZHAOMUZHUANG_CSS);
|
||||||
|
document.title = document.title.replace('Items', '寻找木桩');
|
||||||
this.mainRoleContainer = document.querySelector('div[role="main"]');
|
this.mainRoleContainer = document.querySelector('div[role="main"]');
|
||||||
let block = new TornStyleBlock('寻找木桩');
|
let block = new TornStyleBlock('寻找木桩');
|
||||||
block.setContent(XUNZHAOMUZHUANG_HTML);
|
block.setContent(XUNZHAOMUZHUANG_HTML);
|
||||||
this.mainRoleContainer.append(block.getBase());
|
this.mainRoleContainer.append(block.getBase());
|
||||||
this.IDList = MUZHUANG_ID_LIST_JSON.default;
|
this.IDList = MUZHUANG_ID_LIST_JSON.default;
|
||||||
this.btn = block.querySelector('#deadman-start-btn') as HTMLButtonElement;
|
this.btn = block.querySelector('#deadman-start-btn') as HTMLButtonElement;
|
||||||
|
this.stopBtn = this.btn.nextElementSibling as HTMLButtonElement;
|
||||||
this.tips = block.querySelector('#deadman_tips');
|
this.tips = block.querySelector('#deadman_tips');
|
||||||
|
|
||||||
block.querySelector('#deadman-start-btn').addEventListener('click', () => {
|
this.btn.addEventListener('click', () => {
|
||||||
this.mainRoleContainer.querySelector('#table-body').innerHTML = '';
|
this.mainRoleContainer.querySelector('#table-body').innerHTML = '';
|
||||||
this.btn.disabled = true;
|
this.btn.disabled = true;
|
||||||
|
this.stopSignal = false;
|
||||||
this.StartSearch();
|
this.StartSearch();
|
||||||
});
|
});
|
||||||
|
this.stopBtn.addEventListener('click', () => this.stopSignal = true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private StartSearch() {
|
private StartSearch() {
|
||||||
@ -43,6 +49,12 @@ export default class XZMZ extends WuhuBase {
|
|||||||
tips.innerText = "---寻找中,长按目标名字弹出迷你档案---";
|
tips.innerText = "---寻找中,长按目标名字弹出迷你档案---";
|
||||||
window.setTimeout(async () => {
|
window.setTimeout(async () => {
|
||||||
for (const id of this.IDList) {
|
for (const id of this.IDList) {
|
||||||
|
if (this.stopSignal) {
|
||||||
|
this.stopSignal = false;
|
||||||
|
this.counter = 1;
|
||||||
|
this.counterHandler(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
await this.SearchDeadman(id);
|
await this.SearchDeadman(id);
|
||||||
}
|
}
|
||||||
}, 1);
|
}, 1);
|
||||||
@ -79,11 +91,11 @@ export default class XZMZ extends WuhuBase {
|
|||||||
$parentNode.insertAdjacentHTML('beforeend', $node)
|
$parentNode.insertAdjacentHTML('beforeend', $node)
|
||||||
}
|
}
|
||||||
|
|
||||||
private counterHandler(): void {
|
private counterHandler(hasCoolDown: boolean = true): void {
|
||||||
this.counter--;
|
this.counter--;
|
||||||
if (this.counter === 0) {
|
if (this.counter === 0) {
|
||||||
this.tips.innerText = "---寻找结束,等待60秒后重试---";
|
this.tips.innerText = "---寻找结束,等待60秒后重试---";
|
||||||
let countdown = 60;
|
let countdown = hasCoolDown ? 60 : 2;
|
||||||
let timer = window.setInterval(() => {
|
let timer = window.setInterval(() => {
|
||||||
this.btn.innerHTML = (countdown--).toString();
|
this.btn.innerHTML = (countdown--).toString();
|
||||||
if (countdown === 0) {
|
if (countdown === 0) {
|
||||||
@ -91,7 +103,7 @@ export default class XZMZ extends WuhuBase {
|
|||||||
this.btn.disabled = false;
|
this.btn.disabled = false;
|
||||||
this.btn.innerHTML = '重新寻找';
|
this.btn.innerHTML = '重新寻找';
|
||||||
}
|
}
|
||||||
}, 1000)
|
}, 1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -353,6 +353,26 @@ export default class SettingsHandler extends WuhuBase {
|
|||||||
clickFunc: () => BuyBeerHelper.getInstance().setTimeHandler()
|
clickFunc: () => BuyBeerHelper.getInstance().setTimeHandler()
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 个人资料
|
||||||
|
list.push({
|
||||||
|
domType: 'plain',
|
||||||
|
domId: '',
|
||||||
|
domHTML: '个人资料',
|
||||||
|
tagName: 'h4',
|
||||||
|
});
|
||||||
|
list.push({
|
||||||
|
domType: 'checkbox',
|
||||||
|
domText: '隐藏个人资料头像',
|
||||||
|
dictName: 'HideProfileImg',
|
||||||
|
domId: ''
|
||||||
|
});
|
||||||
|
list.push({
|
||||||
|
domType: 'checkbox',
|
||||||
|
domText: '显示曾用名',
|
||||||
|
dictName: 'ShowNameHistory',
|
||||||
|
domId: ''
|
||||||
|
});
|
||||||
|
|
||||||
// 其他
|
// 其他
|
||||||
list.push({
|
list.push({
|
||||||
domType: 'plain',
|
domType: 'plain',
|
||||||
|
|||||||
@ -3,6 +3,7 @@ import MathUtils from "./MathUtils";
|
|||||||
export default class TornStyleSwitch {
|
export default class TornStyleSwitch {
|
||||||
private readonly baseElement;
|
private readonly baseElement;
|
||||||
private readonly randomId;
|
private readonly randomId;
|
||||||
|
private readonly input;
|
||||||
|
|
||||||
constructor(label: string, checked: boolean = false) {
|
constructor(label: string, checked: boolean = false) {
|
||||||
this.randomId = MathUtils.getInstance().getRandomInt(100, 2000);
|
this.randomId = MathUtils.getInstance().getRandomInt(100, 2000);
|
||||||
@ -10,14 +11,15 @@ export default class TornStyleSwitch {
|
|||||||
this.baseElement.id = 'WHSwitch' + this.randomId;
|
this.baseElement.id = 'WHSwitch' + this.randomId;
|
||||||
this.baseElement.innerHTML = `<input class="checkbox-css" type="checkbox" id="WHCheck${ this.randomId }" ${ checked ? 'checked' : '' }/>
|
this.baseElement.innerHTML = `<input class="checkbox-css" type="checkbox" id="WHCheck${ this.randomId }" ${ checked ? 'checked' : '' }/>
|
||||||
<label for="WHCheck${ this.randomId }" class="non-selection marker-css">${ label }</label>`;
|
<label for="WHCheck${ this.randomId }" class="non-selection marker-css">${ label }</label>`;
|
||||||
|
this.input = this.baseElement.querySelector('input') as HTMLInputElement;
|
||||||
}
|
}
|
||||||
|
|
||||||
public getBase() {
|
public getBase(): HTMLElement {
|
||||||
return this.baseElement
|
return this.baseElement
|
||||||
};
|
};
|
||||||
|
|
||||||
public getInput(): HTMLInputElement {
|
public getInput(): HTMLInputElement {
|
||||||
return this.baseElement.querySelector('input');
|
return this.input;
|
||||||
}
|
}
|
||||||
|
|
||||||
public getHtml(): string {
|
public getHtml(): string {
|
||||||
|
|||||||
@ -8,12 +8,28 @@ import MathUtils from "../../class/utils/MathUtils";
|
|||||||
import ActionButtonUtils from "../../class/utils/ActionButtonUtils";
|
import ActionButtonUtils from "../../class/utils/ActionButtonUtils";
|
||||||
import ATTACK_HELPER_CSS from "../../static/css/attack_helper.css";
|
import ATTACK_HELPER_CSS from "../../static/css/attack_helper.css";
|
||||||
|
|
||||||
|
enum FIGHT_STAGE {
|
||||||
|
READY,
|
||||||
|
IN_PROGRESS_OR_ERROR,
|
||||||
|
FINISHED
|
||||||
|
}
|
||||||
|
|
||||||
|
enum DIALOG_BUTTON {
|
||||||
|
START = 'start',
|
||||||
|
JOIN = 'join',
|
||||||
|
LEAVE = 'leave',
|
||||||
|
MUG = 'mug',
|
||||||
|
// TODO
|
||||||
|
HOST = 'hospitalize',
|
||||||
|
OTHER = 'other'
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO class重构、各功能联动
|
* TODO class重构、各功能联动
|
||||||
*/
|
*/
|
||||||
export default async function attackHelper(): Promise<null> {
|
export default async function attackHelper(): Promise<null> {
|
||||||
let { href, device } = WuhuBase.glob;
|
let { href, device } = WuhuBase.glob;
|
||||||
// 攻击页面
|
// 攻击页面URL判断
|
||||||
if (href.contains(/loader\.php\?sid=attack/)) {
|
if (href.contains(/loader\.php\?sid=attack/)) {
|
||||||
let stop_reload = false;
|
let stop_reload = false;
|
||||||
const quickAttIndex = WuhuConfig.get('quickAttIndex');
|
const quickAttIndex = WuhuConfig.get('quickAttIndex');
|
||||||
@ -64,20 +80,21 @@ export default async function attackHelper(): Promise<null> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// await CommonUtils.querySelector('#react-root div[class^="players___"]'); // pc 可用
|
||||||
|
let playersModelWrap = await CommonUtils.querySelector('#react-root div[class^="playersModelWrap___"]');
|
||||||
|
let fightStage = document.querySelectorAll('div[class^="dialogButtons___"] button').length > 1;
|
||||||
|
Log.info('响应式内容已加载');
|
||||||
// 光速拔刀
|
// 光速拔刀
|
||||||
if (quickAttIndex !== 6) {
|
if (quickAttIndex !== 6) {
|
||||||
// await CommonUtils.querySelector('#react-root div[class^="players___"]'); // pc 可用
|
|
||||||
await CommonUtils.querySelector('#react-root div[class^="playersModelWrap___"]');
|
|
||||||
Log.info('响应式内容已加载, 查找攻击按钮');
|
|
||||||
// const btn = await CommonUtils.elementReady('div[class^="modal___"] button');
|
|
||||||
/**
|
/**
|
||||||
* pc #defender
|
* pc #defender
|
||||||
* mobile #attacker
|
* mobile #attacker
|
||||||
*/
|
*/
|
||||||
const btn = <HTMLInputElement>(document.querySelector('#attacker button') || document.querySelector('#defender button'));
|
const btn = <HTMLInputElement>(document.querySelector('#attacker button') || document.querySelector('#defender button'));
|
||||||
Log.info('操作按钮按钮', { btn });
|
Log.info('操作按钮', { btn });
|
||||||
if (!btn.innerText.toLowerCase().includes('fight')) {
|
if (!btn.innerText.toLowerCase().includes('fight')) {
|
||||||
Log.info('未找到攻击按钮, 退出');
|
Log.info('未找到攻击按钮, 光速拔刀跳过');
|
||||||
|
new Alert('未找到攻击按钮, 光速拔刀跳过');
|
||||||
} else {
|
} else {
|
||||||
// 判断是否存在脚踢
|
// 判断是否存在脚踢
|
||||||
const hasKick = !!document.querySelector('#weapon_boots');
|
const hasKick = !!document.querySelector('#weapon_boots');
|
||||||
@ -236,27 +253,26 @@ export default async function attackHelper(): Promise<null> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 光速跑路 TODO 暂时关闭
|
// 光速跑路 TODO 暂时关闭
|
||||||
// if (quickFinishAtt !== 3) {
|
if (quickFinishAtt !== 3) {
|
||||||
// const user_btn_select = ['leave', 'mug', 'hosp'][WuhuConfig.get('quickFinishAtt')];
|
const user_btn_select = ['leave', 'mug', 'hosp'][WuhuConfig.get('quickFinishAtt')];
|
||||||
// const wrap = document.querySelector('#react-root');
|
const wrap = document.querySelector('#react-root');
|
||||||
// Log.info('光速跑路选项选中:', user_btn_select);
|
Log.info('光速跑路选项选中:', user_btn_select);
|
||||||
// new MutationObserver(() => {
|
new MutationObserver((mut, obs) => {
|
||||||
// const btn_arr = document.querySelectorAll('div[class^="dialogButtons___"] button') as unknown as HTMLButtonElement[];
|
const btn_arr: HTMLButtonElement[] = document.querySelectorAll('div[class^="dialogButtons___"] button') as unknown as HTMLButtonElement[];
|
||||||
// if (btn_arr.length > 1) btn_arr.forEach(btn => {
|
if (btn_arr.length > 1) btn_arr.forEach(btn => {
|
||||||
// btn = btn as HTMLButtonElement;
|
const flag = btn.innerText.toLowerCase().includes(user_btn_select);
|
||||||
// const flag = btn.innerText.toLowerCase().includes(user_btn_select);
|
Log.info('按钮内容:', btn.innerText, ',是否包含选中:', flag);
|
||||||
// Log.info('按钮内容:', btn.innerText, ',是否包含选中:', flag);
|
if (!flag) btn.style.display = 'none';
|
||||||
// if (!flag) btn.style.display = 'none';
|
// 自动结束
|
||||||
// // 自动结束
|
else if (WuhuConfig.get('autoStartFinish')) {
|
||||||
// else if (WuhuConfig.get('autoStartFinish') === true) {
|
try {
|
||||||
// try {
|
btn.click();
|
||||||
// btn.click();
|
} catch {
|
||||||
// } catch {
|
}
|
||||||
// }
|
}
|
||||||
// }
|
});
|
||||||
// });
|
}).observe(wrap, { subtree: true, attributes: true, childList: true });
|
||||||
// }).observe(wrap, { subtree: true, attributes: true, childList: true });
|
}
|
||||||
// }
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
<div id="deadman_div" style="width: inherit">
|
<div id="deadman_div" style="width: inherit">
|
||||||
<div id="deadman_header" style="margin:10px 0px; border:1px solid darkgray; text-align:center;">
|
<div id="deadman_header" style="margin:10px 0px; border:1px solid darkgray; text-align:center;">
|
||||||
<button class="torn-btn" id="deadman-start-btn" style="margin:5px;">开始寻找木桩</button>
|
<button class="torn-btn" id="deadman-start-btn" style="margin:5px;">开始寻找木桩</button>
|
||||||
|
<button class="torn-btn" style="margin:5px;">停止</button>
|
||||||
</div>
|
</div>
|
||||||
<div id="deadman_tips" style="text-align:center; margin-bottom: 3px; font-size: 16px;">未开始</div>
|
<div id="deadman_tips" style="text-align:center; margin-bottom: 3px; font-size: 16px;">未开始</div>
|
||||||
<div id="deadman_wrapper"
|
<div id="deadman_wrapper"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user