From bb770d8e2e12c8385fa7307b5348823cc40f404f Mon Sep 17 00:00:00 2001 From: Liwanyi Date: Mon, 17 Oct 2022 15:19:18 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- global.d.ts | 7 +++-- src/class/Application.ts | 11 ++++---- src/class/Common.ts | 1 + src/class/Global.ts | 16 +++++------ src/class/Log.ts | 2 +- src/class/UrlMatch.ts | 33 +++++++++++----------- src/class/WuhuBase.ts | 15 +++------- src/class/WuhuConfig.ts | 1 + src/class/WuhuTornHelper.ts | 17 +++++------ src/class/ZhongIcon.ts | 19 ++++++------- src/class/action/BuyBeerHelper.ts | 1 + src/class/action/LotteryHelper.ts | 1 + src/class/action/PTHelper.ts | 1 + src/class/action/StackHelper.ts | 1 + src/class/action/TravelItem.ts | 1 + src/class/action/WindowActiveState.ts | 1 + src/class/action/XZMZ.ts | 12 ++++++-- src/class/provider/Provider.ts | 7 ++++- src/class/provider/Starter.ts | 16 +++++++++-- src/class/utils/ActionButtonUtils.ts | 1 + src/class/utils/Alert.ts | 1 + src/class/utils/CommonUtils.ts | 4 ++- src/class/utils/FetchUtils.ts | 1 + src/class/utils/InfoUtils.ts | 1 + src/class/utils/MDUtils.ts | 1 + src/class/utils/MathUtils.ts | 1 + src/class/utils/NotificationUtils.ts | 1 + src/class/utils/Popup.ts | 2 +- src/func/module/travelHelper.ts | 3 +- src/interface/MyHTMLElement.ts | 1 + src/static/html/xunzhaomuzhuang/index.html | 6 ++-- src/test/Test.ts | 17 +++++------ 32 files changed, 116 insertions(+), 87 deletions(-) diff --git a/global.d.ts b/global.d.ts index b598e1f..0936a07 100644 --- a/global.d.ts +++ b/global.d.ts @@ -17,10 +17,13 @@ declare interface Window { ReactDOM?: any; hasWHQuickFlyOpt?: boolean; // 插件运行标识 - WHTRANS?: boolean; + WHTRANS?: number; Vue?: Function; /* 油猴脚本引擎自带 */ unsafeWindow?: Window & typeof globalThis; + // google不跟踪标识 + _gaUserPrefs?: unknown; + dataLayer?: unknown; eval(exc: string): void; @@ -47,7 +50,7 @@ declare interface Window { GM_setValue(k: string, v: any): void; // TODO 临时测试用 - [key: string]: unknown; + // [key: string]: unknown; } declare interface GM_RequestParams { diff --git a/src/class/Application.ts b/src/class/Application.ts index c6a9572..48f197c 100644 --- a/src/class/Application.ts +++ b/src/class/Application.ts @@ -10,22 +10,21 @@ import Global from "./Global"; export default class Application { public static main() { - let started = performance.now(); - - WuhuBase.PDAExecute(); WuhuBase.conditionInterrupt(); + // 初始化 WuHuTornHelper.getInstance(); + // 插件图标和设置菜单 ZhongIcon.getInstance(); + // 所有页面通用 Common.getInstance().resolve(); + // URL匹配 UrlPattern.getInstance().resolve(); + // 翻译 if (WuhuConfig.get('transEnable')) translateMain(Global.getInstance().href); - - let runTime: number = (performance.now() - started) | 0; - ZhongIcon.ZhongNode.initTimer.innerHTML = `助手加载时间 ${ runTime }ms`; } } \ No newline at end of file diff --git a/src/class/Common.ts b/src/class/Common.ts index 128ce2f..ee2cf06 100644 --- a/src/class/Common.ts +++ b/src/class/Common.ts @@ -7,6 +7,7 @@ import WuhuConfig from "./WuhuConfig"; import CommonUtils from "./utils/CommonUtils"; export class Common extends WuhuBase { + className = 'Common'; resolve() { let glob = Common.glob; // 价格监控 diff --git a/src/class/Global.ts b/src/class/Global.ts index ce7b5c4..9814c10 100644 --- a/src/class/Global.ts +++ b/src/class/Global.ts @@ -9,6 +9,7 @@ import BuyBeerHelper from "./action/BuyBeerHelper"; * 存储脚本用到的参数,单例存在 */ export default class Global extends WuhuBase implements IGlobal { + className = 'Global'; GM_xmlhttpRequest: Function = null; href: string = window.location.href; @@ -39,13 +40,12 @@ export default class Global extends WuhuBase implements IGlobal { 'data-celebration'?: string; 'data-traveling'?: string; 'data-abroad'?: string; - // [key: string]: string; } = null; constructor() { Log.info('WH脚本参数初始化'); super(); - this.window = window; + // this.window = window; this.unsafeWindow = window.unsafeWindow || null; this.GM_xmlhttpRequest = window.GM_xmlhttpRequest || null; this.version = '$$WUHU_DEV_VERSION$$'; @@ -60,13 +60,11 @@ export default class Global extends WuhuBase implements IGlobal { this.bodyAttrs = {}; if (this.unsafeWindow) { - try { - window = this.unsafeWindow || this.window; - Log.info('替换window上下文'); - } catch { - this.unsafeWindow = null; - this.GM_xmlhttpRequest = null; - } + Log.info('存在unsafeWindow, 引入部分torn公共方法'); + window.addRFC = this.unsafeWindow.addRFC; + window.getAction = this.unsafeWindow.getAction; + window.initializeTooltip = this.unsafeWindow.initializeTooltip; + window.renderMiniProfile = this.unsafeWindow.renderMiniProfile; } for (let i = 0; i < document.body.attributes.length; i++) { diff --git a/src/class/Log.ts b/src/class/Log.ts index f07e7ae..5cae666 100644 --- a/src/class/Log.ts +++ b/src/class/Log.ts @@ -13,7 +13,7 @@ export default class Log { static error(...o): void { let time = this.getTime(); let flag = '[WH] ERR'; - (this.debug()) && (console.error(flag, time, ...o)); + console.error(flag, time, ...o); this.saveLogs(flag, time, ...o); } diff --git a/src/class/UrlMatch.ts b/src/class/UrlMatch.ts index 93a29e2..141f68a 100644 --- a/src/class/UrlMatch.ts +++ b/src/class/UrlMatch.ts @@ -1,13 +1,11 @@ import cityFinder from "../func/module/cityFinder"; import { missionDict } from "../dictionary/translation"; import getTaskHint from "../func/translate/getTaskHint"; -import Device from "../enum/Device"; import WuhuBase from "./WuhuBase"; import CommonUtils from "./utils/CommonUtils"; import Log from "./Log"; import WuhuConfig from "./WuhuConfig"; import Alert from "./utils/Alert"; -import InfoUtils from "./utils/InfoUtils"; import SHOP_BEER_STATIC_ITEM_HTML from "../static/html/buyBeer/shop_beer_static_item.html"; import ADD_BEER_HEAD_HTML from "../static/html/buyBeer/add_beer_head.html"; import QUICK_CRIMES_HTML from "../static/html/quick_crimes.html"; @@ -21,6 +19,7 @@ import BuyBeerHelper from "./action/BuyBeerHelper"; import XZMZ from "./action/XZMZ"; export default class UrlPattern extends WuhuBase { + className = 'UrlPattern'; public resolve(): void { let href = window.location.href; // 捡垃圾助手 @@ -226,21 +225,21 @@ export default class UrlPattern extends WuhuBase { } // 特定 - if (InfoUtils.getInstance().getPlayerInfo().userID === 2687093 && CommonUtils.getDeviceType() === Device.PC) { - InfoUtils.getInstance().getSidebarData().then(data => { - let item = document.getElementById('nav-items'); - if (item) { - let copy = item.cloneNode(true); - (copy.firstChild).style.backgroundColor = '#678c00'; - let a = copy.firstChild.firstChild as HTMLAnchorElement; - a.href = '/item.php?temp=1'; - let span = a.lastChild as HTMLElement; - span.innerHTML = '物品'; - span.style.color = 'white'; - item.after(copy); - } - }); - } + // if (InfoUtils.getInstance().getPlayerInfo().userID === 2687093 && CommonUtils.getDeviceType() === Device.PC) { + // InfoUtils.getInstance().getSidebarData().then(data => { + // let item = document.getElementById('nav-items'); + // if (item) { + // let copy = item.cloneNode(true); + // (copy.firstChild).style.backgroundColor = '#678c00'; + // let a = copy.firstChild.firstChild as HTMLAnchorElement; + // a.href = '/item.php?temp=1'; + // let span = a.lastChild as HTMLElement; + // span.innerHTML = '物品'; + // span.style.color = 'white'; + // item.after(copy); + // } + // }); + // } // 彩票助手 if (href.includes('loader.php?sid=lottery')) LotteryHelper.getInstance().init(); diff --git a/src/class/WuhuBase.ts b/src/class/WuhuBase.ts index 05e2a58..ca6f4df 100644 --- a/src/class/WuhuBase.ts +++ b/src/class/WuhuBase.ts @@ -1,17 +1,10 @@ import IGlobal from "../interface/IGlobal"; import IWHSettings from "../interface/IWHSettings"; -import Log from "./Log"; import Provider from "./provider/Provider"; export default class WuhuBase extends Provider { static glob: IGlobal = null; - protected static className = 'WuhuBase'; - - constructor() { - super(); - // Log.info({ 'constructor': this.constructor, this: this, test: this.getClassName() }); - Log.info('创建对象:', this); - } + className = 'WuhuBase'; static getLocal(): IWHSettings { return JSON.parse(localStorage.getItem('wh_trans_settings')) || {}; @@ -28,8 +21,8 @@ export default class WuhuBase extends Provider { if (condition) throw '芜湖'; } - static PDAExecute() { - if (window.WHTRANS) throw '已运行,退出'; - window.WHTRANS = true; + public getClassName() { + return this.className; } + } \ No newline at end of file diff --git a/src/class/WuhuConfig.ts b/src/class/WuhuConfig.ts index cae881c..3547f23 100644 --- a/src/class/WuhuConfig.ts +++ b/src/class/WuhuConfig.ts @@ -3,6 +3,7 @@ import Alert from "./utils/Alert"; import Log from "./Log"; export default class WuhuConfig extends WuhuBase { + className = 'WuhuConfig'; static get(key: string | string[]) { let localPool = this.getLocal(); if (typeof key === 'string') return localPool[key]; diff --git a/src/class/WuhuTornHelper.ts b/src/class/WuhuTornHelper.ts index 850f04d..ccb3ccc 100644 --- a/src/class/WuhuTornHelper.ts +++ b/src/class/WuhuTornHelper.ts @@ -8,6 +8,7 @@ import WuhuConfig from "./WuhuConfig"; import COMMON_CSS from "../static/css/common.css"; export default class WuHuTornHelper extends WuhuBase { + className = 'WuHuTornHelper'; constructor() { super(); @@ -23,7 +24,7 @@ export default class WuHuTornHelper extends WuhuBase { window.Notification.requestPermission().then(); } } else { - Log.error('当前浏览器不支持系统通知'); + Log.error('该浏览器不支持系统通知'); } // 扩展正则方法 @@ -38,9 +39,9 @@ export default class WuHuTornHelper extends WuhuBase { // 监听fetch const ori_fetch = window.fetch; - window.fetch = async (url: string, init: RequestInit) => { + window.fetch = (url: string, init: RequestInit) => { let startTime = performance.now(); - Log.info('FETCH调用:[' + url + ']'); + Log.info('FETCH调用:[' + url + '], init:', init); return new Promise(resolve => { if (url.contains('newsTickers')) { Log.info('阻止获取新闻横幅'); @@ -55,16 +56,12 @@ export default class WuHuTornHelper extends WuhuBase { ori_fetch(url, init).then(res => { // mini profile 翻译 if (url.includes('profiles.php?step=getUserNameContextMenu') && WuhuConfig.get('transEnable')) { - setTimeout(() => miniprofTrans(), 200); + window.setTimeout(() => miniprofTrans(), 200); } let clone = res.clone(); - res.text().then(text => Log.info('FETCH响应,耗时' + ((performance.now() - startTime) | 0) + 'ms', { - url, - init, - text - })); + res.text().then(text => Log.info('FETCH响应,耗时' + ((performance.now() - startTime) | 0) + 'ms', { response: text })); resolve(clone); - }) + }); }) }; diff --git a/src/class/ZhongIcon.ts b/src/class/ZhongIcon.ts index 21bb919..a2aa707 100644 --- a/src/class/ZhongIcon.ts +++ b/src/class/ZhongIcon.ts @@ -31,6 +31,7 @@ import Global from "./Global"; import BuyBeerHelper from "./action/BuyBeerHelper"; export default class ZhongIcon extends WuhuBase { + className = 'ZhongIcon'; public static ZhongNode: MyHTMLElement = null; private menuItemList: MenuItemConfig[] = null; private settingItemList: MenuItemConfig[] = null; @@ -46,7 +47,7 @@ export default class ZhongIcon extends WuhuBase { Log.info('设置图标结束, ZhongIcon初始化结束'); } - private elemGenerator(setting: MenuItemConfig, root_node: Node) { + private elemGenerator(setting: MenuItemConfig, root_node: Element): HTMLElement { let { tip, domType } = setting; let new_node = null; switch (domType) { @@ -120,7 +121,7 @@ export default class ZhongIcon extends WuhuBase { let zhong_node: MyHTMLElement = document.querySelector('div#wh-trans-icon'); let settings = this.menuItemList; let { version } = WuhuBase.glob; - if ((self !== top) || !!zhong_node) return zhong_node; + if ((self !== top) || !!zhong_node) return null; zhong_node = document.createElement('div'); zhong_node.id = 'wh-trans-icon'; zhong_node.classList.add('cont-gray'); @@ -135,7 +136,6 @@ export default class ZhongIcon extends WuhuBase { (zhong_node.querySelector('#wh-trans-icon-btn')).onclick = () => { zhong_node.classList.toggle('wh-icon-expanded'); const click_func = e => { - // e.stopImmediatePropagation(); Log.info(e.target); if (e.target === zhong_node.querySelector('#wh-trans-icon-btn')) return; if (!zhong_node.contains(e.target)) { @@ -203,7 +203,6 @@ export default class ZhongIcon extends WuhuBase { // 加载torn mini profile initMiniProf('#wh-trans-icon'); ZhongIcon.ZhongNode = zhong_node; - // return zhong_node; } // 菜单 @@ -1198,15 +1197,15 @@ export default class ZhongIcon extends WuhuBase { domType: 'button', domId: 'wh-otherBtn', domText: '更多设定', clickFunc: () => { let pop = new Popup('', '更多设定'); - let insertHtml = '

'; + let insertHtml = '

'; pop.getElement().insertAdjacentHTML('beforeend', insertHtml); let [btn1, btn2, btn3] = Array.from(pop.getElement().querySelectorAll('button')); btn1.addEventListener('click', () => { - localStorage.setItem('wh_trv_alarm', ''); - localStorage.setItem('wh_trans_settings', ''); - localStorage.setItem('whuuid', ''); - localStorage.setItem('wh-gs-storage', ''); - localStorage.setItem('WHTEST', ''); + localStorage.removeItem('wh_trv_alarm'); + localStorage.removeItem('wh_trans_settings'); + localStorage.removeItem('whuuid'); + localStorage.removeItem('wh-gs-storage'); + localStorage.removeItem('WHTEST'); new Alert('已清空,刷新页面'); window.location.reload(); }); diff --git a/src/class/action/BuyBeerHelper.ts b/src/class/action/BuyBeerHelper.ts index 8bb568a..11609b2 100644 --- a/src/class/action/BuyBeerHelper.ts +++ b/src/class/action/BuyBeerHelper.ts @@ -8,6 +8,7 @@ import NOTIFY_HTML from "../../static/html/buyBeer/notify.html"; import CommonUtils from "../utils/CommonUtils"; export default class BuyBeerHelper extends WuhuBase implements BeerMonitorLoop { + className = 'BuyBeerHelper'; private isNotifying = false; private loopId: number = null; diff --git a/src/class/action/LotteryHelper.ts b/src/class/action/LotteryHelper.ts index b2c7fb5..c5d6a37 100644 --- a/src/class/action/LotteryHelper.ts +++ b/src/class/action/LotteryHelper.ts @@ -6,6 +6,7 @@ import CommonUtils from "../utils/CommonUtils"; import TornStyleBlock from "../utils/TornStyleBlock"; export default class LotteryHelper extends WuhuBase { + className = 'LotteryHelper'; private loopFlag = true; private radioDaily: HTMLInputElement = null; diff --git a/src/class/action/PTHelper.ts b/src/class/action/PTHelper.ts index 3aff9cc..89cce99 100644 --- a/src/class/action/PTHelper.ts +++ b/src/class/action/PTHelper.ts @@ -5,6 +5,7 @@ import Alert from "../utils/Alert"; import TornStyleSwitch from "../utils/TornStyleSwitch"; export default class PTHelper extends WuhuBase { + className = 'PTHelper'; private readonly observer; private readonly usersPointSell; diff --git a/src/class/action/StackHelper.ts b/src/class/action/StackHelper.ts index 79c43b9..dd5b421 100644 --- a/src/class/action/StackHelper.ts +++ b/src/class/action/StackHelper.ts @@ -4,6 +4,7 @@ import WuhuConfig from "../WuhuConfig"; import TornStyleSwitch from "../utils/TornStyleSwitch"; export default class StackHelper extends WuhuBase { + className = 'StackHelper'; constructor() { super(); let block = new TornStyleBlock('叠E保护').insert2Dom(); diff --git a/src/class/action/TravelItem.ts b/src/class/action/TravelItem.ts index 619dd64..45391e7 100644 --- a/src/class/action/TravelItem.ts +++ b/src/class/action/TravelItem.ts @@ -8,6 +8,7 @@ import * as FILTER from "../../static/json/for_stock_item_filter.json"; import WindowActiveState from "./WindowActiveState"; export default class TravelItem extends WuhuBase { + className = 'TravelItem'; private readonly apiUrl: string = 'https://yata.yt/api/v1/travel/export/'; private foreignStockInfo: any = null; diff --git a/src/class/action/WindowActiveState.ts b/src/class/action/WindowActiveState.ts index 1b5fc77..a5b4cbc 100644 --- a/src/class/action/WindowActiveState.ts +++ b/src/class/action/WindowActiveState.ts @@ -2,6 +2,7 @@ import uuidv4 from "../../func/utils/uuidv4"; import WuhuBase from "../WuhuBase"; export default class WindowActiveState extends WuhuBase { + className = 'WindowActiveState'; isFocus = false; uuid = uuidv4(); diff --git a/src/class/action/XZMZ.ts b/src/class/action/XZMZ.ts index 4225dbd..1ce9e8b 100644 --- a/src/class/action/XZMZ.ts +++ b/src/class/action/XZMZ.ts @@ -6,7 +6,12 @@ import CommonUtils from "../utils/CommonUtils"; import XUNZHAOMUZHUANG_CSS from "../../static/css/xunzhaomuzhuang.css"; import TornStyleBlock from "../utils/TornStyleBlock"; +/** + * 寻找木桩 + * /item.php?temp=4#xunzhaomuzhuang + */ export default class XZMZ extends WuhuBase { + className = 'XZMZ'; private readonly mainRoleContainer: HTMLElement; private readonly IDList: number[]; private readonly btn: HTMLButtonElement; @@ -44,8 +49,9 @@ export default class XZMZ extends WuhuBase { CommonUtils.ajaxFetch({ url: window.addRFC('https://www.torn.com/profiles.php?step=getProfileData&XID=' + id), method: 'GET' - }) - .then((res) => res.json()) + }).then((res) => + res.json() + ) .then((res) => { this.counter--; if (res.userStatus.status.type === 'ok') { @@ -79,7 +85,7 @@ export default class XZMZ extends WuhuBase { $node += '' + data.player_id + '' $node += `${ data.name }`; $node += '' + data.level + '' - $node += '攻击' + $node += '攻击' $parentNode.insertAdjacentHTML('beforeend', $node) } } \ No newline at end of file diff --git a/src/class/provider/Provider.ts b/src/class/provider/Provider.ts index d43eb6e..0640476 100644 --- a/src/class/provider/Provider.ts +++ b/src/class/provider/Provider.ts @@ -1,7 +1,10 @@ +import Log from "../Log"; + /** * 基类、单例 */ export default class Provider { + protected readonly className: string = 'Provider'; private static instance; private static readonly pool = {}; @@ -13,7 +16,9 @@ export default class Provider { // return this.instance ||= new this(); if (!this.instance) { this.instance = new this(); - Provider.pool[this.name] = this.instance; + let thatName = this.instance.getClassName() || this.name; + Log.info('新建实例,', thatName, this.instance); + Provider.pool[thatName] = this.instance; } return this.instance; } diff --git a/src/class/provider/Starter.ts b/src/class/provider/Starter.ts index e03bdec..5982131 100644 --- a/src/class/provider/Starter.ts +++ b/src/class/provider/Starter.ts @@ -1,12 +1,22 @@ import Log from "../Log"; +import ZhongIcon from "../ZhongIcon"; export default class Starter { public static run(T): void { + + if (window.WHTRANS) throw '退出, 已运行次数' + window.WHTRANS; + window.WHTRANS = window.WHTRANS === undefined ? 1 : window.WHTRANS++; + + let started = performance.now(); try { T.main(); - } catch (error) { - Log.error(error); - Log.error('[Starter] trace: ', JSON.stringify({ error })); + } catch (e) { + Log.error('加载出错'); + Log.error('[Starter]', e.message || JSON.stringify(e)); } + let runTime: number = (performance.now() - started) | 0; + Log.info(`加载时间${ runTime }ms`); + if (ZhongIcon.ZhongNode && ZhongIcon.ZhongNode.initTimer) + ZhongIcon.ZhongNode.initTimer.innerHTML = `加载时间 ${ runTime }ms`; } } \ No newline at end of file diff --git a/src/class/utils/ActionButtonUtils.ts b/src/class/utils/ActionButtonUtils.ts index d6202a5..98b99d7 100644 --- a/src/class/utils/ActionButtonUtils.ts +++ b/src/class/utils/ActionButtonUtils.ts @@ -3,6 +3,7 @@ import Log from "../Log"; import ZhongIcon from "../ZhongIcon"; export default class ActionButtonUtils extends WuhuBase { + className = 'ActionButtonUtils'; private hasAdded: boolean = false; public add(txt: string, func: (ev: Event) => void = () => null): void { diff --git a/src/class/utils/Alert.ts b/src/class/utils/Alert.ts index e921fa0..1c95600 100644 --- a/src/class/utils/Alert.ts +++ b/src/class/utils/Alert.ts @@ -7,6 +7,7 @@ import NOTIFY_HTML from "../../static/html/notify.html"; import WindowActiveState from "../action/WindowActiveState"; export default class Alert extends WuhuBase { + className = 'Alert'; private static container: HTMLElement = null; private notify: MyHTMLElement = null; diff --git a/src/class/utils/CommonUtils.ts b/src/class/utils/CommonUtils.ts index 954f530..c53b699 100644 --- a/src/class/utils/CommonUtils.ts +++ b/src/class/utils/CommonUtils.ts @@ -7,9 +7,11 @@ import Alert from "./Alert"; import LOADING_IMG_HTML from "../../static/html/loading_img.html"; export default class CommonUtils extends WuhuBase { + className = 'CommonUtils'; + static getScriptEngine() { let glob = CommonUtils.glob; - return glob.unsafeWindow ? UserScriptEngine.GM : glob.isPDA + return glob.GM_xmlhttpRequest ? UserScriptEngine.GM : glob.isPDA ? UserScriptEngine.PDA : UserScriptEngine.RAW; } diff --git a/src/class/utils/FetchUtils.ts b/src/class/utils/FetchUtils.ts index e1e8836..aa2e8a9 100644 --- a/src/class/utils/FetchUtils.ts +++ b/src/class/utils/FetchUtils.ts @@ -1,6 +1,7 @@ import WuhuBase from "../WuhuBase"; export default class FetchUtils extends WuhuBase { + className = 'FetchUtils'; /** * 包装jquery ajax 异步返回string * @param url diff --git a/src/class/utils/InfoUtils.ts b/src/class/utils/InfoUtils.ts index f374f82..653ad03 100644 --- a/src/class/utils/InfoUtils.ts +++ b/src/class/utils/InfoUtils.ts @@ -5,6 +5,7 @@ import Log from "../Log"; import CommonUtils from "./CommonUtils"; export default class InfoUtils extends WuhuBase { + className = 'InfoUtils'; /** * 返回玩家信息的对象 { playername: string, userID: number } * @return {PlayerInfo} rs diff --git a/src/class/utils/MDUtils.ts b/src/class/utils/MDUtils.ts index 3286595..78bc3cc 100644 --- a/src/class/utils/MDUtils.ts +++ b/src/class/utils/MDUtils.ts @@ -1,6 +1,7 @@ import WuhuBase from "../WuhuBase"; export default class MDUtils extends WuhuBase { + className = 'MDUtils'; /** * 解析 Markdown 内容 * @param {String} from diff --git a/src/class/utils/MathUtils.ts b/src/class/utils/MathUtils.ts index 7dbbf17..cc764bb 100644 --- a/src/class/utils/MathUtils.ts +++ b/src/class/utils/MathUtils.ts @@ -1,6 +1,7 @@ import WuhuBase from "../WuhuBase"; export default class MathUtils extends WuhuBase { + className = 'MathUtils'; // 得到一个两数之间的随机整数 public getRandomInt(min: number, max: number): number { min = Math.ceil(min); diff --git a/src/class/utils/NotificationUtils.ts b/src/class/utils/NotificationUtils.ts index 3527d35..c5d0565 100644 --- a/src/class/utils/NotificationUtils.ts +++ b/src/class/utils/NotificationUtils.ts @@ -3,6 +3,7 @@ import Log from "../Log"; import WuhuBase from "../WuhuBase"; export default class NotificationUtils extends WuhuBase { + className = 'NotificationUtils'; private permission: boolean = window.Notification && window.Notification.permission === 'granted'; public push(msg: string, options: IWHNotify = {}): void { diff --git a/src/class/utils/Popup.ts b/src/class/utils/Popup.ts index 3987509..4036450 100644 --- a/src/class/utils/Popup.ts +++ b/src/class/utils/Popup.ts @@ -3,7 +3,7 @@ import POPUP_HTML from "../../static/html/popup.html"; import Log from "../Log"; export default class Popup extends WuhuBase { - protected className = 'Popup'; + className = 'Popup'; private readonly container: HTMLElement = null; private readonly node: HTMLElement = null; diff --git a/src/func/module/travelHelper.ts b/src/func/module/travelHelper.ts index fd045b3..697ad5d 100644 --- a/src/func/module/travelHelper.ts +++ b/src/func/module/travelHelper.ts @@ -204,8 +204,9 @@ export default async function travelHelper(): Promise { } // 解毒提醒 if (bodyAttrs['data-country'] === 'switzerland') { - let block = new TornStyleBlock('解毒提醒').insert2Dom(); + let block = new TornStyleBlock('解毒提醒'); block.setContent('

❤️ 点击前往解毒

'); + document.querySelector('h4#skip-to-content').before(block.getBase()); // let page_title = document.querySelector('h4#skip-to-content'); // let msg = document.createElement('div'); // msg.innerHTML = `
diff --git a/src/interface/MyHTMLElement.ts b/src/interface/MyHTMLElement.ts index fd92d3f..f03f374 100644 --- a/src/interface/MyHTMLElement.ts +++ b/src/interface/MyHTMLElement.ts @@ -2,6 +2,7 @@ interface MyHTMLElement extends HTMLElement { sys_notify?: Notification; msgInnerText?: string; close?: () => void; + initTimer?: HTMLElement; // 对象的其他参数 [key: string]: any; diff --git a/src/static/html/xunzhaomuzhuang/index.html b/src/static/html/xunzhaomuzhuang/index.html index dff503f..7806c16 100644 --- a/src/static/html/xunzhaomuzhuang/index.html +++ b/src/static/html/xunzhaomuzhuang/index.html @@ -19,9 +19,9 @@ 攻击 - - BS(M) - + + + diff --git a/src/test/Test.ts b/src/test/Test.ts index 9dbd907..8251178 100644 --- a/src/test/Test.ts +++ b/src/test/Test.ts @@ -1,17 +1,17 @@ import WuhuBase from "../class/WuhuBase"; import Log from "../class/Log"; import Popup from "../class/utils/Popup"; -import TornStyleSwitch from "../class/utils/TornStyleSwitch"; -import CommonUtils from "../class/utils/CommonUtils"; export default class Test extends WuhuBase { + className = 'Test'; public test(): void { - let popup = new Popup('test'); + let popup = new Popup(''); popup.getElement()['__POOL__'] = Test.getPool(); - popup.getElement().append(new TornStyleSwitch('123').getBase()); + // this.case1() // this.case2() this.case3().then(); + // window.fetch('/test').then(res=>res.text()).then(o=>Log.info(o)) } private case1() { @@ -44,9 +44,10 @@ export default class Test extends WuhuBase { } private async case3() { - Log.info(await CommonUtils.ajaxFetch({ - url: window.addRFC('https://www.torn.com/profiles.php?step=getProfileData&XID=17003'), - method: 'GET' - })); + Log.info('window.addRFC', typeof window.addRFC); + Log.info('window.getAction', typeof window.getAction); + Log.info('window.initializeTooltip', typeof window.initializeTooltip); + Log.info('window.renderMiniProfile', typeof window.renderMiniProfile); + // 12 } } \ No newline at end of file