This commit is contained in:
Liwanyi 2023-09-19 10:54:30 +08:00
parent ad36cba92e
commit 201dcb9ba5
65 changed files with 2203 additions and 1121 deletions

10
global.d.ts vendored
View File

@ -122,10 +122,8 @@ declare module "*.module.css" {
declare function GM_xmlhttpRequest(init: any): void; declare function GM_xmlhttpRequest(init: any): void;
declare var unsafeWindow: Window & typeof globalThis; declare var unsafeWindow: Window & typeof globalThis;
declare interface UnknownFields {
// any property
[key: string]: any
}
declare type Constructor<T = any> = new (...args: any[]) => T; declare type Constructor<T = any> = new (...args: any[]) => T;
declare interface ClassType<T> {
new(...args: unknown[]): T
}

18
package-lock.json generated
View File

@ -1,12 +1,12 @@
{ {
"name": "wuhu-torn-helper", "name": "wuhu-torn-helper",
"version": "1.0.8", "version": "1.1.1",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "wuhu-torn-helper", "name": "wuhu-torn-helper",
"version": "1.0.8", "version": "1.1.1",
"devDependencies": { "devDependencies": {
"@element-plus/icons-vue": "^2.1.0", "@element-plus/icons-vue": "^2.1.0",
"@rollup/plugin-alias": "^4.0.3", "@rollup/plugin-alias": "^4.0.3",
@ -17,7 +17,7 @@
"@rollup/plugin-terser": "^0.4.0", "@rollup/plugin-terser": "^0.4.0",
"@rollup/plugin-typescript": "^8.5.0", "@rollup/plugin-typescript": "^8.5.0",
"@types/jquery": "^3.5.14", "@types/jquery": "^3.5.14",
"@types/node": "^18.0.6", "@types/node": "^20.6.0",
"@vitejs/plugin-vue": "^4.0.0", "@vitejs/plugin-vue": "^4.0.0",
"@vue/tsconfig": "^0.1.3", "@vue/tsconfig": "^0.1.3",
"cross-env": "^7.0.3", "cross-env": "^7.0.3",
@ -1150,9 +1150,9 @@
} }
}, },
"node_modules/@types/node": { "node_modules/@types/node": {
"version": "18.0.6", "version": "20.6.0",
"resolved": "https://registry.npmmirror.com/@types/node/-/node-18.0.6.tgz", "resolved": "https://registry.npmmirror.com/@types/node/-/node-20.6.0.tgz",
"integrity": "sha512-/xUq6H2aQm261exT6iZTMifUySEt4GR5KX8eYyY+C4MSNPqSh9oNIP7tz2GLKTlFaiBbgZNxffoR3CVRG+cljw==", "integrity": "sha512-najjVq5KN2vsH2U/xyh2opaSEz6cZMR2SetLIlxlj08nOcmPOemJmUK2o4kUzfLqfrWE0PIrNeE16XhYDd3nqg==",
"dev": true "dev": true
}, },
"node_modules/@types/parse-json": { "node_modules/@types/parse-json": {
@ -8390,9 +8390,9 @@
} }
}, },
"@types/node": { "@types/node": {
"version": "18.0.6", "version": "20.6.0",
"resolved": "https://registry.npmmirror.com/@types/node/-/node-18.0.6.tgz", "resolved": "https://registry.npmmirror.com/@types/node/-/node-20.6.0.tgz",
"integrity": "sha512-/xUq6H2aQm261exT6iZTMifUySEt4GR5KX8eYyY+C4MSNPqSh9oNIP7tz2GLKTlFaiBbgZNxffoR3CVRG+cljw==", "integrity": "sha512-najjVq5KN2vsH2U/xyh2opaSEz6cZMR2SetLIlxlj08nOcmPOemJmUK2o4kUzfLqfrWE0PIrNeE16XhYDd3nqg==",
"dev": true "dev": true
}, },
"@types/parse-json": { "@types/parse-json": {

View File

@ -17,7 +17,7 @@
"@rollup/plugin-terser": "^0.4.0", "@rollup/plugin-terser": "^0.4.0",
"@rollup/plugin-typescript": "^8.5.0", "@rollup/plugin-typescript": "^8.5.0",
"@types/jquery": "^3.5.14", "@types/jquery": "^3.5.14",
"@types/node": "^18.0.6", "@types/node": "^20.6.0",
"@vitejs/plugin-vue": "^4.0.0", "@vitejs/plugin-vue": "^4.0.0",
"@vue/tsconfig": "^0.1.3", "@vue/tsconfig": "^0.1.3",
"cross-env": "^7.0.3", "cross-env": "^7.0.3",

View File

@ -1,19 +1,24 @@
<div class="acc-title"> <div class="acc-title">
<span class="item-desc" style="display: inline-block;"> <span class="item-desc tt-buy">
<span class="item Alcohol" itemid="180" loaded="0"> <span class="item Alcohol" itemid="180" loaded="0">
<span class="item-plate"> <span class="item-plate">
<img alt="Bottle of Beer" class="torn-item large" src="/images/items/180/large.png"> <img alt="Bottle of Beer" class="torn-item large"
src="/images/items/180/large.png"
srcset="/images/items/180/large.png 1x, /images/items/180/large@2x.png 2x, /images/items/180/large@3x.png 3x, /images/items/180/large@4x.png 4x">
</span> </span>
<span class="item-hover"> <span class="item-hover">
<button aria-labelledby="Show info: 180-name 180-price 180-stock" class="view-info wai-btn" i-data="i_871_346_51_52" <button aria-labelledby="Show info: 180-name 180-price 180-stock" class="view-info wai-btn"
value="100"></button> value="100"></button>
<button aria-label="Buy: Bottle of Beer" class="buy-info wai-btn" i-data="i_922_346_51_52" value="100"></button> <button aria-label="Buy: Bottle of Beer" class="buy-info wai-btn" value="100"></button>
</span> </span>
</span> </span>
<span class="desc"> <span class="desc">
<input name="shoparea" type="hidden" value="100">
<span id="180-name" class="name t-overflow bold">Bottle of Beer</span> <span id="180-name" class="name t-overflow bold">Bottle of Beer</span>
<span id="180-price" class="price t-gray-6" data-sell="$5">$10</span> <span id="180-price" class="price t-gray-6 tt-modified" data-sell="$5">$10<span
<span id="180-stock" class="stock t-gray-6 t-overflow">Alcohol (<span class="instock">800</span> in stock)</span> class="tt-profit positive"><i class="fas fa-caret-up"></i>$1,636</span></span>
<span id="180-stock" class="stock t-gray-6 t-overflow">Alcohol (<span class="instock">5,000</span> in
stock)</span>
</span> </span>
<span class="buy-act-wrap"> <span class="buy-act-wrap">
<button aria-label="Close" class="close-icon p0 wai-btn" value="100"></button> <button aria-label="Close" class="close-icon p0 wai-btn" value="100"></button>
@ -21,37 +26,42 @@
of Bottle of Beer</label> of Bottle of Beer</label>
<input id="180" autocomplete="new-amount" maxlength="3" name="buyAmount[]" type="text" value="100"> <input id="180" autocomplete="new-amount" maxlength="3" name="buyAmount[]" type="text" value="100">
<span class="buy-act bold"> <span class="buy-act bold">
<button class="wai-support t-blue h" i-data="i_1076_375_53_34" value="100">Buy<br></button> <button class="wai-support t-blue h" value="100">Buy<br><span class="tt-max-buy">fill
max</span></button>
<div class="tt-max-buy-overlay"></div>
</span> </span>
</span> </span>
</span> </span>
<div class="torn-divider divider-right"></div> <div class="torn-divider divider-right"></div>
<div class="confirm-wrap" style="display: none;" tabindex="0"> <div class="confirm-wrap" tabindex="0">
<span class="confirm"> <span class="confirm">
<span> <span>
Are you sure you would like to buy Are you sure you would like to buy
</span> </span>
<span> <span>
<span class="count">100</span> <span class="count"></span>
x Bottle of Beer for x Bottle of Beer for
$<span class="total">1,000</span> $<span class="total"></span>
</span> </span>
<span class="confirm-act m-top5"> <span class="confirm-act m-top5">
<a class="wai-support yes m-right10 bold t-blue h" data-id="180" href="#" i-data="i_966_379_24_14"> <a class="wai-support yes m-right10 bold t-blue h" data-id="180" href="#">
Yes Yes
</a> </a>
<span class="no bold"> <span class="no bold">
<a class="wai-support t-blue h" href="#" i-data="i_1001_379_16_14"> <a class="wai-support t-blue h" href="#">
No No
</a> </a>
</span> </span>
</span> </span>
</span> </span>
</div> </div>
<div class="success-wrap" style="display: none;"> <div class="success-wrap">
<span class="success"><span class="t-green bold"></span> <span class="success">
<span class="confirm-act m-top5"></span></span> <span class="t-green bold">
<button aria-label="Close" class="close-icon p0 wai-btn" i-data="i_1101_344_10_11" value="100"></button> <span class="ajax-preloader"></span>
</span>
</span>
<button aria-label="Close" class="close-icon p0 wai-btn" value="100"></button>
</div> </div>
<div class="msg-wrap"> <div class="msg-wrap">
<span class="t-green bold"> <span class="t-green bold">
@ -59,10 +69,3 @@ No
</span> </span>
</div> </div>
</div> </div>
<div class="view-item-info">
<div class="item-cont">
<div class="item-wrap">
<span class="ajax-preloader m-top10 m-bottom10"></span>
</div>
</div>
</div>

View File

@ -1,47 +1,57 @@
import WuhuBase from "./class/WuhuBase"; import Interrupt from "./class/Interrupt"
import WuHuTornHelper from "./class/WuhuTornHelper"; import Initializer from "./class/Initializer"
import { Common } from "./class/Common"; // import { Common } from "./class/Common"
import UrlRouter from "./class/UrlRouter"; // import UrlRouter from "./class/UrlRouter"
import translateMain from "./func/translate/translateMain"; import translateMain from "./func/translate/translateMain"
import CommonUtils from "./class/utils/CommonUtils"; import CommonUtils from "./class/utils/CommonUtils"
import LocalConfigWrapper from "./class/LocalConfigWrapper"; import LocalConfigWrapper from "./class/LocalConfigWrapper"
import ClassName from "./container/ClassName"; import ClassName from "./container/ClassName"
import { Injectable } from "./container/Injectable"; import { Injectable } from "./container/Injectable"
import FeatureMan from "./man/FeatureMan"
import Logger from "./class/Logger"
@ClassName('Application') @ClassName('Application')
@Injectable() @Injectable()
export default class App { export default class App {
private readonly logger = Logger.factory(App)
constructor( constructor(
// private readonly icon: ZhongIcon, private readonly interrupt: Interrupt,
private readonly wuhuBase: WuhuBase, private readonly initializer: Initializer,
private readonly tornHelper: WuHuTornHelper, // private readonly common: Common,
private readonly common: Common, // private readonly urlRouter: UrlRouter,
private readonly urlRouter: UrlRouter,
private readonly configWrapper: LocalConfigWrapper, private readonly configWrapper: LocalConfigWrapper,
private readonly utils: CommonUtils, private readonly utils: CommonUtils,
private readonly featureMan: FeatureMan,
) { ) {
} }
public run() { public run() {
this.wuhuBase.conditionInterrupt(); this.interrupt.conditionInterrupt();
// 初始化 // 初始化
this.tornHelper.init(); this.initializer.init();
// this.featureMan.fStart().then(() => this.featureMan.printTable());
// 插件图标和设置菜单 // 插件图标和设置菜单
// this.icon.init(); // this.icon.init();
let tmp = () => { let tmp = () => {
// 所有页面通用 // // 所有页面通用
try { // try {
// this.common.resolve.apply(this.common, this.run); // // this.common.resolve.apply(this.common, this.run);
this.common.resolve(() => this.run()); // // this.common.resolve(() => this.run());
} catch (e) { // } catch (e) {
} // }
(async function (self: App) {
await self.featureMan.fStart()
self.featureMan.printTable()
})(this)
// URL匹配 // URL匹配
this.urlRouter.resolve(); // this.urlRouter.resolve();
// 翻译 // 翻译
if (this.configWrapper.config.transEnable) if (this.configWrapper.config.transEnable)

View File

@ -1,152 +1,160 @@
import depoHelper from "../func/module/depoHelper"; // import depoHelper from "../func/module/depoHelper";
import TravelHelper from "../func/module/travelHelper"; // import TravelHelper from "../feature/TravelHelper";
import priceWatcherHandle from "../func/module/priceWatcherHandle"; // import priceWatcherHandle from "../func/module/priceWatcherHandle";
import CompanyHelper from "./action/CompanyHelper"; // import CompanyHelper from "../feature/CompanyHelper";
import AttackHelper from "./action/AttackHelper"; // import AttackHelper from "./action/AttackHelper";
import SidebarHelper from "./action/SidebarHelper"; // import SidebarHelper from "../feature/SidebarHelper";
import CommonUtils from "./utils/CommonUtils"; // import CommonUtils from "./utils/CommonUtils";
import FetchUtils from "./utils/FetchUtils"; // import FetchUtils from "./utils/FetchUtils";
import FetchEventCallback from "./action/FetchEventCallback"; // import FetchEventCallback from "./action/FetchEventCallback";
import globVars from "../globVars"; // import globVars from "../globVars";
import TranslateNew from "./action/TranslateNew"; // import TranslateNew from "./action/TranslateNew";
import ClassName from "../container/ClassName"; // import ClassName from "../container/ClassName";
import { Injectable } from "../container/Injectable"; // import { Injectable } from "../container/Injectable";
import LocalConfigWrapper from "./LocalConfigWrapper"; // import LocalConfigWrapper from "./LocalConfigWrapper";
import Logger from "./Logger"; // import Logger from "./Logger";
import BuyBeerHelper from "./action/BuyBeerHelper"; // import BuyBeerHelper from "../feature/BuyBeerHelper";
import ModuleLoader from "./ModuleLoader"; // import ModuleLoader from "./ModuleLoader";
import TornPDAUtils from "./utils/TornPDAUtils"; // import TornPDAUtils from "./utils/TornPDAUtils";
import TravelItem from "./action/TravelItem"; // import TravelItem from "../feature/TravelItem";
import IconHelper from "./IconHelper"; // import IconHelper from "../feature/IconHelper";
import MsgWrapper from "./utils/MsgWrapper"; // import MsgWrapper from "./utils/MsgWrapper";
import toThousands from "../func/utils/toThousands"; // import toThousands from "../func/utils/toThousands";
import { WHIntervalLoader } from "./interval/IntervalUnit"; // import { WHIntervalLoader } from "../monitor/WHIntervalLoader";
//
/** // /**
* // * 脚本不区分页面的通用功能入口
*/ // */
@Injectable() // @Injectable()
@ClassName('Common') // @ClassName('Common')
export class Common { // export class Common {
// private readonly logger = Logger.factory(Common)
constructor( //
private readonly localConfigWrapper: LocalConfigWrapper, // constructor(
private readonly fetchEventCallback: FetchEventCallback, // private readonly localConfigWrapper: LocalConfigWrapper,
private readonly translateNew: TranslateNew, // // private readonly fetchEventCallback: FetchEventCallback,
private readonly tornPDAUtils: TornPDAUtils, // // private readonly translateNew: TranslateNew,
private readonly logger: Logger, // // private readonly tornPDAUtils: TornPDAUtils,
private readonly buyBeerHelper: BuyBeerHelper, // // private readonly buyBeerHelper: BuyBeerHelper,
private readonly fetchUtils: FetchUtils, // // private readonly fetchUtils: FetchUtils,
private readonly moduleLoader: ModuleLoader, // // private readonly moduleLoader: ModuleLoader,
private readonly msgWrapper: MsgWrapper, // private readonly msgWrapper: MsgWrapper,
) { // ) {
} // }
//
public resolve(mainMethod) { // public resolve(mainMethod) {
// window.setInterval(()=>this.msgWrapper.create('test',{sysNotify:true},'info'),2000); // // window.setInterval(()=>this.msgWrapper.create('test',{sysNotify:true},'info'),2000);
//
// fetch方法处理 // // // fetch方法处理
globVars.responseHandlers.push( // // globVars.responseHandlers.push(
(...args: any[]) => this.fetchEventCallback.responseHandler.apply(this.fetchEventCallback, args) // // (...args: any[]) => this.fetchEventCallback.responseHandler.apply(this.fetchEventCallback, args)
); // // );
// fetch方法处理-翻译 // // // fetch方法处理-翻译
globVars.responseHandlers.push( // // globVars.responseHandlers.push(
(...args: any[]) => this.translateNew.responseHandler.apply(this.translateNew, args) // // (...args: any[]) => this.translateNew.responseHandler.apply(this.translateNew, args)
); // // );
//
// 价格监控 // // // 价格监控
priceWatcherHandle(this.tornPDAUtils.isPDA(), this.tornPDAUtils.APIKey); // // priceWatcherHandle(this.tornPDAUtils.isPDA(), this.tornPDAUtils.APIKey);
//
// 啤酒提醒 // // 啤酒提醒
if (this.localConfigWrapper.config._15Alarm) this.buyBeerHelper.start(); // // if (this.localConfigWrapper.config._15Alarm) this.buyBeerHelper.start();
//
this.moduleLoader.push(SidebarHelper); // // this.moduleLoader.push(SidebarHelper);
this.moduleLoader.push(TravelItem); // // this.moduleLoader.push(TravelItem);
this.moduleLoader.push(WHIntervalLoader) // // this.moduleLoader.push(WHIntervalLoader)
//
/** // /**
* () // * 解决一直转圈(加载中)的问题
* All('script[src*="google"]') // * All('script[src*="google"]')
* All('#gtm_tag') // * All('#gtm_tag')
* All('script[src*="chat/gonline"]') // * All('script[src*="chat/gonline"]')
* All('head script[nonce]') // * All('head script[nonce]')
*/ // */
if (document.readyState === 'interactive' && this.localConfigWrapper.config.SolveGoogleScriptPendingIssue) { // // try {
window.stop(); // // if (document.readyState === 'interactive' && this.localConfigWrapper.config.SolveGoogleScriptPendingIssue) {
document.open(); // // window.stop();
let readyStateChangeHandler = () => { // // document.open();
this.logger.info('document.readyState', document.readyState); // // let readyStateChangeHandler = () => {
if (document.readyState === 'complete') { // // this.logger.info('document.readyState', document.readyState);
document.removeEventListener('readystatechange', readyStateChangeHandler); // // if (document.readyState === 'complete') {
mainMethod(); // // document.removeEventListener('readystatechange', readyStateChangeHandler);
throw new Error('页面已重载'); // // mainMethod();
} // // throw new Error('页面已重载');
} // // }
document.addEventListener('readystatechange', readyStateChangeHandler); // // }
this.fetchUtils.fetchText(window.location.href).then(resp => { // // document.addEventListener('readystatechange', readyStateChangeHandler);
let removed = resp; // // this.fetchUtils.fetchText(window.location.href).then(resp => {
[ // // let removed = resp;
/<script id="gtm_tag">.+?<\/script>/ms, // // [
/<script async src="https:\/\/www\.google.+?<\/script>/ms, // // /<script id="gtm_tag">.+?<\/script>/ms,
/<script nonce=".+?gtag.+?<\/script>/ms, // // /<script async src="https:\/\/www\.google.+?<\/script>/ms,
/<script.+?google.+?\/script>/, // // /<script nonce=".+?gtag.+?<\/script>/ms,
].forEach(remove => { // // /<script.+?google.+?\/script>/,
removed = removed.replace(remove, ''); // // ].forEach(remove => {
}); // // removed = removed.replace(remove, '');
this.logger.info({ removed }); // // });
document.write(removed); // // this.logger.info({ removed });
document.close(); // // document.write(removed);
}); // // document.close();
} // // });
// // }
// 存钱相关 // // } catch (e) {
depoHelper(); // // this.logger.error('【解决一直转圈(加载中)的问题】错误',e)
// // }
// 飞行相关 //
this.moduleLoader.push(TravelHelper); // // // 存钱相关
// // try {
// 战斗相关 // // depoHelper();
this.moduleLoader.push(AttackHelper); // // } catch (e) {
// // this.logger.error('【存钱相关】错误',e)
// 公司助手 // // }
this.moduleLoader.push(CompanyHelper); //
// // // 飞行相关
// TODO 新菜单 // // this.moduleLoader.push(TravelHelper);
this.moduleLoader.push(IconHelper); //
// // 战斗相关
this.moduleLoader.load().then(); // // this.moduleLoader.push(AttackHelper);
//
// 自定义CSS // // 公司助手
if (this.localConfigWrapper.config.CustomCss) { // // this.moduleLoader.push(CompanyHelper);
this.logger.info('应用自定义CSS'); //
CommonUtils.addStyle(this.localConfigWrapper.config.CustomCss); // // // 菜单
} // // this.moduleLoader.push(IconHelper);
//
// 现金变动提醒 // // this.moduleLoader.load().then();
if (this.localConfigWrapper.config.CashChangeAlert) CommonUtils.elementReady("#user-money").then(userMoney => { //
let before = '' // // // 自定义CSS
new MutationObserver((mutations, observer) => { // // if (this.localConfigWrapper.config.CustomCss) {
if (!this.localConfigWrapper.config.CashChangeAlert) { // // this.logger.info('应用自定义CSS');
observer.disconnect(); // // CommonUtils.addStyle(this.localConfigWrapper.config.CustomCss);
this.msgWrapper.create('现金变动提醒已关闭', { sysNotify: true }); // // }
return; // //
} // // // 现金变动提醒
this.logger.info("现金变动提醒", mutations); // // if (this.localConfigWrapper.config.CashChangeAlert) CommonUtils.elementReady("#user-money").then(userMoney => {
mutations.forEach(item => { // // let before = ''
if (item.attributeName === 'data-money') { // // new MutationObserver((mutations, observer) => {
let change = userMoney.innerText // // if (!this.localConfigWrapper.config.CashChangeAlert) {
.trim() // // observer.disconnect();
.replaceAll(/[,$]/g, '') // // this.msgWrapper.create('现金变动提醒已关闭', { sysNotify: true });
if (change !== before) { // // return;
this.msgWrapper.create( // // }
'现金变动 ' + item.oldValue + ' --> ' + toThousands(change), // // this.logger.info("现金变动提醒", mutations);
{ sysNotify: true } // // mutations.forEach(item => {
); // // if (item.attributeName === 'data-money') {
before = change // // let change = userMoney.innerText
} // // .trim()
} // // .replaceAll(/[,$]/g, '')
}); // // if (change !== before) {
}).observe(userMoney, { attributes: true, attributeOldValue: true }) // // this.msgWrapper.create(
}); // // '现金变动 ' + item.oldValue + ' --> ' + toThousands(change),
} // // { sysNotify: true }
} // // );
// // before = change
// // }
// // }
// // });
// // }).observe(userMoney, { attributes: true, attributeOldValue: true })
// // });
// }
// }

View File

@ -1,62 +0,0 @@
import Logger, { LoggerKey } from "./Logger";
import ClassName from "../container/ClassName";
import { Injectable } from "../container/Injectable";
import CommonUtils, { CommonUtilsKey } from "./utils/CommonUtils";
import LocalConfigWrapper, { LocalConfigWrapperKey } from "./LocalConfigWrapper";
import NNB from "./handler/NNB";
import ItemPriceWatcherHandler from "./handler/ItemPriceWatcherHandler";
import { createApp } from "vue";
import FloatMenu from "../../vue/FloatMenu.vue";
import PopupWrapper, { PopupWrapperKey } from "./utils/PopupWrapper";
import InfoUtils from "./utils/InfoUtils";
import TravelItem, { TravelItemKey } from "./action/TravelItem";
import QuickGymTrain, { QuickGymTrainKey } from "./action/QuickGymTrain";
import QuickFlyBtnHandler, { QuickFlyBtnHandlerKey } from "./handler/QuickFlyBtnHandler";
import ItemHelper, { ItemHelperKey } from "./utils/ItemHelper";
import MathUtils, { MathUtilsKey } from "./utils/MathUtils";
@ClassName("IconHelper")
@Injectable()
export default class IconHelper {
private readonly _element: HTMLElement;
constructor(
private readonly logger: Logger,
private readonly commonUtils: CommonUtils,
private readonly localConfigWrapper: LocalConfigWrapper,
private readonly nnb: NNB,
private readonly itemPriceWatcherHandler: ItemPriceWatcherHandler,
private readonly popupWrapper: PopupWrapper,
private readonly infoUtils: InfoUtils,
private readonly travelItem: TravelItem,
private readonly quickGymTrain: QuickGymTrain,
private readonly quickFlyBtnHandler: QuickFlyBtnHandler,
private readonly itemHelper: ItemHelper,
private readonly mathUtils: MathUtils,
) {
this._element = document.createElement('div');
}
get element() {
return this._element;
}
init() {
this._element.id = 'WHMenu2023';
document.body.append(this._element);
let app = createApp(FloatMenu);
app.config.errorHandler = (err) => this.logger.error('[VUE错误]', err);
app.config.warnHandler = (err) => this.logger.warn('[VUE警告]', err);
app.provide(LoggerKey, this.logger);
app.provide(CommonUtilsKey, this.commonUtils);
app.provide(MathUtilsKey, this.mathUtils);
app.provide(TravelItemKey, this.travelItem);
app.provide(PopupWrapperKey, this.popupWrapper);
app.provide(LocalConfigWrapperKey, this.localConfigWrapper);
app.provide(QuickGymTrainKey, this.quickGymTrain);
app.provide(QuickFlyBtnHandlerKey, this.quickFlyBtnHandler);
app.provide(ItemHelperKey, this.itemHelper);
app.mount(this._element);
}
}

View File

@ -6,24 +6,35 @@ import { Injectable } from "../container/Injectable";
import ClassName from "../container/ClassName"; import ClassName from "../container/ClassName";
import Logger from "./Logger"; import Logger from "./Logger";
import InfoUtils from "./utils/InfoUtils"; import InfoUtils from "./utils/InfoUtils";
import FetchEventCallback from "./action/FetchEventCallback";
import TranslateNew from "./action/TranslateNew";
import priceWatcherHandle from "../func/module/priceWatcherHandle";
import TornPDAUtils from "./utils/TornPDAUtils";
import LocalConfigWrapper from "./LocalConfigWrapper";
import depoHelper from "../func/module/depoHelper";
import toThousands from "../func/utils/toThousands";
import MsgWrapper from "./utils/MsgWrapper";
import FetchUtils from "./utils/FetchUtils";
@Injectable() @Injectable()
@ClassName('WuHuTornHelper') @ClassName('Initializer')
export default class WuHuTornHelper { export default class Initializer {
private readonly logger: Logger = Logger.factory(Initializer)
constructor( constructor(
// private readonly travelItem: TravelItem,
private readonly global: Global, private readonly global: Global,
private readonly logger: Logger,
private readonly infoUtils: InfoUtils, private readonly infoUtils: InfoUtils,
private readonly commonUtils: CommonUtils, private readonly commonUtils: CommonUtils,
private readonly fetchEventCallback: FetchEventCallback,
private readonly translateNew: TranslateNew,
private readonly tornPDAUtils: TornPDAUtils,
private readonly localConfigWrapper: LocalConfigWrapper,
private readonly msgWrapper: MsgWrapper,
private readonly fetchUtils: FetchUtils,
) { ) {
} }
public init() { public init() {
// this.logger.info('WuHuTornHelper初始化');
// WuhuBase.glob = this.global;
let glob = this.global; let glob = this.global;
// glob.fStock = this.travelItem;
// 请求通知权限 // 请求通知权限
if (window.Notification) { if (window.Notification) {
@ -176,6 +187,97 @@ export default class WuHuTornHelper {
document.documentElement.classList.add("d"); document.documentElement.classList.add("d");
document.body.classList.add("scrollbar-transparent"); document.body.classList.add("scrollbar-transparent");
// fetch方法处理
globVars.responseHandlers.push(
(...args: any[]) => this.fetchEventCallback.responseHandler.apply(this.fetchEventCallback, args)
);
// fetch方法处理-翻译
globVars.responseHandlers.push(
(...args: any[]) => this.translateNew.responseHandler.apply(this.translateNew, args)
);
// 价格监控 TODO 重构
priceWatcherHandle(this.tornPDAUtils.isPDA(), this.tornPDAUtils.APIKey);
/**
* ()
* All('script[src*="google"]')
* All('#gtm_tag')
* All('script[src*="chat/gonline"]')
* All('head script[nonce]')
*/
try {
if (document.readyState === 'interactive' && this.localConfigWrapper.config.SolveGoogleScriptPendingIssue) {
window.stop();
document.open();
let readyStateChangeHandler = () => {
this.logger.info('document.readyState', document.readyState);
if (document.readyState === 'complete') {
document.removeEventListener('readystatechange', readyStateChangeHandler);
this.init();
throw new Error('页面已重载');
}
}
document.addEventListener('readystatechange', readyStateChangeHandler);
this.fetchUtils.fetchText(window.location.href).then(resp => {
let removed = resp;
[
/<script id="gtm_tag">.+?<\/script>/ms,
/<script async src="https:\/\/www\.google.+?<\/script>/ms,
/<script nonce=".+?gtag.+?<\/script>/ms,
/<script.+?google.+?\/script>/,
].forEach(remove => {
removed = removed.replace(remove, '');
});
this.logger.info({ removed });
document.write(removed);
document.close();
});
}
} catch (e) {
this.logger.error('【解决一直转圈(加载中)的问题】错误', e)
}
// 存钱相关
try {
depoHelper();
} catch (e) {
this.logger.error('【存钱相关】错误', e)
}
// 自定义CSS
if (this.localConfigWrapper.config.CustomCss) {
this.logger.info('应用自定义CSS');
CommonUtils.addStyle(this.localConfigWrapper.config.CustomCss);
}
// 现金变动提醒
if (this.localConfigWrapper.config.CashChangeAlert) CommonUtils.elementReady("#user-money").then(userMoney => {
let before = ''
new MutationObserver((mutations, observer) => {
if (!this.localConfigWrapper.config.CashChangeAlert) {
observer.disconnect();
this.msgWrapper.create('现金变动提醒已关闭', { sysNotify: true });
return;
}
this.logger.info("现金变动提醒", mutations);
mutations.forEach(item => {
if (item.attributeName === 'data-money') {
let change = userMoney.innerText
.trim()
.replaceAll(/[,$]/g, '')
if (change !== before) {
this.msgWrapper.create(
'现金变动 ' + item.oldValue + ' --> ' + toThousands(change),
{ sysNotify: true }
);
before = change
}
}
});
}).observe(userMoney, { attributes: true, attributeOldValue: true })
});
return this; return this;
} }
} }

View File

@ -2,12 +2,9 @@ import ClassName from "../container/ClassName";
import { Injectable } from "../container/Injectable"; import { Injectable } from "../container/Injectable";
@ClassName('WuhuBase') @ClassName('Interrupt')
@Injectable() @Injectable()
export default class WuhuBase { export default class Interrupt {
constructor() {
}
public conditionInterrupt() { public conditionInterrupt() {
let title: HTMLElement | { innerText: string } = (document.querySelector('#skip-to-content') || let title: HTMLElement | { innerText: string } = (document.querySelector('#skip-to-content') ||
@ -17,6 +14,6 @@ export default class WuhuBase {
title.innerText.toLowerCase().includes('please validate') || title.innerText.toLowerCase().includes('please validate') ||
document.querySelector('div.container div.cf .iAmUnderAttack') !== null document.querySelector('div.container div.cf .iAmUnderAttack') !== null
); );
if (condition) throw '芜湖'; if (condition) throw new Error('芜湖');
} }
} }

View File

@ -1,3 +1,4 @@
import "reflect-metadata";
import ClassName, { GetClassName } from "../container/ClassName"; import ClassName, { GetClassName } from "../container/ClassName";
import { Injectable } from "../container/Injectable"; import { Injectable } from "../container/Injectable";
import Log from "./Log"; import Log from "./Log";
@ -30,7 +31,7 @@ export default class Logger {
return Log.getTime() return Log.getTime()
} }
static factory(classT: new(...args) => any): Logger { static factory<T>(classT: ClassType<T>): Logger {
let className = GetClassName(classT); let className = GetClassName(classT);
return new class extends Logger { return new class extends Logger {
info(...o: any): void { info(...o: any): void {

View File

@ -6,23 +6,24 @@ import { Injectable } from "../container/Injectable";
@ClassName('ModuleLoader') @ClassName('ModuleLoader')
@Injectable() @Injectable()
export default class ModuleLoader { export default class ModuleLoader {
private readonly classes: any[] = []; private readonly classes: (new(...arg: any) => { init: () => void })[] = [];
private readonly logger = Logger.factory(ModuleLoader)
constructor( // constructor() {
private readonly logger: Logger, // }
) {
}
/** /**
* *
* @param method 'init' * @param method 'init'
*/ */
public async load(method: string = 'init'): Promise<void> { public async load(method: string = 'init'): Promise<void> {
this.classes.forEach(clas => { this.logger.info('即将加载: ', this.classes)
this.classes.forEach(clazz => {
try { try {
Container.factory(clas)[method](); this.logger.info('正在加载' + GetClassName(clazz))
Container.factory(clazz)[method]();
} catch (e) { } catch (e) {
this.logger.error('ModuleLoader 加载[' + GetClassName(clas) + ']时出错', e.message, e.stack); this.logger.error('加载[' + GetClassName(clazz) + ']时出错', e.message, e.stack);
} }
}); });
this.classes.length = 0; this.classes.length = 0;

View File

@ -7,11 +7,11 @@ import ADD_BEER_HEAD_HTML from "../../static/html/buyBeer/add_beer_head.html";
import QUICK_CRIMES_HTML from "../../static/html/quick_crimes.html"; import QUICK_CRIMES_HTML from "../../static/html/quick_crimes.html";
import RW_RIDER_HTML from "../../static/html/rw_rider.html"; import RW_RIDER_HTML from "../../static/html/rw_rider.html";
import christmasTownHelper from "../func/module/christmasTownHelper"; import christmasTownHelper from "../func/module/christmasTownHelper";
import LotteryHelper from "./action/LotteryHelper"; import LotteryHelper from "../feature/LotteryHelper";
import TornStyleBlock from "./utils/TornStyleBlock"; import TornStyleBlock from "./utils/TornStyleBlock";
import PTHelper from "./action/PTHelper"; import PTHelper from "./action/PTHelper";
import StackHelper from "./action/StackHelper"; import StackHelper from "../feature/StackHelper";
import BuyBeerHelper from "./action/BuyBeerHelper"; import BuyBeerHelper from "../feature/BuyBeerHelper";
import XZMZ from "./action/XZMZ"; import XZMZ from "./action/XZMZ";
import ProfileHelper from "./action/ProfileHelper"; import ProfileHelper from "./action/ProfileHelper";
import SearchHelper from "./action/SearchHelper"; import SearchHelper from "./action/SearchHelper";

View File

@ -5,7 +5,7 @@ import CommonUtils from "./utils/CommonUtils";
import * as EVENTS from "../../static/json/event.json"; import * as EVENTS from "../../static/json/event.json";
import * as FEST from "../../static/json/fest.json"; import * as FEST from "../../static/json/fest.json";
import Popup from "./utils/Popup"; import Popup from "./utils/Popup";
import TravelItem from "./action/TravelItem"; import TravelItem from "../feature/TravelItem";
import ZHONG_MENU_HTML from "../../static/html/zhong/zhong_menu.html"; import ZHONG_MENU_HTML from "../../static/html/zhong/zhong_menu.html";
import ZHONG_UPDATE_HTML from "../../static/html/zhong/zhong_update.html"; import ZHONG_UPDATE_HTML from "../../static/html/zhong/zhong_update.html";
import ZHONG_LOOT_HTML from "../../static/html/zhong/zhong_loot.html"; import ZHONG_LOOT_HTML from "../../static/html/zhong/zhong_loot.html";
@ -15,7 +15,7 @@ import QuickFlyBtnHandler from "./handler/QuickFlyBtnHandler";
import NNB from "./handler/NNB"; import NNB from "./handler/NNB";
import QuickLinksHandler from "./handler/QuickLinksHandler"; import QuickLinksHandler from "./handler/QuickLinksHandler";
import ItemPriceWatcherHandler from "./handler/ItemPriceWatcherHandler"; import ItemPriceWatcherHandler from "./handler/ItemPriceWatcherHandler";
import ChangeLogHandler from "./handler/ChangeLogHandler"; // import ChangeLogHandler from "./handler/ChangeLogHandler";
import ItemPriceHandler from "./handler/ItemPriceHandler"; import ItemPriceHandler from "./handler/ItemPriceHandler";
import SettingsHandler from "./handler/SettingsHandler"; import SettingsHandler from "./handler/SettingsHandler";
import { MENU_ITEM_TYPE } from "../interface/MenuItem"; import { MENU_ITEM_TYPE } from "../interface/MenuItem";
@ -417,7 +417,7 @@ export default class ZhongIcon {
// 物品查价 // 物品查价
list.push(ItemPriceHandler); list.push(ItemPriceHandler);
// 更新历史 // 更新历史
list.push(ChangeLogHandler); // list.push(ChangeLogHandler);
// 助手设置 // 助手设置
list.push(SettingsHandler); list.push(SettingsHandler);
// 测试 // 测试

View File

@ -1,358 +1,352 @@
import CommonUtils from "../utils/CommonUtils"; // import CommonUtils from "../utils/CommonUtils";
import Alert from "../utils/Alert"; // import Alert from "../utils/Alert";
import Global from "../Global"; // import Global from "../Global";
import Device from "../../enum/Device"; // import Device from "../../enum/Device";
import ATTACK_HELPER_CSS from "../../../static/css/attack_helper.module.css"; // import ATTACK_HELPER_CSS from "../../../static/css/attack_helper.module.css";
import ActionButtonUtils from "../utils/ActionButtonUtils"; // import ActionButtonUtils from "../utils/ActionButtonUtils";
import TornStyleBlock from "../utils/TornStyleBlock"; // import TornStyleBlock from "../utils/TornStyleBlock";
import TornStyleSwitch from "../utils/TornStyleSwitch"; // import TornStyleSwitch from "../utils/TornStyleSwitch";
import DialogMsgBox from "../utils/DialogMsgBox"; // import DialogMsgBox from "../utils/DialogMsgBox";
import FetchUtils from "../utils/FetchUtils"; // import FetchUtils from "../utils/FetchUtils";
import MathUtils from "../utils/MathUtils"; // import MathUtils from "../utils/MathUtils";
import LoopHelper from "../utils/LoopHelper"; // import LoopHelper from "../utils/LoopHelper";
import TRAVEL_STATE from "../../enum/TravelState"; // import TRAVEL_STATE from "../../enum/TravelState";
import { Injectable } from "../../container/Injectable"; // import { Injectable } from "../../container/Injectable";
import ClassName from "../../container/ClassName"; // import ClassName from "../../container/ClassName";
import LocalConfigWrapper from "../LocalConfigWrapper"; // import LocalConfigWrapper from "../LocalConfigWrapper";
import Logger from "../Logger"; // import Logger from "../Logger";
//
enum FIGHT_STAGE { // enum FIGHT_STAGE {
READY = 'ready', // READY = 'ready',
IN_PROGRESS_OR_ERROR = 'in_progress_or_error', // IN_PROGRESS_OR_ERROR = 'in_progress_or_error',
FINISHED = 'finished', // FINISHED = 'finished',
END = 'end', // END = 'end',
OTHER = 'other' // OTHER = 'other'
} // }
//
/** // /**
* // * 战斗助手
* TODO // * TODO 页面加载已经在进行中的战斗时的正确判断
*/ // */
@Injectable() // @Injectable()
@ClassName('AttackHelper') // @ClassName('AttackHelper')
export default class AttackHelper { // export default class AttackHelper {
//
private currentStage: FIGHT_STAGE = FIGHT_STAGE.OTHER; // private currentStage: FIGHT_STAGE = FIGHT_STAGE.OTHER;
//
constructor( // constructor(
private readonly localConfigWrapper: LocalConfigWrapper, // private readonly localConfigWrapper: LocalConfigWrapper,
private readonly commonUtils: CommonUtils, // private readonly commonUtils: CommonUtils,
private readonly global: Global, // private readonly global: Global,
private readonly mathUtils: MathUtils, // private readonly mathUtils: MathUtils,
private readonly actionButtonUtils: ActionButtonUtils, // private readonly actionButtonUtils: ActionButtonUtils,
private readonly fetchUtils: FetchUtils, // private readonly fetchUtils: FetchUtils,
private readonly logger: Logger, // private readonly logger: Logger,
) { // ) {
} // }
//
init(): void { // init(): void {
window.setTimeout(() => this._init(), 0); // window.setTimeout(() => this._init(), 0);
} // }
//
private _init() { // private _init() {
if (window.location.href.contains(/loader\.php\?sid=attack/)) { // if (window.location.href.contains(/loader\.php\?sid=attack/)) {
this.fightingPageHandle(); // this.fightingPageHandle();
} // }
// 错误的攻击页面转跳 // // 错误的攻击页面转跳
else if (window.location.href.includes('loader2.php') && this.localConfigWrapper.config.attRelocate) { // // else if (window.location.href.includes('loader2.php') && this.localConfigWrapper.config.attRelocate) {
const spl = window.location.href.trim().split('='); // // const spl = window.location.href.trim().split('=');
const uid = spl[spl.length - 1]; // // const uid = spl[spl.length - 1];
if (this.commonUtils.isValidUid(uid)) { // // if (this.commonUtils.isValidUid(uid)) {
window.location.href = 'https://www.torn.com/loader.php?sid=attack&user2ID=' + uid; // // window.location.href = 'https://www.torn.com/loader.php?sid=attack&user2ID=' + uid;
} else { // // } else {
this.logger.error('[AttackHelper] UID格式不正确'); // // this.logger.error('[AttackHelper] UID格式不正确');
} // // }
} // // }
} // }
//
private fightingPageHandle(): void { // private fightingPageHandle(): void {
// 光速刷新按钮 // // 光速刷新按钮
this.actionButtonUtils.add('光速刷新', () => this.doAttackReload()); // this.actionButtonUtils.add('光速刷新', () => this.doAttackReload());
//
// 盯梢 // // 盯梢
this.watchTarget(); // this.watchTarget();
//
new MutationObserver((_, observer) => { // new MutationObserver((_, observer) => {
let btnList = document.querySelectorAll('div[class^="dialogButtons___"] button') as NodeListOf<HTMLButtonElement>; // let btnList = document.querySelectorAll('div[class^="dialogButtons___"] button') as NodeListOf<HTMLButtonElement>;
//
if (btnList.length === 0) { // if (btnList.length === 0) {
if (this.currentStage === FIGHT_STAGE.READY && this.localConfigWrapper.config.quickFinishAtt === 3) { // if (this.currentStage === FIGHT_STAGE.READY && this.localConfigWrapper.config.quickFinishAtt === 3) {
document.body.classList.remove('wh-move-btn'); // document.body.classList.remove('wh-move-btn');
this.logger.info('移除body class wh-move-btn'); // this.logger.info('移除body class wh-move-btn');
observer.disconnect(); // observer.disconnect();
} // }
// 错误或正在打 // // 错误或正在打
this.currentStage = FIGHT_STAGE.IN_PROGRESS_OR_ERROR; // this.currentStage = FIGHT_STAGE.IN_PROGRESS_OR_ERROR;
this.logger.info('[attackHelper] currentStage', this.currentStage); // this.logger.info('[attackHelper] currentStage', this.currentStage);
return; // return;
} // }
btnList.forEach(btn => { // btnList.forEach(btn => {
let btnText = btn.innerText.toLowerCase(); // let btnText = btn.innerText.toLowerCase();
if (btnText.includes('start') || btnText.includes('join')) { // if (btnText.includes('start') || btnText.includes('join')) {
// 开始 // // 开始
this.quickStartFight(); // this.quickStartFight();
} else if (btnText.includes('continue')) { // } else if (btnText.includes('continue')) {
// 结束end // // 结束end
this.currentStage = FIGHT_STAGE.END; // this.currentStage = FIGHT_STAGE.END;
observer.disconnect(); // observer.disconnect();
} else if (btnText.includes('leave')) { // } else if (btnText.includes('leave')) {
// 无意识状态FINISHED // // 无意识状态FINISHED
this.quickFinishFight(btnList); // this.quickFinishFight(btnList);
} // }
this.logger.info('[attackHelper] currentStage', this.currentStage); // this.logger.info('[attackHelper] currentStage', this.currentStage);
}) // })
}) // })
.observe(document.querySelector('#react-root'), { childList: true, subtree: true }); // .observe(document.querySelector('#react-root'), { childList: true, subtree: true });
} // }
//
// 战斗页面快速刷新 // // 战斗页面快速刷新
private doAttackReload(): void { // private doAttackReload(): void {
if (!window.ReactDOM) { // if (!window.ReactDOM) {
new Alert('光速刷新失败未找到React对象'); // new Alert('光速刷新失败未找到React对象');
this.logger.error('光速刷新失败未找到React对象'); // this.logger.error('光速刷新失败未找到React对象');
return; // return;
} // }
if (!document.querySelector('#react-root #attacker')) { // if (!document.querySelector('#react-root #attacker')) {
this.logger.error('dom元素未找到selector: [#react-root #attacker]'); // this.logger.error('dom元素未找到selector: [#react-root #attacker]');
return; // return;
} // }
let script = document.querySelector('script[src*="/builds/attack/"]'); // let script = document.querySelector('script[src*="/builds/attack/"]');
let url = script.src; // let url = script.src;
if (!url.contains(/runtime\..+\.js/)) { // if (!url.contains(/runtime\..+\.js/)) {
this.logger.error('脚本源[' + url + '] 不匹配规则'); // this.logger.error('脚本源[' + url + '] 不匹配规则');
return; // return;
} // }
window.ReactDOM.unmountComponentAtNode(document.querySelector('#react-root')); // window.ReactDOM.unmountComponentAtNode(document.querySelector('#react-root'));
script.remove(); // script.remove();
let node = document.createElement('script'); // let node = document.createElement('script');
node.src = url; // node.src = url;
node.type = 'text/javascript'; // node.type = 'text/javascript';
document.head.appendChild(node); // document.head.appendChild(node);
} // }
//
// 光速拔刀 // // 光速拔刀
private quickStartFight(): void { // private quickStartFight(): void {
if (this.currentStage === FIGHT_STAGE.READY) { // if (this.currentStage === FIGHT_STAGE.READY) {
return; // return;
} else { // } else {
this.currentStage = FIGHT_STAGE.READY; // this.currentStage = FIGHT_STAGE.READY;
} // }
if (this.localConfigWrapper.config.quickAttIndex === 6) return; // if (this.localConfigWrapper.config.quickAttIndex === 6) return;
/** // /**
* 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'));
this.logger.info('操作按钮', { btn }); // this.logger.info('操作按钮', { btn });
if (!btn.innerText.toLowerCase().includes('fight')) { // if (!btn.innerText.toLowerCase().includes('fight')) {
this.logger.info('未找到攻击按钮, 光速拔刀跳过'); // this.logger.info('未找到攻击按钮, 光速拔刀跳过');
new Alert('未找到攻击按钮, 光速拔刀跳过'); // new Alert('未找到攻击按钮, 光速拔刀跳过');
} else { // } else {
// 判断是否存在脚踢 // // 判断是否存在脚踢
const hasKick = !!document.querySelector('#weapon_boots'); // const hasKick = !!document.querySelector('#weapon_boots');
// modal层 // // modal层
// const modal: HTMLElement = document.querySelector('div[class^="modal___"]'); // // const modal: HTMLElement = document.querySelector('div[class^="modal___"]');
let device = this.global.device; // let device = this.global.device;
this.logger.info(`当前设备类型是${ device }`); // this.logger.info(`当前设备类型是${ device }`);
// 区分设备 // // 区分设备
switch (device) { // switch (device) {
case Device.PC: { // case Device.PC: {
this.logger.info(`开始调整按钮位置`); // this.logger.info(`开始调整按钮位置`);
// 隐藏modal层 // // 隐藏modal层
// modal.style.display = 'none'; // // modal.style.display = 'none';
// 根据选择的武器调整css // // 根据选择的武器调整css
let css_top = '0'; // let css_top = '0';
switch (this.localConfigWrapper.config.quickAttIndex) { // switch (this.localConfigWrapper.config.quickAttIndex) {
// weapon_second // // weapon_second
case 1: { // case 1: {
css_top = '97px'; // css_top = '97px';
break; // break;
} // }
// weapon_melee // // weapon_melee
case 2: { // case 2: {
css_top = '194px'; // css_top = '194px';
break; // break;
} // }
// weapon_temp // // weapon_temp
case 3: { // case 3: {
css_top = '291px'; // css_top = '291px';
break; // break;
} // }
// weapon_fists // // weapon_fists
case 4: // case 4:
// weapon_boots // // weapon_boots
case 5: { // case 5: {
css_top = '375px'; // css_top = '375px';
break; // break;
} // }
} // }
this.commonUtils.styleInject(ATTACK_HELPER_CSS); // this.commonUtils.styleInject(ATTACK_HELPER_CSS);
CommonUtils.addStyle(`.wh-move-btn #defender div[class^="modal___"]{top: ${ css_top };}`); // CommonUtils.addStyle(`.wh-move-btn #defender div[class^="modal___"]{top: ${ css_top };}`);
document.body.classList.add('wh-move-btn'); // document.body.classList.add('wh-move-btn');
break; // break;
} // }
case Device.MOBILE: { // case Device.MOBILE: {
this.logger.info(`开始调整按钮位置`); // this.logger.info(`开始调整按钮位置`);
// 加入css // // 加入css
let css_top = '0'; // let css_top = '0';
let slot_height = '76px'; // let slot_height = '76px';
// 判断有没有脚踢 // // 判断有没有脚踢
if (hasKick) { // if (hasKick) {
// 根据选择的武器调整 // // 根据选择的武器调整
switch (this.localConfigWrapper.config.quickAttIndex) { // switch (this.localConfigWrapper.config.quickAttIndex) {
case 1: { // weapon_second // case 1: { // weapon_second
css_top = '76px'; // css_top = '76px';
break; // break;
} // }
case 2: { // weapon_melee // case 2: { // weapon_melee
css_top = '152px'; // css_top = '152px';
break; // break;
} // }
case 3: { // weapon_temp // case 3: { // weapon_temp
css_top = '228px'; // css_top = '228px';
break; // break;
} // }
case 4: { // weapon_fists // case 4: { // weapon_fists
css_top = '304px'; // css_top = '304px';
break; // break;
} // }
case 5: { // weapon_boots // case 5: { // weapon_boots
css_top = '380px'; // css_top = '380px';
break; // break;
} // }
} // }
} else { // } else {
const slot = document.querySelector('#weapon_main') as HTMLElement; // const slot = document.querySelector('#weapon_main') as HTMLElement;
const height = slot.offsetHeight + 1; // const height = slot.offsetHeight + 1;
// TODO 待验证 // // TODO 待验证
slot_height = height + 'px'; // slot_height = height + 'px';
// 根据选择的武器调整 // // 根据选择的武器调整
switch (this.localConfigWrapper.config.quickAttIndex) { // switch (this.localConfigWrapper.config.quickAttIndex) {
case 1: { // weapon_second // case 1: { // weapon_second
css_top = `${ height }px`; // css_top = `${ height }px`;
break; // break;
} // }
case 2: { // weapon_melee // case 2: { // weapon_melee
css_top = `${ height * 2 }px`; // css_top = `${ height * 2 }px`;
break; // break;
} // }
case 3: { // weapon_temp // case 3: { // weapon_temp
css_top = `${ height * 3 }px`; // css_top = `${ height * 3 }px`;
break; // break;
} // }
case 4: { // weapon_fists // case 4: { // weapon_fists
css_top = `${ height * 4 }px`; // css_top = `${ height * 4 }px`;
break; // break;
} // }
case 5: { // weapon_boots // case 5: { // weapon_boots
css_top = `${ height * 5 }px`; // css_top = `${ height * 5 }px`;
break; // break;
} // }
} // }
} // }
const css_rule = ATTACK_HELPER_CSS.replace('CSSVAR', css_top).replace('CSSVAR', slot_height); // const css_rule = ATTACK_HELPER_CSS.replace('CSSVAR', css_top).replace('CSSVAR', slot_height);
// ` //
// .wh-move-btn #attacker div[class^="modal___"]{display: block;width: 0;top: ${ css_top };left:0;height:0;} // this.commonUtils.styleInject(css_rule);
// .wh-move-btn #attacker div[class^="dialog___"]{border:0;width:80px;height:${ slot_height };} // document.body.classList.toggle('wh-move-btn');
// .wh-move-btn #attacker div[class^="colored___"]{display:block;padding:0;} // btn.onclick = () => {
// .wh-move-btn #attacker div[class^="title___"]{height:0;} // if (this.localConfigWrapper.config.quickFinishAtt !== 3) {
// .wh-move-btn #attacker button{width:100%;margin:0;height:63px;white-space:normal;} // btn.remove();
// `; // // 停止自动刷新
this.commonUtils.styleInject(css_rule); // // stop_reload = true;
document.body.classList.toggle('wh-move-btn'); // } else {
btn.onclick = () => { // document.body.classList.toggle('wh-move-btn');
if (this.localConfigWrapper.config.quickFinishAtt !== 3) { // }
btn.remove(); // };
// 停止自动刷新 // break;
// stop_reload = true; // }
} else { // case Device.TABLET: {
document.body.classList.toggle('wh-move-btn'); // break;
} // }
}; // }
break; // }
} // }
case Device.TABLET: { //
break; // // 光速跑路
} // private quickFinishFight(btnList: NodeListOf<HTMLButtonElement>): void {
} // if (this.currentStage === FIGHT_STAGE.FINISHED) {
} // return;
} // } else {
// this.currentStage = FIGHT_STAGE.FINISHED;
// 光速跑路 // }
private quickFinishFight(btnList: NodeListOf<HTMLButtonElement>): void { // if (this.localConfigWrapper.config.quickFinishAtt === 3) {
if (this.currentStage === FIGHT_STAGE.FINISHED) { // document.body.classList.remove('wh-move-btn');
return; // this.logger.info('移除body class wh-move-btn');
} else { // return;
this.currentStage = FIGHT_STAGE.FINISHED; // }
} // const user_btn_select = ['leave', 'mug', 'hosp'][this.localConfigWrapper.config.quickFinishAtt];
if (this.localConfigWrapper.config.quickFinishAtt === 3) { // // const wrap = document.querySelector('#react-root');
document.body.classList.remove('wh-move-btn'); // this.logger.info('光速跑路选项选中:', user_btn_select);
this.logger.info('移除body class wh-move-btn'); // // const btn_arr: HTMLButtonElement[] = document.querySelectorAll('div[class^="dialogButtons___"] button') as unknown as HTMLButtonElement[];
return; // if (btnList.length > 1) btnList.forEach(btn => {
} // const flag = btn.innerText.toLowerCase().includes(user_btn_select);
const user_btn_select = ['leave', 'mug', 'hosp'][this.localConfigWrapper.config.quickFinishAtt]; // this.logger.info('按钮内容:', btn.innerText, ',是否包含选中:', flag);
// const wrap = document.querySelector('#react-root'); // if (!flag) btn.style.display = 'none';
this.logger.info('光速跑路选项选中:', user_btn_select); // });
// const btn_arr: HTMLButtonElement[] = document.querySelectorAll('div[class^="dialogButtons___"] button') as unknown as HTMLButtonElement[]; // }
if (btnList.length > 1) btnList.forEach(btn => { //
const flag = btn.innerText.toLowerCase().includes(user_btn_select); // // 盯梢模式
this.logger.info('按钮内容:', btn.innerText, ',是否包含选中:', flag); // private watchTarget(): void {
if (!flag) btn.style.display = 'none'; // this.logger.info('获取目标id');
}); // let targetId = window.location.href.split('user2ID=')[1];
} // if (!this.commonUtils.isValidUid(targetId)) {
// this.logger.error('目标id获取错误', targetId);
// 盯梢模式 // throw new Error('目标id获取错误:' + targetId);
private watchTarget(): void { // }
this.logger.info('获取目标id'); // let loop = new LoopHelper(async () => {
let targetId = window.location.href.split('user2ID=')[1]; // let userProfile;
if (!this.commonUtils.isValidUid(targetId)) { // try {
this.logger.error('目标id获取错误', targetId); // userProfile = await this.fetchUtils.getProfile(targetId);
throw new Error('目标id获取错误:' + targetId); // } catch {
} // this.logger.error('盯梢模式无法获取目标id');
let loop = new LoopHelper(async () => { // throw new Error('盯梢模式无法获取目标id');
let userProfile; // }
try { // await this.commonUtils.sleep(this.mathUtils.getRandomInt(20, 50));
userProfile = await this.fetchUtils.getProfile(targetId); // if ((userProfile.userStatus.status === 'ok' && this.commonUtils.getTravelStage() === TRAVEL_STATE.IN_TORN) ||
} catch { // (userProfile.userStatus.status === 'abroad' && this.commonUtils.getTravelStage() === TRAVEL_STATE.ABROAD)) {
this.logger.error('盯梢模式无法获取目标id'); // watchSwitch.getInput().checked = false;
throw new Error('盯梢模式无法获取目标id'); // window.setTimeout(async () => {
} // new Alert('目标已落地/出院/出狱!', { timeout: 10, force: true, sysNotify: true });
await this.commonUtils.sleep(this.mathUtils.getRandomInt(20, 50)); // await this.commonUtils.audioPlay();
if ((userProfile.userStatus.status === 'ok' && this.commonUtils.getTravelStage() === TRAVEL_STATE.IN_TORN) || // await this.commonUtils.sleep(300);
(userProfile.userStatus.status === 'abroad' && this.commonUtils.getTravelStage() === TRAVEL_STATE.ABROAD)) { // await this.commonUtils.audioPlay();
watchSwitch.getInput().checked = false; // await this.commonUtils.sleep(300);
window.setTimeout(async () => { // await this.commonUtils.audioPlay();
new Alert('目标已落地/出院/出狱!', { timeout: 10, force: true, sysNotify: true }); // await this.commonUtils.sleep(300);
await this.commonUtils.audioPlay(); // }, 0);
await this.commonUtils.sleep(300); // }
await this.commonUtils.audioPlay(); // });
await this.commonUtils.sleep(300); // let block = new TornStyleBlock('盯梢模式').insert2Dom();
await this.commonUtils.audioPlay(); // let watchSwitch = new TornStyleSwitch('开启');
await this.commonUtils.sleep(300); // block.append(watchSwitch.getBase());
}, 0); // watchSwitch.getInput().addEventListener('change', () => {
} // if (watchSwitch.getInput().checked) {
}); // new DialogMsgBox('检测玩家状态,当目标状态变成(海外)落地、出院或出狱时通知并播放声音提醒,后可搭配光速刷新食用<br/>确定开启?', {
let block = new TornStyleBlock('盯梢模式').insert2Dom(); // callback: () => {
let watchSwitch = new TornStyleSwitch('开启'); // if (this.commonUtils.getTravelStage() === TRAVEL_STATE.FLYING) {
block.append(watchSwitch.getBase()); // new Alert('失败!已取消');
watchSwitch.getInput().addEventListener('change', () => { // watchSwitch.getInput().checked = false;
if (watchSwitch.getInput().checked) { // return;
new DialogMsgBox('检测玩家状态,当目标状态变成(海外)落地、出院或出狱时通知并播放声音提醒,后可搭配光速刷新食用<br/>确定开启?', { // }
callback: () => { // this.logger.info('盯梢开启, 目标id' + targetId);
if (this.commonUtils.getTravelStage() === TRAVEL_STATE.FLYING) { // loop.start(this.localConfigWrapper.config.WatchTargetFreq | 0);
new Alert('失败!已取消'); // },
watchSwitch.getInput().checked = false; // cancel: () => watchSwitch.getInput().checked = false
return; // });
} // } else {
this.logger.info('盯梢开启, 目标id' + targetId); // loop.stop();
loop.start(this.localConfigWrapper.config.WatchTargetFreq | 0); // this.logger.info('盯梢关闭');
}, // }
cancel: () => watchSwitch.getInput().checked = false // });
}); // }
} else { // }
loop.stop();
this.logger.info('盯梢关闭');
}
});
}
}

View File

@ -1,25 +1,47 @@
import TornStyleBlock from "../utils/TornStyleBlock"; import TornStyleBlock from "../utils/TornStyleBlock";
import Alert from "../utils/Alert";
import TornStyleSwitch from "../utils/TornStyleSwitch"; import TornStyleSwitch from "../utils/TornStyleSwitch";
import { Injectable } from "../../container/Injectable"; import { Injectable } from "../../container/Injectable";
import ClassName from "../../container/ClassName"; import ClassName from "../../container/ClassName";
import LocalConfigWrapper from "../LocalConfigWrapper"; import LocalConfigWrapper from "../LocalConfigWrapper";
import IFeature from "../../man/IFeature";
import MsgWrapper from "../utils/MsgWrapper";
@Injectable() @Injectable()
@ClassName('PTHelper') @ClassName('PTHelper')
export default class PTHelper { export default class PTHelper implements IFeature {
private readonly observer; private observer: MutationObserver;
private readonly usersPointSell; private usersPointSell: HTMLDivElement;
constructor( constructor(
private readonly localConfigWrapper: LocalConfigWrapper, private readonly localConfigWrapper: LocalConfigWrapper,
private readonly msgWrapper: MsgWrapper,
) { ) {
}
description(): string {
return "pt一键购买";
}
iStart(): void | Promise<void> {
this.start()
}
urlExcludes(): RegExp[] {
return [];
}
urlIncludes(): RegExp[] {
return [/pmarket\.php/];
}
start() {
this.observer = new MutationObserver(e => { this.observer = new MutationObserver(e => {
for (const t of e) { for (const t of e) {
t.addedNodes.forEach(e => 'LI' === (e as HTMLElement).tagName && this.removeConfirm(e)) t.addedNodes.forEach(e => 'LI' === (e as HTMLElement).tagName && this.removeConfirm(e))
} }
}); });
this.usersPointSell = document.querySelector('.users-point-sell'); this.usersPointSell = document.querySelector<HTMLDivElement>('.users-point-sell');
let block = new TornStyleBlock('PT一键购买').insert2Dom(); let block = new TornStyleBlock('PT一键购买').insert2Dom();
let switcher = new TornStyleSwitch('开启'); let switcher = new TornStyleSwitch('开启');
@ -27,7 +49,7 @@ export default class PTHelper {
let toggle = switcher.getInput(); let toggle = switcher.getInput();
toggle.checked = this.localConfigWrapper.config.ptQuickBuy; toggle.checked = this.localConfigWrapper.config.ptQuickBuy;
if (toggle.checked) { if (toggle.checked) {
new Alert('一键购买已开启'); this.msgWrapper.create('一键购买已开启');
for (const index in this.usersPointSell.children) { for (const index in this.usersPointSell.children) {
'LI' === this.usersPointSell.children[index].tagName && this.removeConfirm(this.usersPointSell.children[index]) 'LI' === this.usersPointSell.children[index].tagName && this.removeConfirm(this.usersPointSell.children[index])
} }
@ -40,13 +62,13 @@ export default class PTHelper {
'LI' === this.usersPointSell.children[index].tagName && this.removeConfirm(this.usersPointSell.children[index]) 'LI' === this.usersPointSell.children[index].tagName && this.removeConfirm(this.usersPointSell.children[index])
} }
this.observer.observe(this.usersPointSell, { childList: true }); this.observer.observe(this.usersPointSell, { childList: true });
new Alert('一键购买已开启'); this.msgWrapper.create('一键购买已开启');
} else { } else {
for (const index in this.usersPointSell.children) { for (const index in this.usersPointSell.children) {
'LI' === this.usersPointSell.children[index].tagName && this.rollbackConfirm(this.usersPointSell.children[index]) 'LI' === this.usersPointSell.children[index].tagName && this.rollbackConfirm(this.usersPointSell.children[index])
} }
this.observer.disconnect(); this.observer.disconnect();
new Alert('一键购买已关闭'); this.msgWrapper.create('一键购买已关闭');
} }
}); });
} }

View File

@ -8,21 +8,41 @@ import ClassName from "../../container/ClassName";
import { Injectable } from "../../container/Injectable"; import { Injectable } from "../../container/Injectable";
import LocalConfigWrapper from "../LocalConfigWrapper"; import LocalConfigWrapper from "../LocalConfigWrapper";
import Logger from "../Logger"; import Logger from "../Logger";
import IFeature from "../../man/IFeature";
@ClassName('ProfileHelper') @ClassName('ProfileHelper')
@Injectable() @Injectable()
export default class ProfileHelper implements ResponseInject { export default class ProfileHelper implements ResponseInject, IFeature {
private block: TornStyleBlock;
private readonly block;
// 曾用名已检测过标记
private task = true;
constructor( constructor(
private readonly localConfigWrapper: LocalConfigWrapper, private readonly localConfigWrapper: LocalConfigWrapper,
private readonly commonUtils: CommonUtils, private readonly commonUtils: CommonUtils,
private readonly logger: Logger, private readonly logger: Logger,
) { ) {
}
description(): string {
return "个人资料页面辅助";
}
iStart(): void | Promise<void> {
this.start()
}
urlExcludes(): RegExp[] {
return [];
}
// 曾用名已检测过标记
private task = true;
urlIncludes(): RegExp[] {
return [/profiles\.php\?XID=/];
}
start() {
CommonUtils.addStyle('body.wh-hide_profile_img .profile-image a.profile-image-wrapper .img-wrap img{display:none;}'); 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]; // let id = document.querySelector('link[rel="canonical"]').getAttribute('href').split('=')[1];
let id = (new URL(window.location.href)).searchParams.get('XID'); let id = (new URL(window.location.href)).searchParams.get('XID');

View File

@ -4,10 +4,26 @@ import CommonUtils from "../utils/CommonUtils";
import ClassName from "../../container/ClassName"; import ClassName from "../../container/ClassName";
import { Injectable } from "../../container/Injectable"; import { Injectable } from "../../container/Injectable";
import LocalConfigWrapper from "../LocalConfigWrapper"; import LocalConfigWrapper from "../LocalConfigWrapper";
import IFeature from "../../man/IFeature";
@ClassName('SearchHelper') @ClassName('SearchHelper')
@Injectable() @Injectable()
export default class SearchHelper { export default class SearchHelper implements IFeature {
description(): string {
return "搜索助手";
}
iStart(): void | Promise<void> {
this.init()
}
urlExcludes(): RegExp[] {
return [];
}
urlIncludes(): RegExp[] {
return [/page\.php\?sid=UserList/];
}
constructor( constructor(
private readonly localConfigWrapper: LocalConfigWrapper, private readonly localConfigWrapper: LocalConfigWrapper,

View File

@ -6,13 +6,29 @@ import MathUtils from "../utils/MathUtils";
import ClassName from "../../container/ClassName"; import ClassName from "../../container/ClassName";
import { Injectable } from "../../container/Injectable"; import { Injectable } from "../../container/Injectable";
import Logger from "../Logger"; import Logger from "../Logger";
import IFeature from "../../man/IFeature";
/** /**
* *
*/ */
@ClassName("SlotsHelper") @ClassName("SlotsHelper")
@Injectable() @Injectable()
export default class SlotsHelper { export default class SlotsHelper implements IFeature {
description(): string {
return "老虎机批量购买助手";
}
iStart(): void | Promise<void> {
this.init()
}
urlExcludes(): RegExp[] {
return [];
}
urlIncludes(): RegExp[] {
return [/loader\.php\?sid=slots/];
}
constructor( constructor(
private readonly mathUtils: MathUtils, private readonly mathUtils: MathUtils,

View File

@ -7,6 +7,7 @@ import MathUtils from "../utils/MathUtils";
import FetchUtils from "../utils/FetchUtils"; import FetchUtils from "../utils/FetchUtils";
import ClassName from "../../container/ClassName"; import ClassName from "../../container/ClassName";
import { Injectable } from "../../container/Injectable"; import { Injectable } from "../../container/Injectable";
import IFeature from "../../man/IFeature";
/** /**
* *
@ -14,8 +15,35 @@ import { Injectable } from "../../container/Injectable";
*/ */
@ClassName('XZMZ') @ClassName('XZMZ')
@Injectable() @Injectable()
export default class XZMZ { export default class XZMZ implements IFeature {
className = 'XZMZ'; description(): string {
return "寻找木桩";
}
iStart(): void | Promise<void> {
this.start()
}
urlExcludes(): RegExp[] {
return [];
}
urlIncludes(): RegExp[] {
return [/item.php\?temp=4/];
}
start() {
let hasInit: boolean = false
let handle = () => {
if (!hasInit && window.location.hash === '#xunzhaomuzhuang') {
this.init()
hasInit = true
}
}
window.addEventListener('hashchange', handle)
handle()
}
private mainRoleContainer: HTMLElement; private mainRoleContainer: HTMLElement;
private IDList: number[]; private IDList: number[];
private btn: HTMLButtonElement; private btn: HTMLButtonElement;

View File

@ -1,70 +1,70 @@
import Popup from "../utils/Popup"; // import Popup from "../utils/Popup";
import CommonUtils from "../utils/CommonUtils"; // import CommonUtils from "../utils/CommonUtils";
import MDUtils from "../utils/MDUtils"; // import MDUtils from "../utils/MDUtils";
import { MENU_ITEM_TYPE } from "../../interface/MenuItem"; // import { MENU_ITEM_TYPE } from "../../interface/MenuItem";
import Provider from "../provider/Provider"; // import Provider from "../provider/Provider";
import ClassName from "../../container/ClassName"; // import ClassName from "../../container/ClassName";
import { Injectable } from "../../container/Injectable"; // import { Injectable } from "../../container/Injectable";
import { Container } from "../../container/Container"; // import { Container } from "../../container/Container";
import Logger from "../Logger"; // import Logger from "../Logger";
//
/** // /**
* @deprecated // * @deprecated
*/ // */
@ClassName('ChangeLogHandler') // @ClassName('ChangeLogHandler')
@Injectable() // @Injectable()
export class ChangeLogHandler extends Provider { // export class ChangeLogHandler extends Provider {
constructor( // constructor(
private readonly mdUtils: MDUtils, // private readonly mdUtils: MDUtils,
private readonly logger: Logger, // private readonly logger: Logger,
) { // ) {
super(); // super();
} // }
//
public show(): void { // public show(): void {
let popup = new Popup( // let popup = new Popup(
'更新历史:<br/><a target="_blank" href="https://gitlab.com/JJins/wuhu-torn-helper/-/blob/dev/CHANGELOG.md">https://gitlab.com/JJins/wuhu-torn-helper/-/blob/dev/CHANGELOG.md</a><br/>', // '更新历史:<br/><a target="_blank" href="https://gitlab.com/JJins/wuhu-torn-helper/-/blob/dev/CHANGELOG.md">https://gitlab.com/JJins/wuhu-torn-helper/-/blob/dev/CHANGELOG.md</a><br/>',
'更新历史' // '更新历史'
).element; // ).element;
popup.classList.add('wh-changeLog'); // popup.classList.add('wh-changeLog');
let progressBar = document.createElement('div'); // let progressBar = document.createElement('div');
progressBar.style.height = '2px'; // progressBar.style.height = '2px';
progressBar.style.width = '1%'; // progressBar.style.width = '1%';
progressBar.style.backgroundColor = 'red'; // progressBar.style.backgroundColor = 'red';
let progressText = document.createElement('p'); // let progressText = document.createElement('p');
progressText.innerText = '加载更新文件……'; // progressText.innerText = '加载更新文件……';
progressText.style.textAlign = 'center'; // progressText.style.textAlign = 'center';
let style = document.createElement('style'); // let style = document.createElement('style');
style.innerHTML = `.wh-changeLog h2,.wh-changeLog h3,.wh-changeLog h4 {margin:8px 0;}.wh-changeLog li{list-style: inside;}`; // style.innerHTML = `.wh-changeLog h2,.wh-changeLog h3,.wh-changeLog h4 {margin:8px 0;}.wh-changeLog li{list-style: inside;}`;
//
popup.append(progressBar, progressText, style); // popup.append(progressBar, progressText, style);
//
CommonUtils // CommonUtils
.COFetch('https://gitlab.com/JJins/wuhu-torn-helper/-/raw/dev/CHANGELOG.md?' + performance.now()) // .COFetch('https://gitlab.com/JJins/wuhu-torn-helper/-/raw/dev/CHANGELOG.md?' + performance.now())
.then(update => { // .then(update => {
progressBar.style.width = '60%'; // progressBar.style.width = '60%';
progressText.innerText = '解析中……'; // progressText.innerText = '解析中……';
let md = this.mdUtils.parse(update); // let md = this.mdUtils.parse(update);
popup.append(md); // popup.append(md);
progressBar.style.width = '100%'; // progressBar.style.width = '100%';
progressText.innerText = '加载完成'; // progressText.innerText = '加载完成';
//
window.setTimeout(() => { // window.setTimeout(() => {
progressBar.remove(); // progressBar.remove();
progressText.remove() // progressText.remove()
}, 3000); // }, 3000);
}) // })
.catch(e => { // .catch(e => {
this.logger.error(e); // this.logger.error(e);
progressBar.remove(); // progressBar.remove();
progressText.innerText = '无法加载'; // progressText.innerText = '无法加载';
}); // });
} // }
//
} // }
//
export default { // export default {
domType: MENU_ITEM_TYPE.BUTTON, // domType: MENU_ITEM_TYPE.BUTTON,
domText: '🐞 更新历史', // domText: '🐞 更新历史',
clickFunc: () => Container.factory(ChangeLogHandler).show() // clickFunc: () => Container.factory(ChangeLogHandler).show()
}; // };

View File

@ -2,7 +2,7 @@ import CommonUtils from "../utils/CommonUtils";
import QUICK_FLY_CSS from "../../../static/css/quick_fly.module.css"; import QUICK_FLY_CSS from "../../../static/css/quick_fly.module.css";
import QUICK_FLY_HTML from "../../../static/html/quick_fly.html"; import QUICK_FLY_HTML from "../../../static/html/quick_fly.html";
import Alert from "../utils/Alert"; import Alert from "../utils/Alert";
import TravelItem from "../action/TravelItem"; import TravelItem from "../../feature/TravelItem";
import ClassName from "../../container/ClassName"; import ClassName from "../../container/ClassName";
import { Injectable } from "../../container/Injectable"; import { Injectable } from "../../container/Injectable";
import Logger from "../Logger"; import Logger from "../Logger";

View File

@ -1,6 +1,6 @@
import { MenuItemConfig } from "../ZhongIcon"; import { MenuItemConfig } from "../ZhongIcon";
import Timer from "../utils/Timer"; import Timer from "../utils/Timer";
import BuyBeerHelper from "../action/BuyBeerHelper"; import BuyBeerHelper from "../../feature/BuyBeerHelper";
import UpdateTranslateDict from "./UpdateTranslateDict"; import UpdateTranslateDict from "./UpdateTranslateDict";
import landedRedirect from "../../func/module/landedRedirect"; import landedRedirect from "../../func/module/landedRedirect";
import Alert from "../utils/Alert"; import Alert from "../utils/Alert";

View File

@ -1,34 +0,0 @@
import drugCDMonitor from "./DrugCDMonitor";
import { Injectable } from "../../container/Injectable";
import ClassName from "../../container/ClassName";
import LocalConfigWrapper from "../LocalConfigWrapper";
import IntervalSwitch from "./IntervalSwitch";
export default interface IntervalType {
handler: () => void
switcher: (s: IntervalSwitch) => void
getId: () => number
setId: (id: number) => void
getMs: () => number
setMs: (ms: number) => void
}
export const intervalUnits: { [key: string]: IntervalType } = {
drugCDMonitor,
}
@Injectable()
@ClassName('WHIntervalLoader')
export class WHIntervalLoader {
constructor(
private readonly localConfigWrapper: LocalConfigWrapper,
) {
}
init() {
const list = this.localConfigWrapper.config.monitorOn
for (let i = 0; i < list.length; i++) {
intervalUnits[list[i]].switcher(IntervalSwitch.ON)
}
}
}

View File

@ -1,12 +0,0 @@
import { MENU_ITEM_TYPE } from "../../interface/MenuItem";
const BUTTON_HANDLE_METADATA_KEY = Symbol("BUTTON_HANDLE_KEY")
/**
* @ButtonHandler
*
* @param target
*/
export function ButtonHandler<T>(target: T): void {
Reflect.defineMetadata(BUTTON_HANDLE_METADATA_KEY, MENU_ITEM_TYPE.BUTTON, target);
}

View File

@ -1,26 +0,0 @@
export default class Elem {
private readonly elem: HTMLElement;
constructor(tagName) {
this.elem = document.createElement(tagName);
}
public html(htmlString): Elem {
this.elem.innerHTML = htmlString;
return this;
}
public id(id): Elem {
this.elem.id = id;
return this;
}
public class(className): Elem {
this.elem.classList.add(className);
return this;
}
public el(): HTMLElement {
return this.elem;
}
}

View File

@ -2,6 +2,7 @@ import ClassWithName from "../../interface/ClassWithName";
/** /**
* *
* @deprecated
*/ */
export default class Provider implements ClassWithName { export default class Provider implements ClassWithName {
readonly className: string = 'Provider'; readonly className: string = 'Provider';

View File

@ -7,30 +7,14 @@ import globVars from "../../globVars";
@Injectable() @Injectable()
export default class ActionButtonUtils { export default class ActionButtonUtils {
private hasAdded: boolean = false; private hasAdded: boolean = false;
private readonly logger = Logger.factory(ActionButtonUtils)
constructor(
private readonly logger: Logger,
) {
}
public add(txt: string, func: (ev: Event) => void = () => null): void { public add(txt: string, func: (ev: Event) => void = () => null): void {
if (!this.hasAdded) this.handle(txt, func);
else this.logger.warn('ActionButton已存在'); let added = { txt, func }
globVars.actionList.push({ globVars.buttons.push(added)
txt,
func this.logger.info({ globVars })
});
} }
private handle(txt, func): void {
let btn = document.createElement('button');
btn.style.padding = '8px 13px 8px 0';
btn.style.verticalAlign = 'bottom';
btn.style.color = '#4CAF50';
btn.innerHTML = txt;
btn.addEventListener('click', func);
// ZhongIcon.ZhongNode.querySelector('button').after(btn);
this.hasAdded = true;
this.logger.info('ActionButton已添加', { txt, func, btn });
}
} }

View File

@ -3,13 +3,13 @@ const CLASSNAME_METADATA_KEY = Symbol("CLASSNAME_KEY");
/** /**
* *
*/ */
export default function ClassName(className?: string): ClassDecorator { export default function ClassName(className: string): ClassDecorator {
return function <TFunction extends Function>(target: TFunction): TFunction { return function <TFunction extends Function>(target: TFunction): TFunction {
Reflect.defineMetadata(CLASSNAME_METADATA_KEY, className || target.name, target); Reflect.defineMetadata(CLASSNAME_METADATA_KEY, className, target);
return target; return target;
}; };
} }
export function GetClassName(target: any) { export function GetClassName(target: ClassType<{}>): string {
return Reflect.getMetadata(CLASSNAME_METADATA_KEY, target); return Reflect.getMetadata(CLASSNAME_METADATA_KEY, target);
} }

View File

@ -1,40 +1,38 @@
import "reflect-metadata";
import { assertInjectable } from "./Injectable"; import { assertInjectable } from "./Injectable";
import { GetClassName } from "./ClassName"; import ClassName, { GetClassName } from "./ClassName";
import Logger from "../class/Logger";
/** /**
* *
*/ */
@ClassName('Container')
export class Container { export class Container {
static _container = new Map(); static _container = new Map();
private static logger; private static logger;
static set(k: any, v: any): void { static set<T>(k: Constructor<T>, v: T): void {
if (!this._container.has(k)) { if (!this._container.has(k)) {
this._container.set(k, v); this._container.set(k, v);
} }
} }
static get(k: any): any { static get<T>(k: Constructor<T>): T {
return this._container.get(k); return this._container.get(k);
} }
static factory<T>(target: Constructor<T>): T { static factory<T>(target: ClassType<T>): T {
assertInjectable(target); assertInjectable(target);
// if (Container.get(target))
// return Container.get(target);
return this.get(target) || this.initParam(target); return this.get(target) || this.initParam(target);
} }
static setLogger(logger: { info(...o: any[]), error(...o: any[]), warn(...o: any[]) }): void { static setLogger(logger: Logger): void {
this.logger = logger; this.logger = logger;
} }
private static initParam<T>(target: Constructor<T>): T { private static initParam<T>(target: Constructor<T>): T {
// 获取所有注入的服务 // 获取所有注入的服务
const providers = Reflect.getMetadata('design:paramtypes', target); const providers = Reflect.getMetadata('design:paramtypes', target);
// this.logger.info({providers})
// this.logger.info('原型名'+Object.getPrototypeOf(target).constructor.name)
// this.logger.info('直接名'+target.name)
const args = providers ? providers.map((provider: Constructor) => { const args = providers ? providers.map((provider: Constructor) => {
return this.factory(provider); return this.factory(provider);
}) : []; }) : [];

View File

@ -5,7 +5,6 @@ const INJECTABLE_METADATA_KEY = Symbol("INJECTABLE_KEY");
// TODO 实现非单例注入 // TODO 实现非单例注入
export enum INJECT_MODE { export enum INJECT_MODE {
Singleton = 1, Singleton = 1,
Multi = 2,
} }
export function Injectable(injectMode: INJECT_MODE = INJECT_MODE.Singleton): ClassDecorator { export function Injectable(injectMode: INJECT_MODE = INJECT_MODE.Singleton): ClassDecorator {

278
src/ts/feature/Atk.ts Normal file
View File

@ -0,0 +1,278 @@
import ClassName from "../container/ClassName"
import { Injectable } from "../container/Injectable"
import IFeature from "../man/IFeature"
import LocalConfigWrapper from "../class/LocalConfigWrapper"
import CommonUtils from "../class/utils/CommonUtils"
import Global from "../class/Global"
import ActionButtonUtils from "../class/utils/ActionButtonUtils"
import Logger from "../class/Logger"
import Alert from "../class/utils/Alert"
import Device from "../enum/Device"
import ATTACK_HELPER_CSS from "../../static/css/attack_helper.module.css"
import ATK_PAGE_REG from "./url/ATK_PAGE_REG";
enum FIGHT_STAGE {
READY = 'ready',
IN_PROGRESS_OR_ERROR = 'in_progress_or_error',
FINISHED = 'finished',
END = 'end',
OTHER = 'other'
}
@ClassName('Atk')
@Injectable()
export default class Atk implements IFeature {
private currentStage: FIGHT_STAGE = FIGHT_STAGE.OTHER;
constructor(
private readonly actionButtonUtils: ActionButtonUtils,
private readonly localConfigWrapper: LocalConfigWrapper,
private readonly commonUtils: CommonUtils,
private readonly global: Global,
// private readonly mathUtils: MathUtils,
// private readonly fetchUtils: FetchUtils,
private readonly logger: Logger,
) {
}
urlIncludes(): RegExp[] {
return [ATK_PAGE_REG]
}
urlExcludes(): RegExp[] {
return []
}
description(): string {
return '攻击助手'
}
iStart(): void | Promise<void> {
// 光速刷新按钮
this.actionButtonUtils.add('光速刷新', () => this.doAttackReload());
new MutationObserver((_, observer) => {
let btnList = document.querySelectorAll('div[class^="dialogButtons___"] button') as NodeListOf<HTMLButtonElement>;
if (btnList.length === 0) {
if (this.currentStage === FIGHT_STAGE.READY && this.localConfigWrapper.config.quickFinishAtt === 3) {
document.body.classList.remove('wh-move-btn');
this.logger.info('移除body class wh-move-btn');
observer.disconnect();
}
// 错误或正在打
this.currentStage = FIGHT_STAGE.IN_PROGRESS_OR_ERROR;
this.logger.info('[attackHelper] currentStage', this.currentStage);
return;
}
btnList.forEach(btn => {
let btnText = btn.innerText.toLowerCase();
if (btnText.includes('start') || btnText.includes('join')) {
// 开始
this.quickStartFight();
} else if (btnText.includes('continue')) {
// 结束end
this.currentStage = FIGHT_STAGE.END;
observer.disconnect();
} else if (btnText.includes('leave')) {
// 无意识状态FINISHED
this.quickFinishFight(btnList);
}
this.logger.info('[attackHelper] currentStage', this.currentStage);
})
})
.observe(document.querySelector('#react-root'), { childList: true, subtree: true });
}
// 战斗页面快速刷新
private doAttackReload(): void {
if (!window.ReactDOM) {
new Alert('光速刷新失败未找到React对象');
this.logger.error('光速刷新失败未找到React对象');
return;
}
if (!document.querySelector('#react-root #attacker')) {
this.logger.error('dom元素未找到selector: [#react-root #attacker]');
return;
}
let script = document.querySelector('script[src*="/builds/attack/"]');
let url = script.src;
if (!url.contains(/runtime\..+\.js/)) {
this.logger.error('脚本源[' + url + '] 不匹配规则');
return;
}
window.ReactDOM.unmountComponentAtNode(document.querySelector('#react-root'));
script.remove();
let node = document.createElement('script');
node.src = url;
node.type = 'text/javascript';
document.head.appendChild(node);
}
// 光速拔刀
private quickStartFight(): void {
if (this.currentStage === FIGHT_STAGE.READY) {
return;
} else {
this.currentStage = FIGHT_STAGE.READY;
}
if (this.localConfigWrapper.config.quickAttIndex === 6) return;
/**
* pc #defender
* mobile #attacker
*/
const btn = <HTMLInputElement>(document.querySelector('#attacker button') || document.querySelector('#defender button'));
this.logger.info('操作按钮', { btn });
if (!btn.innerText.toLowerCase().includes('fight')) {
this.logger.info('未找到攻击按钮, 光速拔刀跳过');
new Alert('未找到攻击按钮, 光速拔刀跳过');
} else {
// 判断是否存在脚踢
const hasKick = !!document.querySelector('#weapon_boots');
// modal层
// const modal: HTMLElement = document.querySelector('div[class^="modal___"]');
let device = this.global.device;
this.logger.info(`当前设备类型是${ device }`);
// 区分设备
switch (device) {
case Device.PC: {
this.logger.info(`开始调整按钮位置`);
// 隐藏modal层
// modal.style.display = 'none';
// 根据选择的武器调整css
let css_top = '0';
switch (this.localConfigWrapper.config.quickAttIndex) {
// weapon_second
case 1: {
css_top = '97px';
break;
}
// weapon_melee
case 2: {
css_top = '194px';
break;
}
// weapon_temp
case 3: {
css_top = '291px';
break;
}
// weapon_fists
case 4:
// weapon_boots
case 5: {
css_top = '375px';
break;
}
}
this.commonUtils.styleInject(ATTACK_HELPER_CSS);
CommonUtils.addStyle(`.wh-move-btn #defender div[class^="modal___"]{top: ${ css_top };}`);
document.body.classList.add('wh-move-btn');
break;
}
case Device.MOBILE: {
this.logger.info(`开始调整按钮位置`);
// 加入css
let css_top = '0';
let slot_height = '76px';
// 判断有没有脚踢
if (hasKick) {
// 根据选择的武器调整
switch (this.localConfigWrapper.config.quickAttIndex) {
case 1: { // weapon_second
css_top = '76px';
break;
}
case 2: { // weapon_melee
css_top = '152px';
break;
}
case 3: { // weapon_temp
css_top = '228px';
break;
}
case 4: { // weapon_fists
css_top = '304px';
break;
}
case 5: { // weapon_boots
css_top = '380px';
break;
}
}
} else {
const slot = document.querySelector('#weapon_main') as HTMLElement;
const height = slot.offsetHeight + 1;
// TODO 待验证
slot_height = height + 'px';
// 根据选择的武器调整
switch (this.localConfigWrapper.config.quickAttIndex) {
case 1: { // weapon_second
css_top = `${ height }px`;
break;
}
case 2: { // weapon_melee
css_top = `${ height * 2 }px`;
break;
}
case 3: { // weapon_temp
css_top = `${ height * 3 }px`;
break;
}
case 4: { // weapon_fists
css_top = `${ height * 4 }px`;
break;
}
case 5: { // weapon_boots
css_top = `${ height * 5 }px`;
break;
}
}
}
const css_rule = ATTACK_HELPER_CSS.replace('CSSVAR', css_top).replace('CSSVAR', slot_height);
this.commonUtils.styleInject(css_rule);
document.body.classList.toggle('wh-move-btn');
btn.onclick = () => {
if (this.localConfigWrapper.config.quickFinishAtt !== 3) {
btn.remove();
// 停止自动刷新
// stop_reload = true;
} else {
document.body.classList.toggle('wh-move-btn');
}
};
break;
}
case Device.TABLET: {
break;
}
}
}
}
// 光速跑路
private quickFinishFight(btnList: NodeListOf<HTMLButtonElement>): void {
if (this.currentStage === FIGHT_STAGE.FINISHED) {
return;
} else {
this.currentStage = FIGHT_STAGE.FINISHED;
}
if (this.localConfigWrapper.config.quickFinishAtt === 3) {
document.body.classList.remove('wh-move-btn');
this.logger.info('移除body class wh-move-btn');
return;
}
const user_btn_select = ['leave', 'mug', 'hosp'][this.localConfigWrapper.config.quickFinishAtt];
// const wrap = document.querySelector('#react-root');
this.logger.info('光速跑路选项选中:', user_btn_select);
// const btn_arr: HTMLButtonElement[] = document.querySelectorAll('div[class^="dialogButtons___"] button') as unknown as HTMLButtonElement[];
if (btnList.length > 1) btnList.forEach(btn => {
const flag = btn.innerText.toLowerCase().includes(user_btn_select);
this.logger.info('按钮内容:', btn.innerText, ',是否包含选中:', flag);
if (!flag) btn.style.display = 'none';
});
}
}

View File

@ -0,0 +1,68 @@
import ClassName from "../container/ClassName"
import { Injectable } from "../container/Injectable"
import IFeature from "../man/IFeature"
import TornStyleBlock from "../class/utils/TornStyleBlock"
import ADD_BEER_HEAD_HTML from "../../static/html/buyBeer/add_beer_head.html"
import SHOP_BEER_STATIC_ITEM_HTML from "../../static/html/buyBeer/shop_beer_static_item.html"
import globVars from "../globVars"
import Logger from "../class/Logger";
import BuyBeerHelper from "./BuyBeerHelper";
@ClassName('BeerShopModifier')
@Injectable()
export default class BeerShopModifier implements IFeature {
private readonly logger = Logger.factory(BeerShopModifier)
constructor(
private readonly buyBeerHelper: BuyBeerHelper,
) {
}
description(): string {
return "啤酒店页面修改";
}
iStart(): void | Promise<void> {
this.start()
}
urlExcludes(): RegExp[] {
return [];
}
urlIncludes(): RegExp[] {
return [/shops.php\?step=bitsnbobs/];
}
start() {
let block = new TornStyleBlock('啤酒助手').insert2Dom();
block.setContent(ADD_BEER_HEAD_HTML);
const msg_node = block.querySelector('#wh-msg');
// 加入啤酒
block.querySelector('button').addEventListener('click', e => {
let node = document.querySelector('ul.items-list');
if (!node) {
msg_node.innerHTML = '❌ 商品未加载完';
this.logger.error('商品未加载完');
return;
}
if (node.querySelector('span[id="180-name"]')) {
msg_node.innerHTML = '❌ 页面已经有啤酒了';
this.logger.warn('商店页面已有啤酒');
return;
}
const clear_node = node.querySelector('li.clear');
const beer = document.createElement('li');
beer.classList.add('torn-divider', 'divider-vertical');
beer.style.backgroundColor = '#c8c8c8';
beer.innerHTML = SHOP_BEER_STATIC_ITEM_HTML;
if (clear_node) clear_node.before(beer);
else node.append(beer);
(<HTMLInputElement>e.target).disabled = true;
msg_node.innerHTML = '添加成功';
});
// 监听啤酒购买
globVars.responseHandlers.push((...args: any[]) => this.buyBeerHelper.responseHandler.apply(this.buyBeerHelper, args));
}
}

View File

@ -1,18 +1,37 @@
import InfoUtils from "../utils/InfoUtils"; import InfoUtils from "../class/utils/InfoUtils";
import MathUtils from "../utils/MathUtils"; import MathUtils from "../class/utils/MathUtils";
import NOTIFY_HTML from "../../../static/html/buyBeer/notify.html"; import NOTIFY_HTML from "../../static/html/buyBeer/notify.html";
import CommonUtils from "../utils/CommonUtils"; import CommonUtils from "../class/utils/CommonUtils";
import Popup from "../utils/Popup"; import Popup from "../class/utils/Popup";
import ResponseInject from "../../interface/ResponseInject"; import ResponseInject from "../interface/ResponseInject";
import LocalConfigWrapper from "../LocalConfigWrapper"; import LocalConfigWrapper from "../class/LocalConfigWrapper";
import ClassName from "../../container/ClassName"; import ClassName from "../container/ClassName";
import { Injectable } from "../../container/Injectable"; import { Injectable } from "../container/Injectable";
import Logger from "../Logger"; import Logger from "../class/Logger";
import MsgWrapper from "../utils/MsgWrapper"; import MsgWrapper from "../class/utils/MsgWrapper";
import IFeature from "../man/IFeature";
import ATK_PAGE_REG from "./url/ATK_PAGE_REG";
import ALL_PAGE_REG from "./url/ALL_PAGE_REG";
@ClassName('BuyBeerHelper') @ClassName('BuyBeerHelper')
@Injectable() @Injectable()
export default class BuyBeerHelper implements BeerMonitorLoop, ResponseInject { export default class BuyBeerHelper implements BeerMonitorLoop, ResponseInject, IFeature {
urlIncludes(): RegExp[] {
return [ALL_PAGE_REG]
}
urlExcludes(): RegExp[] {
return [ATK_PAGE_REG]
}
description(): string {
return '啤酒助手'
}
iStart(): void | Promise<void> {
(this.localConfigWrapper.config._15Alarm) && this.start()
}
private isNotifying = false; private isNotifying = false;
private loopId: number = null; private loopId: number = null;

View File

@ -0,0 +1,25 @@
import ClassName from "../container/ClassName";
import { Injectable } from "../container/Injectable";
import IFeature from "../man/IFeature";
import christmasTownHelper from "../func/module/christmasTownHelper";
@ClassName('ChristmasTown')
@Injectable()
export default class ChristmasTown implements IFeature {
urlIncludes(): RegExp[] {
return [/christmas_town\.php/]
}
urlExcludes(): RegExp[] {
return []
}
description(): string {
return '圣诞小镇助手'
}
iStart(): void | Promise<void> {
christmasTownHelper()
}
}

View File

@ -1,26 +1,44 @@
import CommonUtils from "../utils/CommonUtils"; import CommonUtils from "../class/utils/CommonUtils";
import FetchUtils from "../utils/FetchUtils"; import FetchUtils from "../class/utils/FetchUtils";
import InfoUtils from "../utils/InfoUtils"; import InfoUtils from "../class/utils/InfoUtils";
import TRAVEL_STATE from "../../enum/TravelState"; import TRAVEL_STATE from "../enum/TravelState";
import LocalConfigWrapper from "../LocalConfigWrapper"; import LocalConfigWrapper from "../class/LocalConfigWrapper";
import { Injectable } from "../../container/Injectable"; import { Injectable } from "../container/Injectable";
import ClassName from "../../container/ClassName"; import ClassName from "../container/ClassName";
import Logger from "../Logger"; import Logger from "../class/Logger";
import MsgWrapper from "../utils/MsgWrapper"; import MsgWrapper from "../class/utils/MsgWrapper";
import IFeature from "../man/IFeature";
import ATK_PAGE_REG from "./url/ATK_PAGE_REG";
import ALL_PAGE_REG from "./url/ALL_PAGE_REG";
/** /**
* *
*/ */
@Injectable() @Injectable()
@ClassName('CompanyHelper') @ClassName('CompanyHelper')
export default class CompanyHelper { export default class CompanyHelper implements IFeature {
className = 'CompanyHelper'; private readonly logger: Logger = Logger.factory(CompanyHelper)
description(): string {
return "公司助手、火车爆仓检测";
}
iStart(): void | Promise<void> {
this.init()
}
urlExcludes(): RegExp[] {
return [ATK_PAGE_REG];
}
urlIncludes(): RegExp[] {
return [ALL_PAGE_REG];
}
public constructor( public constructor(
private readonly localConfigWrapper: LocalConfigWrapper, private readonly localConfigWrapper: LocalConfigWrapper,
private readonly commonUtils: CommonUtils, private readonly commonUtils: CommonUtils,
private readonly fetchUtils: FetchUtils, private readonly fetchUtils: FetchUtils,
private readonly logger: Logger,
private readonly infoUtils: InfoUtils, private readonly infoUtils: InfoUtils,
private readonly msgWrapper: MsgWrapper, private readonly msgWrapper: MsgWrapper,
) { ) {
@ -30,10 +48,6 @@ export default class CompanyHelper {
this.localConfigWrapper.config.CHTrainsDetectSwitch && this.trainsDetect().then(); this.localConfigWrapper.config.CHTrainsDetectSwitch && this.trainsDetect().then();
} }
// public detectNow(): void {
// this.trainsDetect(true).then();
// }
/** /**
* *
* *
@ -56,7 +70,7 @@ export default class CompanyHelper {
this.fetchUtils.fetchText('/companies.php') this.fetchUtils.fetchText('/companies.php')
.then(res => { .then(res => {
let tmp: HTMLElement = document.createElement('div'); let tmp: HTMLElement = document.createElement('div');
let bodyTagStart = this.commonUtils.matchOne(res, /<body.+>/); let bodyTagStart = this.commonUtils.matchOne(res, /<body.+/);
if (!bodyTagStart) { if (!bodyTagStart) {
this.logger.warn('火车检测: 无法获取数据'); this.logger.warn('火车检测: 无法获取数据');
throw new Error('火车检测: 无法获取数据'); throw new Error('火车检测: 无法获取数据');

View File

@ -0,0 +1,78 @@
import ClassName from "../container/ClassName";
import { Injectable } from "../container/Injectable";
import IFeature from "../man/IFeature";
import LocalConfigWrapper from "../class/LocalConfigWrapper";
import CommonUtils from "../class/utils/CommonUtils";
import QUICK_CRIMES_HTML from "../../static/html/quick_crimes.html";
@ClassName('CrimePageModifier')
@Injectable()
export default class CrimePageModifier implements IFeature {
constructor(
private readonly localConfigWrapper: LocalConfigWrapper
) {
}
description(): string {
return "页面快速crime";
}
iStart(): void | Promise<void> {
this.start()
}
urlExcludes(): RegExp[] {
return [];
}
urlIncludes(): RegExp[] {
return [/crimes\.php/];
}
start() { // TODO 重构、与翻译解藕
if (this.localConfigWrapper.config.quickCrime) {
// iframe
if (self !== top) {
const isValidate = document.querySelector('h4#skip-to-content').innerText.toLowerCase().includes('validate');
CommonUtils.elementReady('#header-root').then(e => e.style.display = 'none');
CommonUtils.elementReady('#sidebarroot').then(e => e.style.display = 'none');
CommonUtils.elementReady('#chatRoot').then(e => e.style.display = 'none');
if (!isValidate) document.body.style.overflow = 'hidden';
CommonUtils.elementReady('.content-wrapper').then(e => {
e.style.margin = '0px';
e.style.position = 'absolute';
e.style.top = '-35px';
});
CommonUtils.elementReady('#go-to-top-btn button').then(e => e.style.display = 'none');
}
const element = document.querySelector('.content-wrapper');
const OB = new MutationObserver(() => {
OB.disconnect();
trans();
OB.observe(element, {
characterData: true,
attributes: true,
subtree: true,
childList: true
});
});
const trans = () => {
const dom = QUICK_CRIMES_HTML;
const hasInserted = element.querySelector('.wh-translate') !== null;
const $title = document.querySelector('div.content-title');
const $info = document.querySelector('.info-msg-cont');
if (!hasInserted) {
if ($title) $title.insertAdjacentHTML('beforebegin', dom);
else if ($info) $info.insertAdjacentHTML('beforebegin', dom);
}
};
trans();
OB.observe(element, {
characterData: true,
attributes: true,
subtree: true,
childList: true
});
}
}
}

View File

@ -0,0 +1,76 @@
import Logger, { LoggerKey } from "../class/Logger"
import ClassName from "../container/ClassName"
import { Injectable } from "../container/Injectable"
import CommonUtils, { CommonUtilsKey } from "../class/utils/CommonUtils"
import LocalConfigWrapper, { LocalConfigWrapperKey } from "../class/LocalConfigWrapper"
import { createApp } from "vue"
import FloatMenu from "../../vue/FloatMenu.vue"
import PopupWrapper, { PopupWrapperKey } from "../class/utils/PopupWrapper"
import TravelItem from "./TravelItem"
import QuickGymTrain, { QuickGymTrainKey } from "../class/action/QuickGymTrain"
import QuickFlyBtnHandler, { QuickFlyBtnHandlerKey } from "../class/handler/QuickFlyBtnHandler"
import ItemHelper, { ItemHelperKey } from "../class/utils/ItemHelper"
import MathUtils, { MathUtilsKey } from "../class/utils/MathUtils"
import IFeature from "../man/IFeature"
import ALL_PAGE_REG from "./url/ALL_PAGE_REG"
@ClassName("IconHelper")
@Injectable()
export default class IconHelper implements IFeature {
private readonly _element: HTMLElement = document.createElement('div');
private readonly logger = Logger.factory(IconHelper)
description(): string {
return "浮动图标、侧边菜单、标签式便携功能";
}
iStart(): void | Promise<void> {
this.init()
}
urlExcludes(): RegExp[] {
return [];
}
urlIncludes(): RegExp[] {
return [ALL_PAGE_REG];
}
constructor(
private readonly commonUtils: CommonUtils,
private readonly localConfigWrapper: LocalConfigWrapper,
private readonly popupWrapper: PopupWrapper,
private readonly travelItem: TravelItem,
private readonly quickGymTrain: QuickGymTrain,
private readonly quickFlyBtnHandler: QuickFlyBtnHandler,
private readonly itemHelper: ItemHelper,
private readonly mathUtils: MathUtils,
) {
}
get element() {
return this._element;
}
init() {
this._element.id = 'WHMenu2023';
document.body.append(this._element);
let app = createApp(FloatMenu);
this.logger.info('Vue实例已创建', { app })
app.config.errorHandler = (err) => this.logger.error('[VUE错误]', err);
app.config.warnHandler = (err) => this.logger.warn('[VUE警告]', err);
app.provide(LoggerKey, this.logger);
app.provide(CommonUtilsKey, this.commonUtils);
app.provide(MathUtilsKey, this.mathUtils);
// app.provide(TravelItemKey, this.travelItem);
app.provide(PopupWrapperKey, this.popupWrapper);
app.provide(LocalConfigWrapperKey, this.localConfigWrapper);
app.provide(QuickGymTrainKey, this.quickGymTrain);
app.provide(QuickFlyBtnHandlerKey, this.quickFlyBtnHandler);
app.provide(ItemHelperKey, this.itemHelper);
app.mount(this._element);
this.logger.info('Vue实例已挂载')
}
}

View File

@ -1,19 +1,34 @@
import InfoUtils from "../utils/InfoUtils"; import InfoUtils from "../class/utils/InfoUtils";
import MathUtils from "../utils/MathUtils"; import MathUtils from "../class/utils/MathUtils";
import CommonUtils from "../utils/CommonUtils"; import CommonUtils from "../class/utils/CommonUtils";
import TornStyleBlock from "../utils/TornStyleBlock"; import TornStyleBlock from "../class/utils/TornStyleBlock";
import Timer from "../utils/Timer"; import Timer from "../class/utils/Timer";
import FetchUtils from "../utils/FetchUtils"; import FetchUtils from "../class/utils/FetchUtils";
import { Injectable } from "../../container/Injectable"; import { Injectable } from "../container/Injectable";
import ClassName from "../../container/ClassName"; import ClassName from "../container/ClassName";
import Logger from "../Logger"; import Logger from "../class/Logger";
import IFeature from "../man/IFeature";
/** /**
* *
*/ */
@Injectable() @Injectable()
@ClassName('LotteryHelper') @ClassName('LotteryHelper')
export default class LotteryHelper { export default class LotteryHelper implements IFeature {
private readonly logger: Logger = Logger.factory(LotteryHelper)
description(): string {
return "彩票助手";
}
iStart(): void | Promise<void> {
this.init()
}
urlExcludes(): RegExp[] {
return [];
}
private loopFlag = true; private loopFlag = true;
private radioDaily: HTMLInputElement = null; private radioDaily: HTMLInputElement = null;
@ -26,12 +41,15 @@ export default class LotteryHelper {
private status: HTMLElement = null; private status: HTMLElement = null;
private desc: HTMLElement = null; private desc: HTMLElement = null;
urlIncludes(): RegExp[] {
return [/loader\.php\?sid=lottery/];
}
constructor( constructor(
private readonly mathUtils: MathUtils, private readonly mathUtils: MathUtils,
private readonly commonUtils: CommonUtils, private readonly commonUtils: CommonUtils,
private readonly fetchUtils: FetchUtils, private readonly fetchUtils: FetchUtils,
private readonly infoUtils: InfoUtils, private readonly infoUtils: InfoUtils,
private readonly logger: Logger,
) { ) {
} }

50
src/ts/feature/MapItem.ts Normal file
View File

@ -0,0 +1,50 @@
import IFeature from "../man/IFeature";
import ClassName from "../container/ClassName";
import { Injectable } from "../container/Injectable";
import TornStyleBlock from "../class/utils/TornStyleBlock";
import TornStyleSwitch from "../class/utils/TornStyleSwitch";
import cityFinder from "../func/module/cityFinder";
import LocalConfigWrapper from "../class/LocalConfigWrapper";
@ClassName('MapItem')
@Injectable()
export default class MapItem implements IFeature {
constructor(
private readonly localConfigWrapper: LocalConfigWrapper
) {
}
description(): string {
return "捡垃圾助手";
}
iStart(): void | Promise<void> {
this.start()
}
urlExcludes(): RegExp[] {
return [];
}
urlIncludes(): RegExp[] {
return [/city\.php/];
}
start() {
if (this.localConfigWrapper.config.cityFinder) {
let _base = new TornStyleBlock('芜湖助手').insert2Dom();
let reloadSwitch = new TornStyleSwitch('解决一直转圈(加载中)的问题');
reloadSwitch.getInput().checked = this.localConfigWrapper.config.SolveGoogleScriptPendingIssue;
_base.append(reloadSwitch.getBase()).insert2Dom();
reloadSwitch.getInput().addEventListener('change', () => {
if (reloadSwitch.getInput().checked) window.location.replace(window.location.href);
this.localConfigWrapper.config.SolveGoogleScriptPendingIssue = reloadSwitch.getInput().checked;
});
_base.append(document.createElement('br'));
cityFinder(_base);
}
}
}

View File

@ -0,0 +1,77 @@
import ClassName from "../container/ClassName";
import { Injectable } from "../container/Injectable";
import IFeature from "../man/IFeature";
import LocalConfigWrapper from "../class/LocalConfigWrapper";
import getTaskHint from "../func/translate/getTaskHint";
import { missionDict } from "../dictionary/translation";
@ClassName('MissionPageModifier')
@Injectable()
export default class MissionPageModifier implements IFeature {
constructor(
private readonly localConfigWrapper: LocalConfigWrapper
) {
}
description(): string {
return "页面快速crime";
}
iStart(): void | Promise<void> {
this.start()
}
urlExcludes(): RegExp[] {
return [];
}
urlIncludes(): RegExp[] {
return [/crimes\.php/];
}
start() {
const anchor = document.querySelector('.content-wrapper');
const OB = new MutationObserver(() => {
OB.disconnect();
trans();
OB.observe(anchor, {
characterData: true,
attributes: true,
subtree: true,
childList: true
});
});
const taskList = {};
const trans = () => {
$('ul#giver-tabs a.ui-tabs-anchor').each((i, e) => {
let $e = $(e);
if ($e.children().hasClass('mission-complete-icon')) {
taskList[i] = e.innerText.trim();
} else {
taskList[i] = $e.clone().children().remove().end().text().trim();
}
});
// 助手注入
$('div.max-height-fix.info').each((i, e) => {
let $e = $(e);
if ($e.find('.wh-translated').length !== 0) return;
$e.append(`<div class="wh-translated"><h6 style="color:green"><b>任务助手</b></h6><p>${ getTaskHint(taskList[i]) }</p></div>`);
});
// 任务目标
$('ul.tasks-list span.title-wrap').contents().each((i, e) => {
if (e.nodeType === 3) {
if (missionDict[e.nodeValue.trim()]) {
e.nodeValue = missionDict[e.nodeValue.trim()];
}
}
});
};
trans();
OB.observe(anchor, {
characterData: true,
attributes: true,
subtree: true,
childList: true
});
}
}

View File

@ -1,10 +1,13 @@
import CommonUtils from "../utils/CommonUtils"; import CommonUtils from "../class/utils/CommonUtils";
import Global from "../Global"; import Global from "../class/Global";
import Device from "../../enum/Device"; import Device from "../enum/Device";
import ClassName from "../../container/ClassName"; import ClassName from "../container/ClassName";
import { Injectable } from "../../container/Injectable"; import { Injectable } from "../container/Injectable";
import LocalConfigWrapper from "../LocalConfigWrapper"; import LocalConfigWrapper from "../class/LocalConfigWrapper";
import Logger from "../Logger"; import Logger from "../class/Logger";
import IFeature from "../man/IFeature";
import ATK_PAGE_REG from "./url/ATK_PAGE_REG";
import ALL_PAGE_REG from "./url/ALL_PAGE_REG";
/** /**
* ### * ###
@ -13,16 +16,32 @@ import Logger from "../Logger";
*/ */
@ClassName('SidebarHelper') @ClassName('SidebarHelper')
@Injectable() @Injectable()
export default class SidebarHelper { export default class SidebarHelper implements IFeature {
private readonly logger: Logger = Logger.factory(SidebarHelper)
description(): string {
return "边栏助手";
}
iStart(): void | Promise<void> {
this.init()
}
urlExcludes(): RegExp[] {
return [ATK_PAGE_REG];
}
private readonly sidebarRootNode: HTMLElement; private readonly sidebarRootNode: HTMLElement;
private readonly toggleBtn: HTMLButtonElement; private readonly toggleBtn: HTMLButtonElement;
private isHide: boolean; private isHide: boolean;
urlIncludes(): RegExp[] {
return [ALL_PAGE_REG];
}
constructor( constructor(
private readonly localConfigWrapper: LocalConfigWrapper, private readonly localConfigWrapper: LocalConfigWrapper,
private readonly global: Global, private readonly global: Global,
private readonly logger: Logger,
) { ) {
this.sidebarRootNode = document.querySelector('#sidebarroot'); this.sidebarRootNode = document.querySelector('#sidebarroot');
this.toggleBtn = document.createElement('button'); this.toggleBtn = document.createElement('button');
@ -35,7 +54,7 @@ export default class SidebarHelper {
this.initToggleBtn(); this.initToggleBtn();
this.barRedirect(); this.barRedirect();
} else { } else {
this.logger.warn('[SidebarHelper] 页面未开启边栏,边栏助手退出'); this.logger.warn('页面未开启边栏,边栏助手退出');
} }
} }
@ -73,10 +92,10 @@ export default class SidebarHelper {
// 4条转跳 // 4条转跳
private barRedirect(): void { private barRedirect(): void {
if (this.localConfigWrapper.config.barsRedirect) { if (this.localConfigWrapper.config.barsRedirect) {
const eb = document.getElementById('barEnergy') as HTMLAnchorElement; const eb = document.querySelector<HTMLAnchorElement>('#barEnergy');
const nb = document.getElementById('barNerve') as HTMLAnchorElement; const nb = document.querySelector<HTMLAnchorElement>('#barNerve');
const hb = document.getElementById('barHappy') as HTMLAnchorElement; const hb = document.querySelector<HTMLAnchorElement>('#barHappy');
const lb = document.getElementById('barLife') as HTMLAnchorElement; const lb = document.querySelector<HTMLAnchorElement>('#barLife');
if (eb) { if (eb) {
eb.addEventListener('click', () => location.href = '/gym.php'); eb.addEventListener('click', () => location.href = '/gym.php');
eb.href = '/gym.php'; eb.href = '/gym.php';

View File

@ -1,15 +1,36 @@
import TornStyleBlock from "../utils/TornStyleBlock"; import TornStyleBlock from "../class/utils/TornStyleBlock";
import TornStyleSwitch from "../utils/TornStyleSwitch"; import TornStyleSwitch from "../class/utils/TornStyleSwitch";
import { Injectable } from "../../container/Injectable"; import { Injectable } from "../container/Injectable";
import ClassName from "../../container/ClassName"; import ClassName from "../container/ClassName";
import LocalConfigWrapper from "../LocalConfigWrapper"; import LocalConfigWrapper from "../class/LocalConfigWrapper";
import IFeature from "../man/IFeature";
@Injectable() @Injectable()
@ClassName('StackHelper') @ClassName('StackHelper')
export default class StackHelper { export default class StackHelper implements IFeature {
constructor( constructor(
private readonly localConfigWrapper: LocalConfigWrapper, private readonly localConfigWrapper: LocalConfigWrapper,
) { ) {
}
description(): string {
return "叠e助手";
}
iStart(): void | Promise<void> {
this.start()
}
urlExcludes(): RegExp[] {
return [];
}
urlIncludes(): RegExp[] {
return [/gym\.php/];
}
start() {
let block = new TornStyleBlock('叠E保护').insert2Dom(); let block = new TornStyleBlock('叠E保护').insert2Dom();
let switcher = new TornStyleSwitch('启用'); let switcher = new TornStyleSwitch('启用');
let input = switcher.getInput(); let input = switcher.getInput();
@ -23,5 +44,4 @@ export default class StackHelper {
this.localConfigWrapper.config.SEProtect = target.checked; this.localConfigWrapper.config.SEProtect = target.checked;
}; };
} }
} }

View File

@ -1,18 +1,20 @@
import titleTrans from "../translate/titleTrans"; import titleTrans from "../func/translate/titleTrans";
import contentTitleLinksTrans from "../translate/contentTitleLinksTrans"; import contentTitleLinksTrans from "../func/translate/contentTitleLinksTrans";
import Device from "../../enum/Device"; import Device from "../enum/Device";
import ActionButtonUtils from "../../class/utils/ActionButtonUtils"; import ActionButtonUtils from "../class/utils/ActionButtonUtils";
import CommonUtils from "../../class/utils/CommonUtils"; import CommonUtils from "../class/utils/CommonUtils";
import TRAVEL_ALARM_CSS from "../../../static/css/travel_alarm.module.css"; import TRAVEL_ALARM_CSS from "../../static/css/travel_alarm.module.css";
import TRAVEL_ALARM_HTML from "../../../static/html/travel_alarm.html"; import TRAVEL_ALARM_HTML from "../../static/html/travel_alarm.html";
import TornStyleBlock from "../../class/utils/TornStyleBlock"; import TornStyleBlock from "../class/utils/TornStyleBlock";
import QuickFlyBtnHandler from "../../class/handler/QuickFlyBtnHandler"; import QuickFlyBtnHandler from "../class/handler/QuickFlyBtnHandler";
import TRAVEL_STATE from "../../enum/TravelState"; import TRAVEL_STATE from "../enum/TravelState";
import Global from "../../class/Global"; import Global from "../class/Global";
import ClassName from "../../container/ClassName"; import ClassName from "../container/ClassName";
import { Injectable } from "../../container/Injectable"; import { Injectable } from "../container/Injectable";
import LocalConfigWrapper from "../../class/LocalConfigWrapper"; import LocalConfigWrapper from "../class/LocalConfigWrapper";
import MsgWrapper from "../../class/utils/MsgWrapper"; import MsgWrapper from "../class/utils/MsgWrapper";
import IFeature from "../man/IFeature";
import INDEX_PAGE_REG from "./url/INDEX_PAGE_REG";
/** /**
* *
@ -24,7 +26,23 @@ import MsgWrapper from "../../class/utils/MsgWrapper";
*/ */
@ClassName('TravelHelper') @ClassName('TravelHelper')
@Injectable() @Injectable()
export default class TravelHelper { export default class TravelHelper implements IFeature {
description(): string {
return "飞行助手";
}
iStart(): void | Promise<void> {
this.init()
}
urlExcludes(): RegExp[] {
return [];
}
urlIncludes(): RegExp[] {
return [INDEX_PAGE_REG, /travelagency\.php/];
}
constructor( constructor(
private readonly global: Global, private readonly global: Global,
private readonly commonUtils: CommonUtils, private readonly commonUtils: CommonUtils,
@ -153,7 +171,7 @@ export default class TravelHelper {
// 响铃的方法 // 响铃的方法
let audio_play_handle = () => { let audio_play_handle = () => {
if (user_stop_alert) { if (user_stop_alert) {
clearInterval(audio_play_id); window.clearInterval(audio_play_id);
audio_play_id = null; audio_play_id = null;
return; return;
} }
@ -194,7 +212,7 @@ export default class TravelHelper {
} else { } else {
// flying_status.innerHTML = `飞行中...`; // flying_status.innerHTML = `飞行中...`;
if (wh_trv_alarm.enable) { if (wh_trv_alarm.enable) {
clearInterval(audio_play_id); window.clearInterval(audio_play_id);
audio_play_id = null; audio_play_id = null;
stop_node.parentElement.classList.add('wh-trv-alarm-stop-hide'); stop_node.parentElement.classList.add('wh-trv-alarm-stop-hide');
} }
@ -266,6 +284,7 @@ export default class TravelHelper {
}); });
const trans = () => { const trans = () => {
// 当前能量e // 当前能量e
// @ts-ignore
const energyBarStr = $('#barEnergy p[class^="bar-value__"]').text().trim(); const energyBarStr = $('#barEnergy p[class^="bar-value__"]').text().trim();
const [curE, maxE] = energyBarStr.split('/').length === 2 const [curE, maxE] = energyBarStr.split('/').length === 2
? [parseInt(energyBarStr.split('/')[0]), parseInt(energyBarStr.split('/')[1])] ? [parseInt(energyBarStr.split('/')[0]), parseInt(energyBarStr.split('/')[1])]
@ -274,6 +293,7 @@ export default class TravelHelper {
const fullEnergyTime = !(isNaN(curE) || isNaN(maxE)) ? (maxE - 5 - curE) / 5 * incTime const fullEnergyTime = !(isNaN(curE) || isNaN(maxE)) ? (maxE - 5 - curE) / 5 * incTime
+ (incTime - new Date().getMinutes() % incTime) : NaN; + (incTime - new Date().getMinutes() % incTime) : NaN;
// 起飞前提示 // 起飞前提示
// @ts-ignore
$('.travel-confirm .travel-question .q-wrap span:nth-of-type(2)').each((i, e) => { $('.travel-confirm .travel-question .q-wrap span:nth-of-type(2)').each((i, e) => {
if (isNaN(fullEnergyTime)) return; if (isNaN(fullEnergyTime)) return;
const spl = e.innerText.trim().split(' '); const spl = e.innerText.trim().split(' ');
@ -304,10 +324,6 @@ export default class TravelHelper {
} }
} }
/** TODO */
inTravelPage() {
}
async doTravelBack(): Promise<void> { async doTravelBack(): Promise<void> {
if (typeof window['getAction'] !== 'function') return; if (typeof window['getAction'] !== 'function') return;
let backHomeAction = function (): Promise<string> { let backHomeAction = function (): Promise<string> {

View File

@ -1,22 +1,41 @@
import CommonUtils from "../utils/CommonUtils"; import CommonUtils from "../class/utils/CommonUtils";
import UserScriptEngine from "../../enum/UserScriptEngine"; import UserScriptEngine from "../enum/UserScriptEngine";
import Popup from "../utils/Popup"; import Popup from "../class/utils/Popup";
import STOCK_IMG_HTML from "../../../static/html/stock_img.html"; import STOCK_IMG_HTML from "../../static/html/stock_img.html";
import WindowActiveState from "./WindowActiveState"; import WindowActiveState from "../class/action/WindowActiveState";
import { Injectable } from "../../container/Injectable"; import { Injectable } from "../container/Injectable";
import ClassName from "../../container/ClassName"; import ClassName from "../container/ClassName";
import Logger from "../Logger"; import Logger from "../class/Logger";
import { InjectionKey } from "vue"; import IFeature from "../man/IFeature";
import ATK_PAGE_REG from "./url/ATK_PAGE_REG";
import ALL_PAGE_REG from "./url/ALL_PAGE_REG";
@Injectable() @Injectable()
@ClassName('TravelItem') @ClassName('TravelItem')
export default class TravelItem { export default class TravelItem implements IFeature {
private readonly logger: Logger = Logger.factory(TravelItem)
description(): string {
return "海外货物存量静默获取";
}
iStart(): void | Promise<void> {
this.init()
}
urlExcludes(): RegExp[] {
return [ATK_PAGE_REG];
}
private readonly apiUrl: string = 'https://yata.yt/api/v1/travel/export/'; private readonly apiUrl: string = 'https://yata.yt/api/v1/travel/export/';
private foreignStockInfo: any = null; private foreignStockInfo: any = null;
urlIncludes(): RegExp[] {
return [ALL_PAGE_REG];
}
public constructor( public constructor(
private readonly windowActiveState: WindowActiveState, private readonly windowActiveState: WindowActiveState,
private readonly logger: Logger,
private readonly commonUtils: CommonUtils, private readonly commonUtils: CommonUtils,
) { ) {
} }
@ -174,4 +193,4 @@ export default class TravelItem {
} }
} }
export const TravelItemKey = Symbol('TravelItemKey') as InjectionKey<TravelItem> // export const TravelItemKey = Symbol('TravelItemKey') as InjectionKey<TravelItem>

View File

@ -0,0 +1,2 @@
const ALL_PAGE_REG = /^/
export default ALL_PAGE_REG

View File

@ -0,0 +1,2 @@
const ATK_PAGE_REG = /\/loader.php\?sid=attack&user2ID=/
export default ATK_PAGE_REG

View File

@ -0,0 +1,2 @@
const INDEX_PAGE_REG = /index\.php/
export default INDEX_PAGE_REG

View File

@ -1,5 +1,6 @@
import Popup from "./class/utils/Popup"; import Popup from "./class/utils/Popup";
import { reactive } from 'vue'
import IFeatureResult from "./man/IFeatureResult";
type ResponseHandlers = ((url: string, responseBody: { type ResponseHandlers = ((url: string, responseBody: {
json: unknown, json: unknown,
@ -20,11 +21,14 @@ class GlobVars {
responseHandlers: ResponseHandlers = []; responseHandlers: ResponseHandlers = [];
version = '$$WUHU_DEV_VERSION$$'; version = '$$WUHU_DEV_VERSION$$';
popup_node: MyHTMLElement | Popup = null; popup_node: MyHTMLElement | Popup = null;
actionList: {
txt: string,
func: (ev: Event) => void
}[] = [];
loadTime: number = 0; loadTime: number = 0;
buttons = reactive<FloatButtonData[]>([])
featureStatus = reactive<IFeatureResult[]>([])
} }
export default new GlobVars(); export default new GlobVars();
interface FloatButtonData {
txt: string,
func: (ev: Event) => void
}

View File

@ -1,13 +1,15 @@
import "reflect-metadata"; import "reflect-metadata";
import { Container } from "./container/Container";
import App from "./App"; import App from "./App";
import Logger from "./class/Logger"; import EntryPoint from "./starter/EntryPoint";
import EntryPoint from "./class/provider/EntryPoint"; import { Injectable } from "./container/Injectable";
import ClassName from "./container/ClassName";
import { Container } from "./container/Container";
@EntryPoint @EntryPoint
class _ { @ClassName('Index')
static main() { @Injectable()
Container.setLogger(new Logger()); class Index {
Container.factory(App).run(); public static main() {
Container.factory(App).run()
} }
} }

View File

@ -1,7 +1,7 @@
import Device from "../enum/Device"; import Device from "../enum/Device";
import { BeerMonitorLoop } from "../class/action/BuyBeerHelper"; import { BeerMonitorLoop } from "../feature/BuyBeerHelper";
import Popup from "../class/utils/Popup"; import Popup from "../class/utils/Popup";
import TravelItem from "../class/action/TravelItem"; import TravelItem from "../feature/TravelItem";
export default interface IGlobal { export default interface IGlobal {
GM_xmlhttpRequest?: Function; GM_xmlhttpRequest?: Function;

116
src/ts/man/FeatureMan.ts Normal file
View File

@ -0,0 +1,116 @@
import IFeature from "./IFeature"
import { Container } from "../container/Container"
import ClassName, { GetClassName } from "../container/ClassName"
import Atk from "../feature/Atk"
import { Injectable } from "../container/Injectable"
import Logger from "../class/Logger"
import BuyBeerHelper from "../feature/BuyBeerHelper"
import SidebarHelper from "../feature/SidebarHelper"
import TravelItem from "../feature/TravelItem"
import TravelHelper from "../feature/TravelHelper"
import CompanyHelper from "../feature/CompanyHelper"
import IconHelper from "../feature/IconHelper"
import MapItem from "../feature/MapItem"
import PTHelper from "../class/action/PTHelper"
import StackHelper from "../feature/StackHelper"
import XZMZ from "../class/action/XZMZ"
import BeerShopModifier from "../feature/BeerShopModifier"
import CrimePageModifier from "../feature/CrimePageModifier"
import ProfileHelper from "../class/action/ProfileHelper"
import ChristmasTown from "../feature/ChristmasTown"
import LotteryHelper from "../feature/LotteryHelper"
import SlotsHelper from "../class/action/SlotsHelper"
import SearchHelper from "../class/action/SearchHelper"
import { WHIntervalLoader } from "../monitor/WHIntervalLoader"
import IFeatureResult from "./IFeatureResult"
import FeatureStatus from "./const/FeatureStatus"
import globVars from "../globVars";
@ClassName('FeatureMan')
@Injectable()
export default class FeatureMan {
private readonly features: ClassType<IFeature>[] = [
/* 通配 */
BuyBeerHelper,
SidebarHelper,
TravelItem,
CompanyHelper,
IconHelper,
WHIntervalLoader,
/* 页面匹配 */
Atk,
TravelHelper,
MapItem,
PTHelper,
StackHelper,
XZMZ,
BeerShopModifier,
CrimePageModifier,
ProfileHelper,
ChristmasTown,
LotteryHelper,
SlotsHelper,
SearchHelper,
]
private result: IFeatureResult[] = null
private readonly logger = Logger.factory(FeatureMan)
async fStart() {
const manResult: IFeatureResult[] = []
for (let i = 0; i < this.features.length; i++) {
const className = GetClassName(this.features[i])
const instant = Container.factory(this.features[i])
const description = instant.description()
const urlPath = location.href.replace(/^.+\/\/.+?\/(?!\/)?/, '/')
let status = FeatureStatus.ADDED
let isMatch = false
const urlIncludes = instant.urlIncludes()
let load = 0
for (let j = 0; j < urlIncludes.length; j++) {
if (urlIncludes[j].test(urlPath)) {
isMatch = true
const urlExcludes = instant.urlExcludes() ?? []
for (let k = 0; k < urlExcludes.length; k++) {
if (urlExcludes[k].test(urlPath)) {
isMatch = false
status = FeatureStatus.EXCLUDED
break
}
}
break
}
}
if (isMatch) {
try {
const start = performance.now()
let run = instant.iStart()
if (run instanceof Promise) {
run = await run
}
status = FeatureStatus.RUNNING
load = ((performance.now() - start) * 10 | 0) / 10
} catch (e) {
this.logger.error(e.message)
status = FeatureStatus.EXCEPTION
}
}
// else {
// status = FeatureStatus.EXCLUDED
// }
const result = {
desc: description,
status: status,
clazz: className,
load
}
manResult.push(result)
globVars.featureStatus.push(result)
}
this.result = manResult
}
printTable() {
console.table(this.result)
this.logger.info(this.result)
}
}

15
src/ts/man/IFeature.ts Normal file
View File

@ -0,0 +1,15 @@
export default interface IFeature {
iStart(): void | Promise<void>
/**
* urlnull
*/
urlIncludes(): RegExp[]
/**
* url
*/
urlExcludes(): RegExp[]
description(): string
}

View File

@ -0,0 +1,8 @@
import FeatureStatus from "./const/FeatureStatus";
export default interface IFeatureResult {
desc: string
status: FeatureStatus
clazz: string
load: number
}

View File

@ -0,0 +1,8 @@
enum FeatureStatus {
ADDED = '已添加',
RUNNING = '正常',
EXCLUDED = '页面排除',
EXCEPTION = '异常',
}
export default FeatureStatus

View File

@ -1,11 +1,11 @@
import IntervalType from "./IntervalUnit"; import IntervalType from "./WHIntervalLoader";
import ClassName from "../../container/ClassName"; import ClassName from "../container/ClassName";
import IntervalSwitch from "./IntervalSwitch"; import IntervalSwitch from "./IntervalSwitch";
import { SWITCHER } from "./SWITCHER"; import { SWITCHER } from "./SWITCHER";
import getSidebarData from "../../func/utils/getSidebarData"; import getSidebarData from "../func/utils/getSidebarData";
import { Container } from "../../container/Container"; import { Container } from "../container/Container";
import MsgWrapper from "../utils/MsgWrapper"; import MsgWrapper from "../class/utils/MsgWrapper";
import LocalConfigWrapper from "../LocalConfigWrapper"; import LocalConfigWrapper from "../class/LocalConfigWrapper";
@ClassName('DrugCDMonitor') @ClassName('DrugCDMonitor')
class DrugCDMonitor implements IntervalType { class DrugCDMonitor implements IntervalType {

View File

@ -1,5 +1,5 @@
import { GetClassName } from "../../container/ClassName"; import { GetClassName } from "../container/ClassName";
import IntervalType from "./IntervalUnit"; import IntervalType from "./WHIntervalLoader";
import IntervalSwitch from "./IntervalSwitch"; import IntervalSwitch from "./IntervalSwitch";
export function SWITCHER(self: IntervalType, clazz: new () => IntervalType, s: IntervalSwitch) { export function SWITCHER(self: IntervalType, clazz: new () => IntervalType, s: IntervalSwitch) {

View File

@ -0,0 +1,57 @@
/**
*
*/
import drugCDMonitor from "./DrugCDMonitor";
import { Injectable } from "../container/Injectable";
import ClassName from "../container/ClassName";
import LocalConfigWrapper from "../class/LocalConfigWrapper";
import IntervalSwitch from "./IntervalSwitch";
import IFeature from "../man/IFeature";
import ATK_PAGE_REG from "../feature/url/ATK_PAGE_REG";
import ALL_PAGE_REG from "../feature/url/ALL_PAGE_REG";
export default interface IntervalType {
handler: () => void
switcher: (s: IntervalSwitch) => void
getId: () => number
setId: (id: number) => void
getMs: () => number
setMs: (ms: number) => void
}
const intervalUnits: { [key: string]: IntervalType } = {
drugCDMonitor,
}
@Injectable()
@ClassName('WHIntervalLoader')
export class WHIntervalLoader implements IFeature {
description(): string {
return "新监控模块";
}
iStart(): void | Promise<void> {
this.init()
}
urlExcludes(): RegExp[] {
return [ATK_PAGE_REG];
}
urlIncludes(): RegExp[] {
return [ALL_PAGE_REG];
}
constructor(
private readonly localConfigWrapper: LocalConfigWrapper,
) {
}
init() {
const list = this.localConfigWrapper.config.monitorOn
for (let i = 0; i < list.length; i++) {
intervalUnits[list[i]].switcher(IntervalSwitch.ON)
}
}
}

View File

@ -1,32 +1,30 @@
import "reflect-metadata"; import "reflect-metadata";
import { Container } from "../../container/Container"; import Logger from "../class/Logger";
import Logger from "../Logger"; import globVars from "../globVars";
import globVars from "../../globVars"; import { Container } from "../container/Container";
export default function EntryPoint(T: { main: () => void }) { export default function EntryPoint(Index: ClassType<{}> & { main: () => void }) {
const logger = Logger.factory(Index);
if (window.WHTRANS) { if (window.WHTRANS) {
console.log('退出, 已运行次数' + window.WHTRANS) logger.warn('退出, 已运行次数' + window.WHTRANS)
} else { } else {
window.WHTRANS = window.WHTRANS === undefined ? 1 : window.WHTRANS++; window.WHTRANS = window.WHTRANS === undefined ? 1 : window.WHTRANS++;
const logger = Container.factory(Logger);
let started = false; let started = false;
const starter = () => { const starter = () => {
console.log('starter init...'); console.log('starter init...');
let started = performance.now(); let started = performance.now();
try { try {
T.main(); Container.setLogger(Container.factory(Logger))
Index.main()
} catch (e) { } catch (e) {
logger.error('[Starter]加载出错信息: ' + e.stack || e.message); logger.error('加载出错: ' + e.stack || e.message);
} }
let runTime: number = (performance.now() - started) | 0; let runTime: number = (performance.now() - started) | 0;
globVars.loadTime = runTime; globVars.loadTime = runTime;
logger.info(`芜湖脚本完成加载, 耗时${ runTime }ms`); logger.info(`芜湖脚本完成加载, 耗时${ runTime }ms`);
// if (ZhongIcon.ZhongNode && ZhongIcon.ZhongNode.initTimer)
// ZhongIcon.ZhongNode.initTimer.innerHTML = `加载时间 ${ runTime }ms`;
}; };
const evHandler = () => { const evHandler = () => {
// console.log('document.readyState: ' + document.readyState);
if (!started && (document.readyState === 'complete' || document.readyState === 'interactive')) { if (!started && (document.readyState === 'complete' || document.readyState === 'interactive')) {
document.removeEventListener('readystatechange', evHandler); document.removeEventListener('readystatechange', evHandler);
started = !started; started = !started;

View File

@ -4,7 +4,6 @@ import ClassName from "../container/ClassName";
import Debug from "../class/provider/Debug"; import Debug from "../class/provider/Debug";
import "reflect-metadata"; import "reflect-metadata";
import { Injectable } from "../container/Injectable"; import { Injectable } from "../container/Injectable";
import { ButtonHandler } from "../class/provider/ButtonHandler";
import { Container } from "../container/Container"; import { Container } from "../container/Container";
import NetHighLvlWrapper from "../class/utils/NetHighLvlWrapper"; import NetHighLvlWrapper from "../class/utils/NetHighLvlWrapper";
import Logger from "../class/Logger"; import Logger from "../class/Logger";
@ -12,7 +11,6 @@ import QuickGymTrain from "../class/action/QuickGymTrain";
import LocalConfigWrapper from "../class/LocalConfigWrapper"; import LocalConfigWrapper from "../class/LocalConfigWrapper";
import { ElMessage } from "element-plus"; import { ElMessage } from "element-plus";
@ButtonHandler
@ClassName('Test') @ClassName('Test')
@Injectable() @Injectable()
class Test { class Test {

View File

@ -6,7 +6,7 @@
<MoonNight/> <MoonNight/>
</el-icon> </el-icon>
</el-button> </el-button>
<el-button v-for="item in _globVars.actionList" @click="item.func">{{ item.txt }}</el-button> <el-button v-for="item in globVars.buttons" @click="item.func">{{ item.txt }}</el-button>
<el-button v-if="editableTabs.length > 0" circle @click="showDrawer"> <el-button v-if="editableTabs.length > 0" circle @click="showDrawer">
<el-badge :value="editableTabs.length" type="primary"> <el-badge :value="editableTabs.length" type="primary">
<el-icon> <el-icon>
@ -102,7 +102,7 @@
<el-row> <el-row>
<el-col :span="24"> <el-col :span="24">
<el-tooltip content="更新?" placement="bottom-start"> <el-tooltip content="更新?" placement="bottom-start">
<el-button link @click="menuClick({ title: '更新', template: UpdateDate })">芜湖助手 <el-button link @click="menuClick({ title: '关于助手', template: UpdateDate })">芜湖助手
<el-icon> <el-icon>
<Refresh/> <Refresh/>
</el-icon> </el-icon>
@ -131,42 +131,44 @@
</div> </div>
</el-drawer> </el-drawer>
</el-config-provider> </el-config-provider>
<!-- <div id="wh123">{{ sessionObject }}</div>-->
<!-- <div id="wh1234">{{ session }}</div>-->
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { CopyDocument, MoonNight, Refresh } from "@element-plus/icons-vue"; import { CopyDocument, MoonNight, Refresh } from "@element-plus/icons-vue"
import { ElMessage, ElMessageBox } from "element-plus"; import { ElMessage, ElMessageBox } from "element-plus"
import { Component, inject, onMounted, ref, shallowRef, triggerRef } from 'vue'; import { Component, inject, onMounted, ref, shallowRef, triggerRef } from 'vue'
import { LoggerKey } from "../ts/class/Logger"; import { LoggerKey } from "../ts/class/Logger"
import { QuickGymTrainKey } from "../ts/class/action/QuickGymTrain"; import { QuickGymTrainKey } from "../ts/class/action/QuickGymTrain"
import { QuickFlyBtnHandlerKey } from "../ts/class/handler/QuickFlyBtnHandler"; import { QuickFlyBtnHandlerKey } from "../ts/class/handler/QuickFlyBtnHandler"
import SettingsHandler from "../ts/class/handler/SettingsHandler"; import SettingsHandler from "../ts/class/handler/SettingsHandler"
import { BATTLE_STAT } from "../ts/class/utils/NetHighLvlWrapper"; import { BATTLE_STAT } from "../ts/class/utils/NetHighLvlWrapper"
import adHelper from "../ts/func/module/adHelper"; import adHelper from "../ts/func/module/adHelper"
import safeKeeper from "../ts/func/module/safeKeeper"; import safeKeeper from "../ts/func/module/safeKeeper"
import useItem from "../ts/func/utils/useItem"; import useItem from "../ts/func/utils/useItem"
import globVars from "../ts/globVars"; import globVars from "../ts/globVars"
import AutoLoginForm from "./AutoLoginForm.vue"; import AutoLoginForm from "./AutoLoginForm.vue"
import CityUItems from "./CityUItems.vue"; import CityUItems from "./CityUItems.vue"
import CompanyWithdraw from "./CompanyWithdraw.vue"; import CompanyWithdraw from "./CompanyWithdraw.vue"
import EventsViewer from "./EventsViewer.vue"; import EventsViewer from "./EventsViewer.vue"
import ForeignStock from "./ForeignStock.vue"; import ForeignStock from "./ForeignStock.vue"
import InventoryView from "./InventoryView.vue"; import InventoryView from "./InventoryView.vue"
import MarketHelper from "./MarketHelper.vue"; import MarketHelper from "./MarketHelper.vue"
import PTMarketView from "./PTMarketView.vue"; import PTMarketView from "./PTMarketView.vue"
import QuickCrime from "./QuickCrime.vue"; import QuickCrime from "./QuickCrime.vue"
import UpdateDate from "./UpdateScript.vue"; import UpdateDate from "./UpdateScript.vue"
import VirusProgramming from "./VirusProgramming.vue"; import VirusProgramming from "./VirusProgramming.vue"
import getSidebarData from "../ts/func/utils/getSidebarData"; import getSidebarData from "../ts/func/utils/getSidebarData"
import MonitorMgrView from "./MonitorMgrView.vue"; import MonitorMgrView from "./MonitorMgrView.vue"
import ChangeLogView from "./ChangeLogView.vue"; import ChangeLogView from "./ChangeLogView.vue"
const logger = inject(LoggerKey); const logger = inject(LoggerKey)
const quickGymTrain = inject(QuickGymTrainKey); const quickGymTrain = inject(QuickGymTrainKey)
const quickFlyBtnHandler = inject(QuickFlyBtnHandlerKey); const quickFlyBtnHandler = inject(QuickFlyBtnHandlerKey)
type MenuItem = { title: string, template?: Component, handler?: Function }; type MenuItem = { title: string, template?: Component, handler?: Function }
const menuItemList: MenuItem[] = [ const menuItemList: MenuItem[] = [
{ {
title: '💊 吃 XAN', title: '💊 吃 XAN',
@ -290,16 +292,16 @@ const menuItemList: MenuItem[] = [
SettingsHandler.clickFunc() SettingsHandler.clickFunc()
}, },
}, },
]; ]
const drawer = ref(false); const drawer = ref(false)
const isMobilePhone = ref(false); const isMobilePhone = ref(false)
const documentHeight = ref(0); const documentHeight = ref(0)
const expanded = ref(false); const expanded = ref(false)
const _globVars = ref(globVars); const _globVars = ref(globVars)
logger.info({ _globVars })
// tabs // tabs
const editableTabsValue = ref(''); const editableTabsValue = ref('')
const editableTabs = shallowRef([]); const editableTabs = shallowRef([])
// fast travel // fast travel
const travelData = [ const travelData = [
@ -314,7 +316,7 @@ const travelData = [
{ cName: "🇨🇳 祖国", index: 8 }, { cName: "🇨🇳 祖国", index: 8 },
{ cName: "🇦🇪 阿联酋 (UAE)", index: 9 }, { cName: "🇦🇪 阿联酋 (UAE)", index: 9 },
{ cName: "🇿🇦 南非", index: 10 }, { cName: "🇿🇦 南非", index: 10 },
]; ]
const menuClick = (menuItem: MenuItem) => { const menuClick = (menuItem: MenuItem) => {
if (menuItem.handler) { if (menuItem.handler) {
@ -323,7 +325,7 @@ const menuClick = (menuItem: MenuItem) => {
drawer.value = true; drawer.value = true;
addTab(menuItem); addTab(menuItem);
} }
}; }
const showDrawer = () => { const showDrawer = () => {
if (editableTabs.value.length < 1) { if (editableTabs.value.length < 1) {
@ -381,10 +383,6 @@ const removeTab = (targetName: string) => {
} }
}; };
// const tabClick = (pane: TabsPaneContext) => {
// drawerTitle.value = <string>pane.paneName;
// }
const travelConfirm = (destIndex: number, typeIndex: number) => { const travelConfirm = (destIndex: number, typeIndex: number) => {
const destName = travelData[destIndex].cName; const destName = travelData[destIndex].cName;
const typeName = ['普通飞机', 'PI飞机', '股票飞机', '商务飞机(机票或内衣店)'][typeIndex]; const typeName = ['普通飞机', 'PI飞机', '股票飞机', '商务飞机(机票或内衣店)'][typeIndex];
@ -469,6 +467,15 @@ onMounted(() => {
} }
documentHeight.value = document.documentElement.scrollHeight; documentHeight.value = document.documentElement.scrollHeight;
}); });
// watch(_globVars, (_globVars, pre) => {
// logger.info({ _globVars, pre })
// _buttons.value = []
// let keys = Object(globVars.buttons).keys()
// for (let i = 0; i < keys.length; i++) {
// _buttons.value.push(globVars.buttons[keys[i]])
// }
// }, { deep: true })
</script> </script>
<style scoped> <style scoped>

View File

@ -14,11 +14,12 @@
import { CommonUtilsKey } from "../ts/class/utils/CommonUtils"; import { CommonUtilsKey } from "../ts/class/utils/CommonUtils";
import { inject, onMounted, ref } from "vue"; import { inject, onMounted, ref } from "vue";
import UserScriptEngine from "../ts/enum/UserScriptEngine.js"; import UserScriptEngine from "../ts/enum/UserScriptEngine.js";
import { TravelItemKey } from "../ts/class/action/TravelItem"; import TravelItem from "../ts/feature/TravelItem";
import { LoggerKey } from "../ts/class/Logger"; import { LoggerKey } from "../ts/class/Logger";
import { Container } from "../ts/container/Container";
const commonUtils = inject(CommonUtilsKey); const commonUtils = inject(CommonUtilsKey);
const travelItem = inject(TravelItemKey); const travelItem = Container.factory(TravelItem)
const logger = inject(LoggerKey); const logger = inject(LoggerKey);
const loading = ref(true); const loading = ref(true);
const staticImageSrc = 'https://jjins.github.io/t2i/stock.png?' + Date.now(); const staticImageSrc = 'https://jjins.github.io/t2i/stock.png?' + Date.now();

View File

@ -23,8 +23,8 @@
<script lang="ts" setup> <script lang="ts" setup>
import { onMounted, ref, watch } from "vue"; import { onMounted, ref, watch } from "vue";
import drugCDMonitor from "../ts/class/interval/DrugCDMonitor"; import drugCDMonitor from "../ts/monitor/DrugCDMonitor";
import IntervalSwitch from "../ts/class/interval/IntervalSwitch"; import IntervalSwitch from "../ts/monitor/IntervalSwitch";
import { Container } from "../ts/container/Container"; import { Container } from "../ts/container/Container";
import LocalConfigWrapper from "../ts/class/LocalConfigWrapper"; import LocalConfigWrapper from "../ts/class/LocalConfigWrapper";
import Logger from "../ts/class/Logger"; import Logger from "../ts/class/Logger";

View File

@ -1,13 +1,15 @@
<script lang="ts" setup> <script lang="ts" setup>
import { ElMessage } from "element-plus"; import { ElMessage } from "element-plus";
import { inject, ref } from "vue"; import { inject, onMounted, ref } from "vue";
import { LoggerKey } from "../ts/class/Logger"; import { LoggerKey } from "../ts/class/Logger";
import CommonUtils from "../ts/class/utils/CommonUtils"; import CommonUtils from "../ts/class/utils/CommonUtils";
import globVars from "../ts/globVars";
const logger = inject(LoggerKey) const logger = inject(LoggerKey)
const loading = ref(false) const loading = ref(false)
const featureStatus = ref(globVars.featureStatus)
const now = performance.now() const now = performance.now()
const loadAndCopy = async () => { const loadAndCopy = async () => {
@ -31,9 +33,13 @@ const loadAndCopy = async () => {
loading.value = false loading.value = false
} }
onMounted(() => logger.info({ featureStatus }))
</script> </script>
<template> <template>
<el-card class="card" shadow="never">
<template #header>更新</template>
<el-space direction="vertical" style="width: 100%"> <el-space direction="vertical" style="width: 100%">
<el-row> <el-row>
<el-text>最新版本: <el-text>最新版本:
@ -74,10 +80,25 @@ const loadAndCopy = async () => {
<el-text>加载脚本后复制粘贴到用户脚本处</el-text> <el-text>加载脚本后复制粘贴到用户脚本处</el-text>
<el-button :loading="loading" @click="loadAndCopy">加载</el-button> <el-button :loading="loading" @click="loadAndCopy">加载</el-button>
</el-space> </el-space>
</el-card>
<el-card class="card" shadow="never">
<template #header>功能状况</template>
<el-table :data="featureStatus" border style="width: 100%">
<el-table-column label="描述" prop="desc"/>
<el-table-column label="状态" prop="status"/>
<el-table-column label="类名" prop="clazz"/>
<el-table-column label="加载(ms)" prop="load"/>
</el-table>
</el-card>
</template> </template>
<style scoped> <style scoped>
.el-image { .el-image {
width: 20px; width: 20px;
} }
.card {
margin-bottom: 10px;
}
</style> </style>