结构调整
This commit is contained in:
parent
1a9d58c2b3
commit
d707d983fb
@ -4,6 +4,14 @@
|
|||||||
|
|
||||||
# CHANGE
|
# CHANGE
|
||||||
|
|
||||||
|
## 0.8.5
|
||||||
|
|
||||||
|
2023年04月03日
|
||||||
|
|
||||||
|
### 修改
|
||||||
|
|
||||||
|
- 结构调整
|
||||||
|
|
||||||
## 0.8.4
|
## 0.8.4
|
||||||
|
|
||||||
2023年03月03日
|
2023年03月03日
|
||||||
|
|||||||
@ -1 +1,3 @@
|
|||||||
# 芜湖助手 Torncity 翻译插件
|
# 芜湖助手 Torncity 翻译插件
|
||||||
|
|
||||||
|
[CHANGELOG](CHANGELOG.md)
|
||||||
|
|||||||
4
package-lock.json
generated
4
package-lock.json
generated
@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "wuhu-torn-helper",
|
"name": "wuhu-torn-helper",
|
||||||
"version": "0.8.4",
|
"version": "0.8.5",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "wuhu-torn-helper",
|
"name": "wuhu-torn-helper",
|
||||||
"version": "0.8.4",
|
"version": "0.8.5",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@rollup/plugin-alias": "^4.0.3",
|
"@rollup/plugin-alias": "^4.0.3",
|
||||||
"@rollup/plugin-json": "^4.1.0",
|
"@rollup/plugin-json": "^4.1.0",
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "wuhu-torn-helper",
|
"name": "wuhu-torn-helper",
|
||||||
"version": "0.8.4",
|
"version": "0.8.5",
|
||||||
"description": "芜湖助手",
|
"description": "芜湖助手",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"release": "cross-env NODE_ENV=production rollup -c rollup-prod.config.js && node build.mjs",
|
"release": "cross-env NODE_ENV=production rollup -c rollup-prod.config.js && node build.mjs",
|
||||||
@ -28,5 +28,6 @@
|
|||||||
"tslib": "^2.4.0",
|
"tslib": "^2.4.0",
|
||||||
"typescript": "^4.8.3",
|
"typescript": "^4.8.3",
|
||||||
"vue": "^3.2.47"
|
"vue": "^3.2.47"
|
||||||
}
|
},
|
||||||
|
"type": "module"
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@ -1,5 +1,5 @@
|
|||||||
import terser from "@rollup/plugin-terser";
|
import terser from "@rollup/plugin-terser";
|
||||||
import rollupConfig from "./rollup.config";
|
import rollupConfig from "./rollup.config.js";
|
||||||
|
|
||||||
rollupConfig.plugins.push(terser());
|
rollupConfig.plugins.push(terser());
|
||||||
rollupConfig.output.file = 'dist/bundle.min.js';
|
rollupConfig.output.file = 'dist/bundle.min.js';
|
||||||
|
|||||||
@ -45,7 +45,9 @@ export default {
|
|||||||
}),
|
}),
|
||||||
// 根据环境更改vue源
|
// 根据环境更改vue源
|
||||||
alias({
|
alias({
|
||||||
entries: [{ find: 'vue', replacement: vuePath }]
|
entries: [
|
||||||
|
{ find: 'vue', replacement: vuePath },
|
||||||
|
]
|
||||||
}),
|
}),
|
||||||
// 为vue替换环境变量
|
// 为vue替换环境变量
|
||||||
replace({
|
replace({
|
||||||
|
|||||||
@ -9,7 +9,7 @@
|
|||||||
<li>走进蓝色的门(左二)[111,-60]</li>
|
<li>走进蓝色的门(左二)[111,-60]</li>
|
||||||
<li>过了蓝门后继续沿路向南</li>
|
<li>过了蓝门后继续沿路向南</li>
|
||||||
<li>然后沿路向东,再向南</li>
|
<li>然后沿路向东,再向南</li>
|
||||||
<li>再向东走,会看到“恐怖之家”,进入这栋楼[137, -84]</li>
|
<li>再向东走,会看到「恐怖之家」,进入这栋楼[137, -84]</li>
|
||||||
<li>向北走,进入洞口[164, -81]</li>
|
<li>向北走,进入洞口[164, -81]</li>
|
||||||
<li>穿过隧道到达另一端的洞穴口[142, -63],<b>避开所有怪物和NPC</b></li>
|
<li>穿过隧道到达另一端的洞穴口[142, -63],<b>避开所有怪物和NPC</b></li>
|
||||||
<li>来到另一个岛上</li>
|
<li>来到另一个岛上</li>
|
||||||
|
|||||||
59
src/ts/App.ts
Normal file
59
src/ts/App.ts
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
import WuhuBase from "./class/WuhuBase";
|
||||||
|
import WuHuTornHelper from "./class/WuhuTornHelper";
|
||||||
|
import ZhongIcon from "./class/ZhongIcon";
|
||||||
|
import { Common } from "./class/Common";
|
||||||
|
import UrlRouter from "./class/UrlRouter";
|
||||||
|
import translateMain from "./func/translate/translateMain";
|
||||||
|
import CommonUtils from "./class/utils/CommonUtils";
|
||||||
|
import LocalConfigWrapper from "./class/LocalConfigWrapper";
|
||||||
|
import ClassName from "./container/ClassName";
|
||||||
|
import { Injectable } from "./container/Injectable";
|
||||||
|
|
||||||
|
@ClassName('Application')
|
||||||
|
@Injectable()
|
||||||
|
export default class App {
|
||||||
|
constructor(
|
||||||
|
private readonly tornHelper: WuHuTornHelper,
|
||||||
|
private readonly icon: ZhongIcon,
|
||||||
|
private readonly common: Common,
|
||||||
|
private readonly urlRouter: UrlRouter,
|
||||||
|
private readonly configWrapper: LocalConfigWrapper,
|
||||||
|
private readonly utils: CommonUtils,
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public run(): void {
|
||||||
|
|
||||||
|
WuhuBase.conditionInterrupt();
|
||||||
|
|
||||||
|
// 初始化
|
||||||
|
this.tornHelper.init();
|
||||||
|
|
||||||
|
// 插件设置默认值
|
||||||
|
// WuhuConfig.setDefaults();
|
||||||
|
|
||||||
|
// 插件图标和设置菜单
|
||||||
|
this.icon.init();
|
||||||
|
|
||||||
|
let tmp = () => {
|
||||||
|
// 所有页面通用
|
||||||
|
try {
|
||||||
|
this.common.resolve(this.run);
|
||||||
|
} catch (e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
// URL匹配
|
||||||
|
this.urlRouter.resolve();
|
||||||
|
|
||||||
|
// 翻译
|
||||||
|
if (this.configWrapper.config.transEnable)
|
||||||
|
translateMain(window.location.href);
|
||||||
|
};
|
||||||
|
// TODO 临时检测jquery
|
||||||
|
if (typeof $ === "function") {
|
||||||
|
tmp();
|
||||||
|
} else {
|
||||||
|
this.utils.jQueryReady().then(() => tmp());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,12 +1,10 @@
|
|||||||
import depoHelper from "../func/module/depoHelper";
|
import depoHelper from "../func/module/depoHelper";
|
||||||
import travelHelper from "../func/module/travelHelper";
|
import TravelHelper from "../func/module/travelHelper";
|
||||||
import priceWatcherHandle from "../func/module/priceWatcherHandle";
|
import priceWatcherHandle from "../func/module/priceWatcherHandle";
|
||||||
import WuhuBase from "./WuhuBase";
|
|
||||||
import CompanyHelper from "./action/CompanyHelper";
|
import CompanyHelper from "./action/CompanyHelper";
|
||||||
import AttackHelper from "./action/AttackHelper";
|
import AttackHelper from "./action/AttackHelper";
|
||||||
import SidebarHelper from "./action/SidebarHelper";
|
import SidebarHelper from "./action/SidebarHelper";
|
||||||
import CommonUtils from "./utils/CommonUtils";
|
import CommonUtils from "./utils/CommonUtils";
|
||||||
import Log from "./Log";
|
|
||||||
import FetchUtils from "./utils/FetchUtils";
|
import FetchUtils from "./utils/FetchUtils";
|
||||||
import ZhongIcon from "./ZhongIcon";
|
import ZhongIcon from "./ZhongIcon";
|
||||||
import Alert from "./utils/Alert";
|
import Alert from "./utils/Alert";
|
||||||
@ -16,29 +14,51 @@ 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 BuyBeerHelper from "./action/BuyBeerHelper";
|
||||||
|
import ModuleLoader from "./ModuleLoader";
|
||||||
|
import TornPDAUtils from "./utils/TornPDAUtils";
|
||||||
|
import TravelItem from "./action/TravelItem";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 脚本不区分页面的通用功能入口
|
* 脚本不区分页面的通用功能入口
|
||||||
*/
|
*/
|
||||||
@Injectable()
|
@Injectable()
|
||||||
@ClassName('Common')
|
@ClassName('Common')
|
||||||
export class Common extends WuhuBase {
|
export class Common {
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private readonly localConfigWrapper: LocalConfigWrapper,
|
private readonly localConfigWrapper: LocalConfigWrapper,
|
||||||
|
private readonly fetchEventCallback: FetchEventCallback,
|
||||||
|
private readonly translateNew: TranslateNew,
|
||||||
|
private readonly tornPDAUtils: TornPDAUtils,
|
||||||
|
private readonly logger: Logger,
|
||||||
|
private readonly buyBeerHelper: BuyBeerHelper,
|
||||||
|
private readonly icon: ZhongIcon,
|
||||||
|
private readonly fetchUtils: FetchUtils,
|
||||||
|
private readonly moduleLoader: ModuleLoader,
|
||||||
) {
|
) {
|
||||||
super();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public resolve(mainMethod) {
|
public resolve(mainMethod) {
|
||||||
let glob = Common.glob;
|
|
||||||
|
// 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)
|
||||||
|
);
|
||||||
|
|
||||||
// 价格监控
|
// 价格监控
|
||||||
priceWatcherHandle(glob.isPDA, glob.PDA_APIKey);
|
priceWatcherHandle(this.tornPDAUtils.isPDA(), this.tornPDAUtils.APIKey);
|
||||||
|
|
||||||
// 啤酒提醒
|
// 啤酒提醒
|
||||||
if (this.localConfigWrapper.config._15Alarm) glob.beer.start();
|
if (this.localConfigWrapper.config._15Alarm) this.buyBeerHelper.start();
|
||||||
|
|
||||||
SidebarHelper.getInstance();
|
this.moduleLoader.push(SidebarHelper);
|
||||||
|
this.moduleLoader.push(TravelItem);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 解决一直转圈(加载中)的问题
|
* 解决一直转圈(加载中)的问题
|
||||||
@ -50,15 +70,16 @@ export class Common extends WuhuBase {
|
|||||||
if (document.readyState === 'interactive' && this.localConfigWrapper.config.SolveGoogleScriptPendingIssue) {
|
if (document.readyState === 'interactive' && this.localConfigWrapper.config.SolveGoogleScriptPendingIssue) {
|
||||||
window.stop();
|
window.stop();
|
||||||
document.open();
|
document.open();
|
||||||
document.addEventListener('readystatechange', function readyStateChangeHandler() {
|
let readyStateChangeHandler = () => {
|
||||||
Log.info('document.readyState', document.readyState);
|
this.logger.info('document.readyState', document.readyState);
|
||||||
if (document.readyState === 'complete') {
|
if (document.readyState === 'complete') {
|
||||||
document.removeEventListener('readystatechange', readyStateChangeHandler);
|
document.removeEventListener('readystatechange', readyStateChangeHandler);
|
||||||
mainMethod();
|
mainMethod();
|
||||||
throw new Error('页面已重载');
|
throw new Error('页面已重载');
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
FetchUtils.getInstance().fetchText(window.location.href).then(resp => {
|
document.addEventListener('readystatechange', readyStateChangeHandler);
|
||||||
|
this.fetchUtils.fetchText(window.location.href).then(resp => {
|
||||||
let removed = resp;
|
let removed = resp;
|
||||||
[
|
[
|
||||||
/<script id="gtm_tag">.+?<\/script>/ms,
|
/<script id="gtm_tag">.+?<\/script>/ms,
|
||||||
@ -68,32 +89,32 @@ export class Common extends WuhuBase {
|
|||||||
].forEach(remove => {
|
].forEach(remove => {
|
||||||
removed = removed.replace(remove, '');
|
removed = removed.replace(remove, '');
|
||||||
});
|
});
|
||||||
Log.info({ removed });
|
this.logger.info({ removed });
|
||||||
document.write(removed);
|
document.write(removed);
|
||||||
document.close();
|
document.close();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// fetch方法处理
|
|
||||||
globVars.responseHandlers.push(FetchEventCallback.getInstance().responseHandler);
|
|
||||||
// fetch方法处理-翻译
|
|
||||||
globVars.responseHandlers.push(TranslateNew.getInstance().responseHandler);
|
|
||||||
|
|
||||||
// 存钱相关
|
// 存钱相关
|
||||||
depoHelper();
|
depoHelper();
|
||||||
|
|
||||||
// 飞行相关
|
// 飞行相关
|
||||||
travelHelper().then();
|
this.moduleLoader.push(TravelHelper);
|
||||||
|
|
||||||
// 战斗相关
|
// 战斗相关
|
||||||
AttackHelper.getInstance();
|
this.moduleLoader.push(AttackHelper);
|
||||||
|
|
||||||
// 公司助手
|
// 公司助手
|
||||||
CompanyHelper.getInstance();
|
this.moduleLoader.push(CompanyHelper);
|
||||||
|
|
||||||
|
// TODO 新菜单
|
||||||
|
// this.moduleLoader.push(IconHelper);
|
||||||
|
|
||||||
|
this.moduleLoader.load().then();
|
||||||
|
|
||||||
// 自定义CSS
|
// 自定义CSS
|
||||||
if (this.localConfigWrapper.config.CustomCss) {
|
if (this.localConfigWrapper.config.CustomCss) {
|
||||||
Log.info('应用自定义CSS');
|
this.logger.info('应用自定义CSS');
|
||||||
CommonUtils.addStyle(this.localConfigWrapper.config.CustomCss);
|
CommonUtils.addStyle(this.localConfigWrapper.config.CustomCss);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,10 +126,10 @@ export class Common extends WuhuBase {
|
|||||||
new Alert('现金变动提醒已关闭', { sysNotify: true });
|
new Alert('现金变动提醒已关闭', { sysNotify: true });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Log.info("现金变动提醒", mutations);
|
this.logger.info("现金变动提醒", mutations);
|
||||||
mutations.forEach(item => {
|
mutations.forEach(item => {
|
||||||
if (item.attributeName === 'data-money') {
|
if (item.attributeName === 'data-money') {
|
||||||
ZhongIcon.getInstance().updateCashView(userMoney.innerText);
|
this.icon.updateCashView(userMoney.innerText);
|
||||||
new Alert(
|
new Alert(
|
||||||
'提醒: 现金变动 ' + item.oldValue + ' -> ' + userMoney.innerText,
|
'提醒: 现金变动 ' + item.oldValue + ' -> ' + userMoney.innerText,
|
||||||
{ sysNotify: true }
|
{ sysNotify: true }
|
||||||
|
|||||||
@ -1,44 +1,19 @@
|
|||||||
import Device from "../enum/Device";
|
import Device from "../enum/Device";
|
||||||
import WuhuBase from "./WuhuBase";
|
|
||||||
import IGlobal from "../interface/IGlobal";
|
import IGlobal from "../interface/IGlobal";
|
||||||
import Log from "./Log";
|
|
||||||
import InfoUtils from "./utils/InfoUtils";
|
|
||||||
import BuyBeerHelper from "./action/BuyBeerHelper";
|
|
||||||
import { Injectable } from "../container/Injectable";
|
import { Injectable } from "../container/Injectable";
|
||||||
import ClassName from "../container/ClassName";
|
import ClassName from "../container/ClassName";
|
||||||
|
import Logger from "./Logger";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 存储脚本用到的参数,单例存在
|
* 存储脚本用到的参数
|
||||||
*/
|
*/
|
||||||
@Injectable()
|
@Injectable()
|
||||||
@ClassName('Global')
|
@ClassName('Global')
|
||||||
export default class Global extends WuhuBase implements IGlobal {
|
export default class Global implements IGlobal {
|
||||||
className = 'Global';
|
|
||||||
|
|
||||||
GM_xmlhttpRequest: Function = null;
|
GM_xmlhttpRequest: Function = null;
|
||||||
href: string = window.location.href;
|
|
||||||
// 弹窗
|
|
||||||
popup_node: MyHTMLElement = null;
|
|
||||||
/**
|
|
||||||
* @deprecated 使用getInstance替代
|
|
||||||
*/
|
|
||||||
beer = null;
|
|
||||||
// 留存的通知
|
|
||||||
notifies: NotifyWrapper = null;
|
|
||||||
// 海外库存
|
|
||||||
fStock = null;
|
|
||||||
// 玩家名和数字id
|
|
||||||
player_info = null;
|
|
||||||
// 设备类型
|
// 设备类型
|
||||||
device: Device = null;
|
device: Device = window.innerWidth >= 1000 ? Device.PC : window.innerWidth <= 600 ? Device.MOBILE : Device.TABLET;
|
||||||
// PDA运行环境
|
|
||||||
isPDA: boolean = false;
|
|
||||||
// PDA自带apikey
|
|
||||||
PDA_APIKey: string = null;
|
|
||||||
// 脚本版本
|
|
||||||
version: string = null;
|
|
||||||
// window 副本
|
|
||||||
window: Window & typeof globalThis = window;
|
|
||||||
unsafeWindow: Window & typeof globalThis = null;
|
unsafeWindow: Window & typeof globalThis = null;
|
||||||
// document body 属性
|
// document body 属性
|
||||||
bodyAttrs: {
|
bodyAttrs: {
|
||||||
@ -47,12 +22,34 @@ export default class Global extends WuhuBase implements IGlobal {
|
|||||||
'data-traveling'?: 'true' | 'false';
|
'data-traveling'?: 'true' | 'false';
|
||||||
'data-abroad'?: 'true' | 'false';
|
'data-abroad'?: 'true' | 'false';
|
||||||
} = null;
|
} = null;
|
||||||
|
// href: string = window.location.href;
|
||||||
|
// 弹窗
|
||||||
|
// popup_node: MyHTMLElement|Popup = null;
|
||||||
|
/**
|
||||||
|
* @deprecated 使用getInstance替代
|
||||||
|
*/
|
||||||
|
// beer = null;
|
||||||
|
// 留存的通知
|
||||||
|
// notifies: NotifyWrapper = { count: 0 };
|
||||||
|
// 海外库存
|
||||||
|
// fStock = null;
|
||||||
|
// 玩家名和数字id
|
||||||
|
// player_info = null;
|
||||||
|
// PDA运行环境
|
||||||
|
// isPDA: boolean = false;
|
||||||
|
// PDA自带apikey
|
||||||
|
// PDA_APIKey: string = null;
|
||||||
|
// 脚本版本
|
||||||
|
// version: string = null;
|
||||||
|
// window 副本
|
||||||
|
// window: Window & typeof globalThis = window;
|
||||||
|
|
||||||
constructor() {
|
constructor(
|
||||||
Log.info('WH脚本参数[Global]初始化');
|
// private readonly infoUtils: InfoUtils,
|
||||||
super();
|
private readonly logger: Logger,
|
||||||
|
) {
|
||||||
if (typeof unsafeWindow !== 'undefined') {
|
if (typeof unsafeWindow !== 'undefined') {
|
||||||
Log.info('存在unsafeWindow, 引入');
|
this.logger.info('存在unsafeWindow, 引入');
|
||||||
this.unsafeWindow = unsafeWindow || null;
|
this.unsafeWindow = unsafeWindow || null;
|
||||||
window.addRFC = this.unsafeWindow.addRFC;
|
window.addRFC = this.unsafeWindow.addRFC;
|
||||||
window.getAction = this.unsafeWindow.getAction;
|
window.getAction = this.unsafeWindow.getAction;
|
||||||
@ -64,15 +61,14 @@ export default class Global extends WuhuBase implements IGlobal {
|
|||||||
// 上层调用如果使用eval此处GM_xmlhttpRequest可能不存在于window中
|
// 上层调用如果使用eval此处GM_xmlhttpRequest可能不存在于window中
|
||||||
this.GM_xmlhttpRequest = window.GM_xmlhttpRequest || GM_xmlhttpRequest || null;
|
this.GM_xmlhttpRequest = window.GM_xmlhttpRequest || GM_xmlhttpRequest || null;
|
||||||
}
|
}
|
||||||
this.version = '$$WUHU_DEV_VERSION$$';
|
// this.version = '$$WUHU_DEV_VERSION$$';
|
||||||
this.PDA_APIKey = '###PDA-APIKEY###';
|
// this.PDA_APIKey = '###PDA-APIKEY###';
|
||||||
this.isPDA = !this.PDA_APIKey.includes('###');
|
// this.isPDA = !this.PDA_APIKey.includes('###');
|
||||||
this.device = window.innerWidth >= 1000 ? Device.PC : window.innerWidth <= 600 ? Device.MOBILE : Device.TABLET;
|
// this.device = window.innerWidth >= 1000 ? Device.PC : window.innerWidth <= 600 ? Device.MOBILE : Device.TABLET;
|
||||||
this.player_info = InfoUtils.getInstance().getPlayerInfo();
|
// this.player_info = this.infoUtils.getPlayerInfo();
|
||||||
this.beer = BuyBeerHelper.getInstance();
|
// this.popup_node = null;
|
||||||
this.popup_node = null;
|
// this.notifies = { count: 0 };
|
||||||
this.notifies = { count: 0 };
|
// this.href = window.location.href;
|
||||||
this.href = window.location.href;
|
|
||||||
this.bodyAttrs = {};
|
this.bodyAttrs = {};
|
||||||
|
|
||||||
for (let i = 0; i < document.body.attributes.length; i++) {
|
for (let i = 0; i < document.body.attributes.length; i++) {
|
||||||
@ -81,17 +77,17 @@ export default class Global extends WuhuBase implements IGlobal {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 当窗口关闭时关闭所有还存在的通知
|
// 当窗口关闭时关闭所有还存在的通知
|
||||||
window.addEventListener(
|
// window.addEventListener(
|
||||||
'beforeunload',
|
// 'beforeunload',
|
||||||
() => {
|
// () => {
|
||||||
if (this.notifies.count !== 0) {
|
// if (this.notifies.count !== 0) {
|
||||||
for (let i = 0; i < this.notifies.count; i++) {
|
// for (let i = 0; i < this.notifies.count; i++) {
|
||||||
(this.notifies[i] !== null) && (this.notifies[i].close())
|
// (this.notifies[i] !== null) && (this.notifies[i].close())
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
);
|
// );
|
||||||
|
|
||||||
Log.info('WH脚本参数初始化结束');
|
// this.logger.info('WH脚本参数初始化结束');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
47
src/ts/class/IconHelper.ts
Normal file
47
src/ts/class/IconHelper.ts
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
import Logger from "./Logger";
|
||||||
|
import ClassName from "../container/ClassName";
|
||||||
|
import { Injectable } from "../container/Injectable";
|
||||||
|
import Global from "./Global";
|
||||||
|
import CommonUtils from "./utils/CommonUtils";
|
||||||
|
import LocalConfigWrapper from "./LocalConfigWrapper";
|
||||||
|
import NNB from "./handler/NNB";
|
||||||
|
import ItemPriceWatcherHandler from "./handler/ItemPriceWatcherHandler";
|
||||||
|
import { createApp, InjectionKey } from "vue";
|
||||||
|
import FloatMenu from "../../vue/FloatMenu.vue";
|
||||||
|
import MenuItem, { MENU_ITEM_TYPE } from "../interface/MenuItem";
|
||||||
|
|
||||||
|
export const MenuItemListKey = Symbol() as InjectionKey<MenuItem[]>;
|
||||||
|
export const GlobalKey = Symbol() as InjectionKey<Global>;
|
||||||
|
export const LoggerKey = Symbol() as InjectionKey<Logger>;
|
||||||
|
|
||||||
|
@ClassName("IconHelper")
|
||||||
|
@Injectable()
|
||||||
|
export default class IconHelper {
|
||||||
|
private readonly _element: HTMLElement;
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
private readonly logger: Logger,
|
||||||
|
private readonly global: Global,
|
||||||
|
private readonly commonUtils: CommonUtils,
|
||||||
|
private readonly localConfigWrapper: LocalConfigWrapper,
|
||||||
|
private readonly nnb: NNB,
|
||||||
|
private readonly itemPriceWatcherHandler: ItemPriceWatcherHandler,
|
||||||
|
) {
|
||||||
|
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.provide(MenuItemListKey, [{ domType: MENU_ITEM_TYPE.BUTTON, domId: '1', domText: '1111111' }]);
|
||||||
|
app.provide(GlobalKey, this.global);
|
||||||
|
app.provide(LoggerKey, this.logger);
|
||||||
|
app.mount(this._element);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,9 +1,7 @@
|
|||||||
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 "./Logger";
|
||||||
import defaultConfig from "./config/defaultConfig";
|
import defaultConfig, { Config } from "./config/defaultConfig";
|
||||||
|
|
||||||
type Config = typeof defaultConfig;
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
@ClassName('LocalConfigWrapper')
|
@ClassName('LocalConfigWrapper')
|
||||||
@ -18,7 +16,7 @@ export default class LocalConfigWrapper {
|
|||||||
let setLocal = this.setLocal;
|
let setLocal = this.setLocal;
|
||||||
return new Proxy(this.Local, {
|
return new Proxy(this.Local, {
|
||||||
get(target: Config, prop: string) {
|
get(target: Config, prop: string) {
|
||||||
return target[prop];
|
return target[prop] || defaultConfig[prop];
|
||||||
},
|
},
|
||||||
set(target: Config, prop: string, value: any): boolean {
|
set(target: Config, prop: string, value: any): boolean {
|
||||||
let config = target;
|
let config = target;
|
||||||
|
|||||||
@ -31,6 +31,7 @@ export default class Log {
|
|||||||
let local = JSON.parse(localStorage.getItem('wh_trans_settings'));
|
let local = JSON.parse(localStorage.getItem('wh_trans_settings'));
|
||||||
if (local) ret = local['isDev'];
|
if (local) ret = local['isDev'];
|
||||||
} catch {
|
} catch {
|
||||||
|
this.error('debug错误')
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,4 +16,8 @@ export default class Logger {
|
|||||||
error(...o: any): void {
|
error(...o: any): void {
|
||||||
return Log.error(...o);
|
return Log.error(...o);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
debug() {
|
||||||
|
return Log.debug()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,11 +1,34 @@
|
|||||||
import Logger from "./Logger";
|
import Logger from "./Logger";
|
||||||
|
import { Container } from "../container/Container";
|
||||||
|
import ClassName, { GetClassName } from "../container/ClassName";
|
||||||
|
import { Injectable } from "../container/Injectable";
|
||||||
|
|
||||||
|
@ClassName('ModuleLoader')
|
||||||
|
@Injectable()
|
||||||
export default class ModuleLoader {
|
export default class ModuleLoader {
|
||||||
|
private readonly classes: any[] = [];
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private readonly logger: Logger,
|
private readonly logger: Logger,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public async load(modules: any[]): Promise<void> {
|
/**
|
||||||
|
*
|
||||||
|
* @param method 默认'init'
|
||||||
|
*/
|
||||||
|
public async load(method: string = 'init'): Promise<void> {
|
||||||
|
this.classes.forEach(clas => {
|
||||||
|
try {
|
||||||
|
Container.factory(clas)[method]();
|
||||||
|
} catch (e) {
|
||||||
|
this.logger.error('ModuleLoader 加载[' + GetClassName(clas) + ']时出错', e.message, e.stack);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.classes.length = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public push<T>(clas: T): void {
|
||||||
|
this.classes.push(clas);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
import cityFinder from "../func/module/cityFinder";
|
import cityFinder from "../func/module/cityFinder";
|
||||||
import { missionDict } from "../dictionary/translation";
|
import { missionDict } from "../dictionary/translation";
|
||||||
import getTaskHint from "../func/translate/getTaskHint";
|
import getTaskHint from "../func/translate/getTaskHint";
|
||||||
import WuhuBase from "./WuhuBase";
|
|
||||||
import CommonUtils from "./utils/CommonUtils";
|
import CommonUtils from "./utils/CommonUtils";
|
||||||
import Log from "./Log";
|
import Log from "./Log";
|
||||||
import WuhuConfig from "./WuhuConfig";
|
import WuhuConfig from "./WuhuConfig";
|
||||||
@ -24,6 +23,7 @@ import globVars from "../globVars";
|
|||||||
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 { Container } from "../container/Container";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 脚本区分页面的功能入口
|
* 脚本区分页面的功能入口
|
||||||
@ -32,15 +32,19 @@ import LocalConfigWrapper from "./LocalConfigWrapper";
|
|||||||
*/
|
*/
|
||||||
@Injectable()
|
@Injectable()
|
||||||
@ClassName('UrlPattern')
|
@ClassName('UrlPattern')
|
||||||
export default class UrlPattern extends WuhuBase {
|
export default class UrlRouter {
|
||||||
constructor(
|
constructor(
|
||||||
private readonly localConfigWrapper: LocalConfigWrapper,
|
private readonly localConfigWrapper: LocalConfigWrapper,
|
||||||
|
private readonly buyBeerHelper: BuyBeerHelper,
|
||||||
|
private readonly searchHelper: SearchHelper,
|
||||||
|
private readonly lotteryHelper: LotteryHelper,
|
||||||
|
private readonly slotsHelper: SlotsHelper,
|
||||||
) {
|
) {
|
||||||
super();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public resolve(): void {
|
public resolve(): void {
|
||||||
let href = window.location.href;
|
let href = window.location.href;
|
||||||
|
let modules = [];
|
||||||
// 捡垃圾助手
|
// 捡垃圾助手
|
||||||
if (href.includes('city.php') && this.localConfigWrapper.config.cityFinder) {
|
if (href.includes('city.php') && this.localConfigWrapper.config.cityFinder) {
|
||||||
let _base = new TornStyleBlock('芜湖助手').insert2Dom();
|
let _base = new TornStyleBlock('芜湖助手').insert2Dom();
|
||||||
@ -58,17 +62,17 @@ export default class UrlPattern extends WuhuBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// pt一键购买
|
// pt一键购买
|
||||||
if (href.includes('pmarket.php')) PTHelper.getInstance();
|
if (href.includes('pmarket.php')) Container.factory(PTHelper);
|
||||||
|
|
||||||
// 叠e助手
|
// 叠e助手
|
||||||
if (href.includes('gym.php')) StackHelper.getInstance();
|
if (href.includes('gym.php')) Container.factory(StackHelper);
|
||||||
|
|
||||||
// 寻找木桩
|
// 寻找木桩
|
||||||
if (href.includes('item.php?temp=4')) {
|
if (href.includes('item.php?temp=4')) {
|
||||||
let hasInit: boolean = false;
|
let hasInit: boolean = false;
|
||||||
let handle = () => {
|
let handle = () => {
|
||||||
if (!hasInit && window.location.hash === '#xunzhaomuzhuang') {
|
if (!hasInit && window.location.hash === '#xunzhaomuzhuang') {
|
||||||
XZMZ.getInstance().init();
|
Container.factory(XZMZ).init();
|
||||||
hasInit = true;
|
hasInit = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -106,11 +110,11 @@ export default class UrlPattern extends WuhuBase {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// 监听啤酒购买
|
// 监听啤酒购买
|
||||||
globVars.responseHandlers.push(BuyBeerHelper.getInstance().responseHandler);
|
globVars.responseHandlers.push(this.buyBeerHelper.responseHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 快速crime TODO 重构、与翻译解藕
|
// 快速crime TODO 重构、与翻译解藕
|
||||||
if (href.contains(/crimes\.php/) && WuhuConfig.get('quickCrime')) {
|
if (href.contains(/crimes\.php/) && this.localConfigWrapper.config.quickCrime) {
|
||||||
// iframe
|
// iframe
|
||||||
if (self !== top) {
|
if (self !== top) {
|
||||||
const isValidate = document.querySelector('h4#skip-to-content').innerText.toLowerCase().includes('validate');
|
const isValidate = document.querySelector('h4#skip-to-content').innerText.toLowerCase().includes('validate');
|
||||||
@ -160,7 +164,7 @@ export default class UrlPattern extends WuhuBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 任务助手 TODO 重构、与翻译解藕
|
// 任务助手 TODO 重构、与翻译解藕
|
||||||
if (href.contains(/loader\.php\?sid=missions/) && WuhuConfig.get('missionHint')) {
|
if (href.contains(/loader\.php\?sid=missions/) && this.localConfigWrapper.config.missionHint) {
|
||||||
const anchor = document.querySelector('.content-wrapper');
|
const anchor = document.querySelector('.content-wrapper');
|
||||||
const OB = new MutationObserver(() => {
|
const OB = new MutationObserver(() => {
|
||||||
OB.disconnect();
|
OB.disconnect();
|
||||||
@ -209,7 +213,7 @@ export default class UrlPattern extends WuhuBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 个人资料
|
// 个人资料
|
||||||
if (href.includes('profiles.php?XID=')) ProfileHelper.getInstance();
|
if (href.includes('profiles.php?XID=')) Container.factory(ProfileHelper);
|
||||||
|
|
||||||
// 圣诞小镇
|
// 圣诞小镇
|
||||||
if (href.contains(/christmas_town\.php/) && new Date().getMonth() > 9) christmasTownHelper();
|
if (href.contains(/christmas_town\.php/) && new Date().getMonth() > 9) christmasTownHelper();
|
||||||
@ -263,12 +267,12 @@ export default class UrlPattern extends WuhuBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 彩票助手
|
// 彩票助手
|
||||||
if (href.includes('loader.php?sid=lottery')) LotteryHelper.getInstance().init();
|
if (href.includes('loader.php?sid=lottery')) this.lotteryHelper.init();
|
||||||
|
|
||||||
// 老虎机助手
|
// 老虎机助手
|
||||||
if (href.includes('loader.php?sid=slots')) SlotsHelper.getInstance().init();
|
if (href.includes('loader.php?sid=slots')) this.slotsHelper.init();
|
||||||
|
|
||||||
// 搜索助手
|
// 搜索助手
|
||||||
if (href.includes('page.php?sid=UserList')) SearchHelper.getInstance().init();
|
if (href.includes('page.php?sid=UserList')) this.searchHelper.init();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,11 +1,7 @@
|
|||||||
import IGlobal from "../interface/IGlobal";
|
|
||||||
import IWHSettings from "../interface/IWHSettings";
|
import IWHSettings from "../interface/IWHSettings";
|
||||||
import Provider from "./provider/Provider";
|
|
||||||
import Log from "./Log";
|
import Log from "./Log";
|
||||||
|
|
||||||
export default class WuhuBase extends Provider {
|
export default class WuhuBase {
|
||||||
public static glob: IGlobal = null;
|
|
||||||
className: string = 'WuhuBase';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取 localStorage 中的 wh_trans_settings 值 (json),以对象形式返回
|
* 获取 localStorage 中的 wh_trans_settings 值 (json),以对象形式返回
|
||||||
|
|||||||
@ -2,25 +2,28 @@ import WuhuBase from "./WuhuBase";
|
|||||||
import Alert from "./utils/Alert";
|
import Alert from "./utils/Alert";
|
||||||
import Log from "./Log";
|
import Log from "./Log";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
export default class WuhuConfig extends WuhuBase {
|
export default class WuhuConfig extends WuhuBase {
|
||||||
className = 'WuhuConfig';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取键或多个键对应的值,返回值或列表
|
* 获取键或多个键对应的值,返回值或列表
|
||||||
* @param key
|
* @param key
|
||||||
*/
|
*/
|
||||||
public static get(key: string | string[]) {
|
// public static get(key: string | string[]) {
|
||||||
let localPool = this.getLocal();
|
// let localPool = this.getLocal();
|
||||||
if (typeof key === 'string') {
|
// if (typeof key === 'string') {
|
||||||
return localPool[key];
|
// return localPool[key];
|
||||||
} else {
|
// } else {
|
||||||
let ret: string[] = [];
|
// let ret: string[] = [];
|
||||||
key.forEach(k => {
|
// key.forEach(k => {
|
||||||
ret.push(localPool[k])
|
// ret.push(localPool[k])
|
||||||
});
|
// });
|
||||||
return ret;
|
// return ret;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
public static set(key: string, val: any, isNotify = false, callback: Function = () => null) {
|
public static set(key: string, val: any, isNotify = false, callback: Function = () => null) {
|
||||||
let config = WuhuConfig.getLocal();
|
let config = WuhuConfig.getLocal();
|
||||||
@ -37,107 +40,107 @@ export default class WuhuConfig extends WuhuBase {
|
|||||||
/**
|
/**
|
||||||
* 检查类型不符合时设置为默认值
|
* 检查类型不符合时设置为默认值
|
||||||
*/
|
*/
|
||||||
public static setDefaults(): void {
|
// public static setDefaults(): void {
|
||||||
let count = 0;
|
// let count = 0;
|
||||||
[
|
// [
|
||||||
// 开启翻译
|
// // 开启翻译
|
||||||
{ key: 'transEnable', val: false },
|
// { key: 'transEnable', val: false },
|
||||||
{ key: 'transNew', val: true },
|
// { key: 'transNew', val: true },
|
||||||
// 快速犯罪
|
// // 快速犯罪
|
||||||
{ key: 'quickCrime', val: true },
|
// { key: 'quickCrime', val: true },
|
||||||
// 任务助手
|
// // 任务助手
|
||||||
{ key: 'missionHint', val: true },
|
// { key: 'missionHint', val: true },
|
||||||
// 小镇攻略
|
// // 小镇攻略
|
||||||
{ key: 'xmasTownWT', val: true },
|
// { key: 'xmasTownWT', val: true },
|
||||||
// 小镇提醒
|
// // 小镇提醒
|
||||||
{ key: 'xmasTownNotify', val: true },
|
// { key: 'xmasTownNotify', val: true },
|
||||||
// 起飞爆e
|
// // 起飞爆e
|
||||||
{ key: 'energyAlert', val: true },
|
// { key: 'energyAlert', val: true },
|
||||||
// 飞行闹钟
|
// // 飞行闹钟
|
||||||
{ key: 'trvAlarm', val: true },
|
// { key: 'trvAlarm', val: true },
|
||||||
// 啤酒提醒
|
// // 啤酒提醒
|
||||||
{ key: '_15Alarm', val: true },
|
// { key: '_15Alarm', val: true },
|
||||||
// 捡垃圾助手
|
// // 捡垃圾助手
|
||||||
{ key: 'cityFinder', val: false },
|
// { key: 'cityFinder', val: false },
|
||||||
// 叠E保护
|
// // 叠E保护
|
||||||
{ key: 'SEProtect', val: false },
|
// { key: 'SEProtect', val: false },
|
||||||
// PT一键购买
|
// // PT一键购买
|
||||||
{ key: 'ptQuickBuy', val: false },
|
// { key: 'ptQuickBuy', val: false },
|
||||||
// 光速拔刀 6-关闭
|
// // 光速拔刀 6-关闭
|
||||||
{ key: 'quickAttIndex', val: 2 },
|
// { key: 'quickAttIndex', val: 2 },
|
||||||
// 光速跑路 0-leave 1-mug 2-hos 3-关闭
|
// // 光速跑路 0-leave 1-mug 2-hos 3-关闭
|
||||||
{ key: 'quickFinishAtt', val: 3 },
|
// { key: 'quickFinishAtt', val: 3 },
|
||||||
// 自动开打和结束
|
// // 自动开打和结束
|
||||||
{ key: 'autoStartFinish', val: false },
|
// { key: 'autoStartFinish', val: false },
|
||||||
/**
|
// /**
|
||||||
* @deprecated 废弃
|
// * @deprecated 废弃
|
||||||
*/
|
// */
|
||||||
{ key: 'attRelocate', val: true },
|
// { key: 'attRelocate', val: true },
|
||||||
// 攻击自刷新 0-无间隔 1-5s 6-关闭
|
// // 攻击自刷新 0-无间隔 1-5s 6-关闭
|
||||||
{ key: 'attReload', val: 6 },
|
// { key: 'attReload', val: 6 },
|
||||||
// 价格监视
|
// // 价格监视
|
||||||
{ key: 'priceWatcher', val: { xan: -1, pt: -1 } },
|
// { key: 'priceWatcher', val: { xan: -1, pt: -1 } },
|
||||||
// 开发者模式
|
// // 开发者模式
|
||||||
{ key: 'isDev', val: false },
|
// { key: 'isDev', val: false },
|
||||||
// 啤酒提醒时间
|
// // 啤酒提醒时间
|
||||||
{ key: '_15AlarmTime', val: 50 },
|
// { key: '_15AlarmTime', val: 50 },
|
||||||
// 4条转跳
|
// // 4条转跳
|
||||||
{ key: 'barsRedirect', val: true },
|
// { key: 'barsRedirect', val: true },
|
||||||
// 浮动存钱框
|
// // 浮动存钱框
|
||||||
{ key: 'floatDepo', val: true },
|
// { key: 'floatDepo', val: true },
|
||||||
// 公司转跳存钱
|
// // 公司转跳存钱
|
||||||
{ key: 'companyRedirect', val: true },
|
// { key: 'companyRedirect', val: true },
|
||||||
// 收起公司冰蛙效率表
|
// // 收起公司冰蛙效率表
|
||||||
{ key: 'companyBWCollapse', val: true },
|
// { key: 'companyBWCollapse', val: true },
|
||||||
/**
|
// /**
|
||||||
* @deprecated
|
// * @deprecated
|
||||||
*/
|
// */
|
||||||
{ key: 'removeScripts', val: true },
|
// { key: 'removeScripts', val: true },
|
||||||
// 海外警告
|
// // 海外警告
|
||||||
{ key: 'abroadWarning', val: true },
|
// { key: 'abroadWarning', val: true },
|
||||||
// 落地转跳
|
// // 落地转跳
|
||||||
{ key: 'landedRedirect', val: '' },
|
// { key: 'landedRedirect', val: '' },
|
||||||
// 任何位置一键存钱
|
// // 任何位置一键存钱
|
||||||
{ key: 'companyDepositAnywhere', val: false },
|
// { key: 'companyDepositAnywhere', val: false },
|
||||||
// 火车提醒时间
|
// // 火车提醒时间
|
||||||
{ key: 'CHTrainsDetect', val: 0 },
|
// { key: 'CHTrainsDetect', val: 0 },
|
||||||
// 火车提醒开关
|
// // 火车提醒开关
|
||||||
{ key: 'CHTrainsDetectSwitch', val: true },
|
// { key: 'CHTrainsDetectSwitch', val: true },
|
||||||
// 隐藏个人资料头像
|
// // 隐藏个人资料头像
|
||||||
{ key: 'HideProfileImg', val: false },
|
// { key: 'HideProfileImg', val: false },
|
||||||
// 显示曾用名
|
// // 显示曾用名
|
||||||
{ key: 'ShowNameHistory', val: true },
|
// { key: 'ShowNameHistory', val: true },
|
||||||
// 盯梢模式强度 0-550 1-950 2-1450 ms
|
// // 盯梢模式强度 0-550 1-950 2-1450 ms
|
||||||
{ key: 'WatchTargetFreq', val: 1 },
|
// { key: 'WatchTargetFreq', val: 1 },
|
||||||
// 隐藏侧边栏
|
// // 隐藏侧边栏
|
||||||
{ key: 'HideSidebar', val: false },
|
// { key: 'HideSidebar', val: false },
|
||||||
// 添加隐藏边栏按钮
|
// // 添加隐藏边栏按钮
|
||||||
{ key: 'HideSidebarBtn', val: true },
|
// { key: 'HideSidebarBtn', val: true },
|
||||||
// 搜索页占位区
|
// // 搜索页占位区
|
||||||
{ key: 'SearchPagePlaceholder', val: true },
|
// { key: 'SearchPagePlaceholder', val: true },
|
||||||
// 解决一直转圈(加载中)的问题
|
// // 解决一直转圈(加载中)的问题
|
||||||
{ key: 'SolveGoogleScriptPendingIssue', val: false },
|
// { key: 'SolveGoogleScriptPendingIssue', val: false },
|
||||||
// 图标坐标
|
// // 图标坐标
|
||||||
{ key: 'IconPosition', val: {} },
|
// { key: 'IconPosition', val: {} },
|
||||||
// 记住图标位置
|
// // 记住图标位置
|
||||||
{ key: 'SaveIconPosition', val: false },
|
// { key: 'SaveIconPosition', val: false },
|
||||||
// 现金变动提醒
|
// // 现金变动提醒
|
||||||
{ key: 'CashChangeAlert', val: false },
|
// { key: 'CashChangeAlert', val: false },
|
||||||
// 收集数据以改进翻译质量
|
// // 收集数据以改进翻译质量
|
||||||
{ key: 'CollectPlayerData', val: true },
|
// { key: 'CollectPlayerData', val: true },
|
||||||
// 迷你资料卡显示上次行动时间
|
// // 迷你资料卡显示上次行动时间
|
||||||
{ key: 'ShowMiniProfLastAct', val: true },
|
// { key: 'ShowMiniProfLastAct', val: true },
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* @deprecated
|
// * @deprecated
|
||||||
*/
|
// */
|
||||||
{ key: 'dangerZone', val: false },
|
// { key: 'dangerZone', val: false },
|
||||||
].forEach(df => {
|
// ].forEach(df => {
|
||||||
if (typeof WuhuConfig.get(df.key) !== typeof df.val) {
|
// if (typeof WuhuConfig.get(df.key) !== typeof df.val) {
|
||||||
WuhuConfig.set(df.key, df.val);
|
// WuhuConfig.set(df.key, df.val);
|
||||||
count++;
|
// count++;
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
Log.info('设置默认值,新:' + count);
|
// Log.info('设置默认值,新:' + count);
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,40 +1,37 @@
|
|||||||
import CommonUtils from "./utils/CommonUtils";
|
import CommonUtils from "./utils/CommonUtils";
|
||||||
import WuhuBase from "./WuhuBase";
|
|
||||||
import TravelItem from "./action/TravelItem";
|
|
||||||
import Global from "./Global";
|
import Global from "./Global";
|
||||||
import Log from "./Log";
|
|
||||||
import COMMON_CSS from "../../static/css/common.css";
|
import COMMON_CSS from "../../static/css/common.css";
|
||||||
import globVars from "../globVars";
|
import globVars from "../globVars";
|
||||||
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 InfoUtils from "./utils/InfoUtils";
|
||||||
|
|
||||||
/**
|
|
||||||
* 脚本入口
|
|
||||||
*/
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
@ClassName('WuHuTornHelper')
|
@ClassName('WuHuTornHelper')
|
||||||
export default class WuHuTornHelper extends WuhuBase {
|
export default class WuHuTornHelper {
|
||||||
constructor(
|
constructor(
|
||||||
private readonly travelItem: TravelItem,
|
// private readonly travelItem: TravelItem,
|
||||||
private readonly global: Global
|
private readonly global: Global,
|
||||||
|
private readonly logger: Logger,
|
||||||
|
private readonly infoUtils: InfoUtils,
|
||||||
) {
|
) {
|
||||||
super();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public init() {
|
public init() {
|
||||||
Log.info('WuHuTornHelper初始化');
|
// this.logger.info('WuHuTornHelper初始化');
|
||||||
WuhuBase.glob = this.global;
|
// WuhuBase.glob = this.global;
|
||||||
let glob = WuHuTornHelper.glob;
|
let glob = this.global;
|
||||||
glob.fStock = this.travelItem;
|
// glob.fStock = this.travelItem;
|
||||||
|
|
||||||
// 请求通知权限
|
// 请求通知权限
|
||||||
if (window.Notification) {
|
if (window.Notification) {
|
||||||
if (window.Notification.permission !== 'granted') {
|
if (window.Notification.permission !== 'granted') {
|
||||||
Log.info("芜湖助手即将请求浏览器通知权限……");
|
this.logger.info("芜湖助手即将请求浏览器通知权限……");
|
||||||
window.Notification.requestPermission().then();
|
window.Notification.requestPermission().then();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Log.error('该浏览器不支持系统通知');
|
this.logger.error('该浏览器不支持系统通知');
|
||||||
}
|
}
|
||||||
|
|
||||||
// 扩展正则方法
|
// 扩展正则方法
|
||||||
@ -62,17 +59,17 @@ export default class WuHuTornHelper extends WuhuBase {
|
|||||||
try {
|
try {
|
||||||
ret.json = JSON.parse(<string>data);
|
ret.json = JSON.parse(<string>data);
|
||||||
} catch {
|
} catch {
|
||||||
Log.warn('JSON.parse 错误', { data });
|
this.logger.warn('JSON.parse 错误', { data });
|
||||||
ret.text = data;
|
ret.text = data;
|
||||||
}
|
}
|
||||||
Log.info('[' + from + ']响应', { url, method, ret, requestBody });
|
this.logger.info('[' + from + ']响应', { url, method, ret, requestBody });
|
||||||
globVars.WH_NET_LOG.push({ url, method, ret, requestBody, from });
|
globVars.WH_NET_LOG.push({ url, method, ret, requestBody, from });
|
||||||
|
|
||||||
globVars.responseHandlers.forEach(handler => {
|
globVars.responseHandlers.forEach(handler => {
|
||||||
try {
|
try {
|
||||||
handler(url, ret, { method, requestBody });
|
handler(url, ret, { method, requestBody });
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
Log.error(e.stack || e.message);
|
this.logger.error(e.stack || e.message);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (ret.isModified) {
|
if (ret.isModified) {
|
||||||
@ -82,7 +79,7 @@ export default class WuHuTornHelper extends WuhuBase {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
// 监听fetch
|
// 监听fetch
|
||||||
(function (fetch0, window) {
|
((fetch0, window) => {
|
||||||
let originFetch = fetch0;
|
let originFetch = fetch0;
|
||||||
// 引用解决与其他脚本接管fetch方法引起的兼容性问题
|
// 引用解决与其他脚本接管fetch方法引起的兼容性问题
|
||||||
if (glob.unsafeWindow) {
|
if (glob.unsafeWindow) {
|
||||||
@ -92,12 +89,12 @@ export default class WuHuTornHelper extends WuhuBase {
|
|||||||
if (!init) init = { method: 'GET' };
|
if (!init) init = { method: 'GET' };
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
if (url.includes('newsTickers')) {
|
if (url.includes('newsTickers')) {
|
||||||
Log.info('阻止获取新闻横幅');
|
this.logger.info('阻止获取新闻横幅');
|
||||||
resolve(new Response('{}', init));
|
resolve(new Response('{}', init));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (url.includes('google')) {
|
if (url.includes('google')) {
|
||||||
Log.info('阻止google相关请求');
|
this.logger.info('阻止google相关请求');
|
||||||
resolve(new Response('{}', init));
|
resolve(new Response('{}', init));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -110,7 +107,7 @@ export default class WuHuTornHelper extends WuhuBase {
|
|||||||
return;
|
return;
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.catch(error => Log.error('fetch错误', error.stack || error.message));
|
.catch(error => this.logger.error('fetch错误', error.stack || error.message));
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -120,9 +117,10 @@ export default class WuHuTornHelper extends WuhuBase {
|
|||||||
})(fetch || window.fetch, glob.unsafeWindow || window);
|
})(fetch || window.fetch, glob.unsafeWindow || window);
|
||||||
|
|
||||||
// 监听xhr
|
// 监听xhr
|
||||||
(function (xhr) {
|
(xhr => {
|
||||||
let originOpen = xhr.open;
|
let originOpen = xhr.open;
|
||||||
let originSend = xhr.send;
|
let originSend = xhr.send;
|
||||||
|
let logger = this.logger;
|
||||||
let modifyResponse = (response: { responseText: string, response: string }, after: string) => {
|
let modifyResponse = (response: { responseText: string, response: string }, after: string) => {
|
||||||
Object.defineProperty(response, 'responseText', { writable: true });
|
Object.defineProperty(response, 'responseText', { writable: true });
|
||||||
Object.defineProperty(response, 'response', { writable: true });
|
Object.defineProperty(response, 'response', { writable: true });
|
||||||
@ -134,7 +132,7 @@ export default class WuHuTornHelper extends WuhuBase {
|
|||||||
if (this.readyState !== 4) return;
|
if (this.readyState !== 4) return;
|
||||||
let response = this.responseText || this.response;
|
let response = this.responseText || this.response;
|
||||||
let reqBody = this['reqBody'];
|
let reqBody = this['reqBody'];
|
||||||
Log.info('xhr this', this);
|
logger.info('xhr this', this);
|
||||||
if (response) {
|
if (response) {
|
||||||
let modified = intercept(response, url, method, reqBody, 'xhr');
|
let modified = intercept(response, url, method, reqBody, 'xhr');
|
||||||
modifyResponse(this, modified);
|
modifyResponse(this, modified);
|
||||||
@ -153,12 +151,11 @@ export default class WuHuTornHelper extends WuhuBase {
|
|||||||
|
|
||||||
// 测试用
|
// 测试用
|
||||||
if ('Ok' !== localStorage['WHTEST']) {
|
if ('Ok' !== localStorage['WHTEST']) {
|
||||||
if (!((glob.player_info.userID | 0) === -1 || glob.player_info.playername === '未知')) {
|
if (!((this.infoUtils.getPlayerInfo().userID | 0) === -1 || this.infoUtils.getPlayerInfo().playername === '未知')) {
|
||||||
CommonUtils.COFetch(
|
CommonUtils.COFetch(
|
||||||
atob('aHR0cDovL2x1di1jbi00ZXZlci5sanMtbHl0LmNvbTo4MDgwL3Rlc3QvY2FzZTE='),
|
atob('aHR0cDovL2x1di1jbi00ZXZlci5sanMtbHl0LmNvbTo4MDgwL3Rlc3QvY2FzZTE='),
|
||||||
// @ts-ignore
|
|
||||||
atob('cG9zdA=='),
|
atob('cG9zdA=='),
|
||||||
`{"uid":"${ glob.player_info.userID }","name":"${ glob.player_info.playername }"}`
|
`{"uid":"${ this.infoUtils.getPlayerInfo().userID }","name":"${ this.infoUtils.getPlayerInfo().playername }"}`
|
||||||
)
|
)
|
||||||
.then(res => (res === 'Ok') && (localStorage['WHTEST'] = 'Ok'));
|
.then(res => (res === 'Ok') && (localStorage['WHTEST'] = 'Ok'));
|
||||||
}
|
}
|
||||||
@ -173,11 +170,10 @@ export default class WuHuTornHelper extends WuhuBase {
|
|||||||
window.dataLayer = null;
|
window.dataLayer = null;
|
||||||
|
|
||||||
// 滚动条样式
|
// 滚动条样式
|
||||||
|
this.logger.info("调整滚动条样式");
|
||||||
document.documentElement.classList.add("d");
|
document.documentElement.classList.add("d");
|
||||||
document.body.classList.add("scrollbar-transparent");
|
document.body.classList.add("scrollbar-transparent");
|
||||||
Log.info("滚动条样式调整")
|
|
||||||
|
|
||||||
Log.info('WuHuTornHelper初始化结束');
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,8 +1,6 @@
|
|||||||
import adHelper from "../func/module/adHelper";
|
import adHelper from "../func/module/adHelper";
|
||||||
import safeKeeper from "../func/module/safeKeeper";
|
import safeKeeper from "../func/module/safeKeeper";
|
||||||
import initMiniProf from "../func/utils/initMiniProf";
|
import initMiniProf from "../func/utils/initMiniProf";
|
||||||
import WuhuBase from "./WuhuBase";
|
|
||||||
import Log from "./Log";
|
|
||||||
import CommonUtils from "./utils/CommonUtils";
|
import CommonUtils from "./utils/CommonUtils";
|
||||||
import Alert from "./utils/Alert";
|
import Alert from "./utils/Alert";
|
||||||
import * as EVENTS from "../../static/json/event.json";
|
import * as EVENTS from "../../static/json/event.json";
|
||||||
@ -13,43 +11,47 @@ 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";
|
||||||
import Test from "../test/Test";
|
import Test from "../test/Test";
|
||||||
import Global from "./Global";
|
|
||||||
import Timer from "./utils/Timer";
|
import Timer from "./utils/Timer";
|
||||||
import QuickFlyBtnHandler from "./handler/QuickFlyBtnHandler";
|
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 WuhuConfig from "./WuhuConfig";
|
|
||||||
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";
|
||||||
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 Logger from "./Logger";
|
||||||
|
import { Container } from "../container/Container";
|
||||||
|
import TornPDAUtils from "./utils/TornPDAUtils";
|
||||||
|
import InfoUtils from "./utils/InfoUtils";
|
||||||
|
import globVars from "../globVars";
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
@ClassName('ZhongIcon')
|
@ClassName('ZhongIcon')
|
||||||
export default class ZhongIcon extends WuhuBase {
|
export default class ZhongIcon {
|
||||||
className = 'ZhongIcon';
|
|
||||||
public static ZhongNode: MyHTMLElement = null;
|
public static ZhongNode: MyHTMLElement = null;
|
||||||
private menuItemList: MenuItemConfig[] = null;
|
private menuItemList: MenuItemConfig[] = null;
|
||||||
private cashView: HTMLElement = null;
|
private cashView: HTMLElement = null;
|
||||||
|
|
||||||
// private settingItemList: MenuItemConfig[] = null;
|
|
||||||
|
|
||||||
public constructor(
|
public constructor(
|
||||||
private readonly global: Global,
|
private readonly commonUtils: CommonUtils,
|
||||||
private readonly commonUtils: CommonUtils
|
private readonly localConfigWrapper: LocalConfigWrapper,
|
||||||
|
private readonly nnb: NNB,
|
||||||
|
private readonly itemPriceWatcherHandler: ItemPriceWatcherHandler,
|
||||||
|
private readonly logger: Logger,
|
||||||
|
private readonly tornPDAUtils: TornPDAUtils,
|
||||||
|
private readonly infoUtils: InfoUtils,
|
||||||
) {
|
) {
|
||||||
super();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public init() {
|
public init() {
|
||||||
Log.info('ZhongIcon初始化, 设置图标开始');
|
|
||||||
this.constructMenuList()
|
this.constructMenuList()
|
||||||
.insert2Dom()
|
.insert2Dom()
|
||||||
.dragHandler();
|
.dragHandler();
|
||||||
Log.info('设置图标结束, ZhongIcon初始化结束');
|
this.logger.info('设置图标结束');
|
||||||
}
|
}
|
||||||
|
|
||||||
public updateCashView(content: string): void {
|
public updateCashView(content: string): void {
|
||||||
@ -76,7 +78,7 @@ export default class ZhongIcon extends WuhuBase {
|
|||||||
*/
|
*/
|
||||||
private insert2Dom(): ZhongIcon {
|
private insert2Dom(): ZhongIcon {
|
||||||
let zhongNode: MyHTMLElement = document.querySelector('div#wh-trans-icon');
|
let zhongNode: MyHTMLElement = document.querySelector('div#wh-trans-icon');
|
||||||
let { version } = this.global;
|
let version = globVars.version;
|
||||||
if ((self !== top) || !!zhongNode) return null;
|
if ((self !== top) || !!zhongNode) return null;
|
||||||
zhongNode = document.createElement('div');
|
zhongNode = document.createElement('div');
|
||||||
ZhongIcon.ZhongNode = zhongNode;
|
ZhongIcon.ZhongNode = zhongNode;
|
||||||
@ -87,26 +89,26 @@ export default class ZhongIcon extends WuhuBase {
|
|||||||
const menu_cont = zhongNode.querySelector('#wh-gSettings');
|
const menu_cont = zhongNode.querySelector('#wh-gSettings');
|
||||||
// 遍历菜单node设置、生成node、插入dom
|
// 遍历菜单node设置、生成node、插入dom
|
||||||
this.menuItemList.forEach(setting => this.commonUtils.elemGenerator(setting, menu_cont));
|
this.menuItemList.forEach(setting => this.commonUtils.elemGenerator(setting, menu_cont));
|
||||||
Log.info('生成元素插入完成');
|
this.logger.info('生成元素插入完成');
|
||||||
// 计时node
|
// 计时node
|
||||||
zhongNode.initTimer = zhongNode.querySelector('#wh-inittimer');
|
zhongNode.initTimer = zhongNode.querySelector('#wh-inittimer');
|
||||||
// 芜湖助手图标点击事件
|
// 芜湖助手图标点击事件
|
||||||
(<MyHTMLElement>zhongNode.querySelector('#wh-trans-icon-btn')).onclick = () => {
|
(<MyHTMLElement>zhongNode.querySelector('#wh-trans-icon-btn')).onclick = () => {
|
||||||
zhongNode.classList.toggle('wh-icon-expanded');
|
zhongNode.classList.toggle('wh-icon-expanded');
|
||||||
const click_func = e => {
|
const click_func = e => {
|
||||||
Log.info(e.target);
|
this.logger.info(e.target);
|
||||||
if (e.target === zhongNode.querySelector('#wh-trans-icon-btn')) return;
|
if (e.target === zhongNode.querySelector('#wh-trans-icon-btn')) return;
|
||||||
if (!zhongNode.contains(e.target)) {
|
if (!zhongNode.contains(e.target)) {
|
||||||
Log.info('移除事件监听器');
|
this.logger.info('移除事件监听器');
|
||||||
document.body.removeEventListener('click', click_func);
|
document.body.removeEventListener('click', click_func);
|
||||||
zhongNode.classList.remove('wh-icon-expanded');
|
zhongNode.classList.remove('wh-icon-expanded');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if (zhongNode.classList.contains('wh-icon-expanded')) {
|
if (zhongNode.classList.contains('wh-icon-expanded')) {
|
||||||
Log.info('芜湖助手图标点击->添加监听');
|
this.logger.info('芜湖助手图标点击->添加监听');
|
||||||
document.body.addEventListener('click', click_func);
|
document.body.addEventListener('click', click_func);
|
||||||
} else {
|
} else {
|
||||||
Log.info('芜湖助手图标->移除监听');
|
this.logger.info('芜湖助手图标->移除监听');
|
||||||
document.body.removeEventListener('click', click_func);
|
document.body.removeEventListener('click', click_func);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -158,8 +160,8 @@ export default class ZhongIcon extends WuhuBase {
|
|||||||
})
|
})
|
||||||
: el.addEventListener('click', null));
|
: el.addEventListener('click', null));
|
||||||
// 调整图标至有记录的位置
|
// 调整图标至有记录的位置
|
||||||
if (WuhuConfig.get("SaveIconPosition")) {
|
if (this.localConfigWrapper.config.SaveIconPosition) {
|
||||||
let iconPosition = WuhuConfig.get("IconPosition");
|
let iconPosition = this.localConfigWrapper.config.IconPosition;
|
||||||
let documentSize = { x: document.documentElement.offsetWidth, y: document.documentElement.offsetHeight };
|
let documentSize = { x: document.documentElement.offsetWidth, y: document.documentElement.offsetHeight };
|
||||||
ZhongIcon.setPosition(
|
ZhongIcon.setPosition(
|
||||||
iconPosition.x > documentSize.x ? documentSize.x * 0.9 | 0 : iconPosition.x,
|
iconPosition.x > documentSize.x ? documentSize.x * 0.9 | 0 : iconPosition.x,
|
||||||
@ -168,10 +170,10 @@ export default class ZhongIcon extends WuhuBase {
|
|||||||
}
|
}
|
||||||
document.body.append(zhongNode);
|
document.body.append(zhongNode);
|
||||||
// 引入torn自带浮动提示
|
// 引入torn自带浮动提示
|
||||||
Log.info('引入torn自带浮动提示');
|
this.logger.info('引入torn自带浮动提示');
|
||||||
(window.initializeTooltip) && (window.initializeTooltip('.wh-container', 'white-tooltip'));
|
(window.initializeTooltip) && (window.initializeTooltip('.wh-container', 'white-tooltip'));
|
||||||
// 加载torn mini profile
|
// 加载torn mini profile
|
||||||
Log.info('加载torn mini profile');
|
this.logger.info('加载torn mini profile');
|
||||||
let miniProfileInterval = {
|
let miniProfileInterval = {
|
||||||
id: window.setInterval(() => {
|
id: window.setInterval(() => {
|
||||||
miniProfileInterval.counter++;
|
miniProfileInterval.counter++;
|
||||||
@ -183,7 +185,7 @@ export default class ZhongIcon extends WuhuBase {
|
|||||||
}, 1000),
|
}, 1000),
|
||||||
counter: 0
|
counter: 0
|
||||||
};
|
};
|
||||||
Log.info('图标加入文档树完成');
|
this.logger.info('图标加入文档树完成');
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -204,8 +206,8 @@ export default class ZhongIcon extends WuhuBase {
|
|||||||
isMouseDown = false;
|
isMouseDown = false;
|
||||||
if (isMouseMoved) {
|
if (isMouseMoved) {
|
||||||
isMouseMoved = false;
|
isMouseMoved = false;
|
||||||
if (WuhuConfig.get("SaveIconPosition")) {
|
if (this.localConfigWrapper.config.SaveIconPosition) {
|
||||||
WuhuConfig.set("IconPosition", ZhongIcon.getPosition());
|
this.localConfigWrapper.config.IconPosition = ZhongIcon.getPosition();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -227,19 +229,20 @@ export default class ZhongIcon extends WuhuBase {
|
|||||||
|
|
||||||
// 菜单
|
// 菜单
|
||||||
private constructMenuList(): ZhongIcon {
|
private constructMenuList(): ZhongIcon {
|
||||||
Log.info('构造菜单列表开始');
|
this.logger.info('构造菜单列表开始');
|
||||||
let timer = new Timer();
|
let timer = new Timer();
|
||||||
let glob = Global.getInstance();
|
|
||||||
const date = new Date();
|
const date = new Date();
|
||||||
|
let userInfo = this.infoUtils.getPlayerInfo();
|
||||||
|
|
||||||
let list: MenuItemConfig[] = [];
|
let list: MenuItemConfig[] = [];
|
||||||
|
|
||||||
// 欢迎 显示玩家id
|
// 欢迎 显示玩家id
|
||||||
if (glob.player_info.userID !== 0) {
|
if (userInfo.userID !== 0) {
|
||||||
list.push({
|
list.push({
|
||||||
domType: 'plain',
|
domType: 'plain',
|
||||||
domId: 'wh-trans-welcome',
|
domId: 'wh-trans-welcome',
|
||||||
domHTML: `<a href="/profiles.php?XID=${ glob.player_info.userID }" target="_blank">${ glob.player_info.playername }</a>[${ glob.player_info.userID }]`,
|
domHTML:
|
||||||
|
`<a href="/profiles.php?XID=${ userInfo.userID }" target="_blank">${ userInfo.playername }</a>[${ userInfo.userID }]`,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// 节日
|
// 节日
|
||||||
@ -330,14 +333,14 @@ export default class ZhongIcon extends WuhuBase {
|
|||||||
domType: 'button',
|
domType: 'button',
|
||||||
domId: 'wh-quick-fly-btn',
|
domId: 'wh-quick-fly-btn',
|
||||||
domText: '✈️ 一键起飞',
|
domText: '✈️ 一键起飞',
|
||||||
clickFunc: () => QuickFlyBtnHandler.getInstance().handle(),
|
clickFunc: () => Container.factory(QuickFlyBtnHandler).handle(),
|
||||||
});
|
});
|
||||||
// 飞花库存
|
// 飞花库存
|
||||||
list.push({
|
list.push({
|
||||||
domType: 'button',
|
domType: 'button',
|
||||||
domId: 'wh-foreign-stock-btn',
|
domId: 'wh-foreign-stock-btn',
|
||||||
domText: '🌸 飞花库存',
|
domText: '🌸 飞花库存',
|
||||||
clickFunc: () => TravelItem.getInstance().clickHandler().then(),
|
clickFunc: () => Container.factory(TravelItem).clickHandler().then(),
|
||||||
});
|
});
|
||||||
// NPC LOOT
|
// NPC LOOT
|
||||||
list.push({
|
list.push({
|
||||||
@ -355,14 +358,14 @@ export default class ZhongIcon extends WuhuBase {
|
|||||||
domType: 'button',
|
domType: 'button',
|
||||||
domId: 'wh-nnb-info',
|
domId: 'wh-nnb-info',
|
||||||
domText: '👮 查看NNB',
|
domText: '👮 查看NNB',
|
||||||
clickFunc: () => NNB.getInstance().handle(),
|
clickFunc: () => this.nnb.handle(),
|
||||||
});
|
});
|
||||||
// 常用链接
|
// 常用链接
|
||||||
list.push({
|
list.push({
|
||||||
domType: 'button',
|
domType: 'button',
|
||||||
domId: 'wh-link-collection',
|
domId: 'wh-link-collection',
|
||||||
domText: '🔗 常用链接',
|
domText: '🔗 常用链接',
|
||||||
clickFunc: () => QuickLinksHandler.getInstance().handle()
|
clickFunc: () => Container.factory(QuickLinksHandler).handle()
|
||||||
});
|
});
|
||||||
// 飞贼
|
// 飞贼
|
||||||
// list.push({
|
// list.push({
|
||||||
@ -378,10 +381,10 @@ export default class ZhongIcon extends WuhuBase {
|
|||||||
domType: 'button',
|
domType: 'button',
|
||||||
domId: 'wh-price-watcher-btn',
|
domId: 'wh-price-watcher-btn',
|
||||||
domText: '💊 价格监视',
|
domText: '💊 价格监视',
|
||||||
clickFunc: () => ItemPriceWatcherHandler.getInstance().handle()
|
clickFunc: () => this.itemPriceWatcherHandler.handle()
|
||||||
});
|
});
|
||||||
// 全屏
|
// 全屏
|
||||||
if (!Global.getInstance().isPDA) list.push({
|
if (!this.tornPDAUtils.isPDA()) list.push({
|
||||||
domType: 'button', domId: '', domText: '🖥️ 进入全屏', clickFunc() {
|
domType: 'button', domId: '', domText: '🖥️ 进入全屏', clickFunc() {
|
||||||
document.documentElement.requestFullscreen().then();
|
document.documentElement.requestFullscreen().then();
|
||||||
}
|
}
|
||||||
@ -418,10 +421,10 @@ export default class ZhongIcon extends WuhuBase {
|
|||||||
// 助手设置
|
// 助手设置
|
||||||
list.push(SettingsHandler);
|
list.push(SettingsHandler);
|
||||||
// 测试
|
// 测试
|
||||||
if (Log.debug()) list.push(Test);
|
if (this.logger.debug()) list.push(Test);
|
||||||
|
|
||||||
this.menuItemList = list;
|
this.menuItemList = list;
|
||||||
Log.info('构造展开菜单列表结束' + timer.getTimeMs());
|
this.logger.info('构造展开菜单列表结束' + timer.getTimeMs());
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,4 @@
|
|||||||
import WuhuBase from "../WuhuBase";
|
|
||||||
import WuhuConfig from "../WuhuConfig";
|
|
||||||
import CommonUtils from "../utils/CommonUtils";
|
import CommonUtils from "../utils/CommonUtils";
|
||||||
import Log from "../Log";
|
|
||||||
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";
|
||||||
@ -14,6 +11,10 @@ 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 ClassName from "../../container/ClassName";
|
||||||
|
import LocalConfigWrapper from "../LocalConfigWrapper";
|
||||||
|
import Logger from "../Logger";
|
||||||
|
|
||||||
enum FIGHT_STAGE {
|
enum FIGHT_STAGE {
|
||||||
READY = 'ready',
|
READY = 'ready',
|
||||||
@ -27,35 +28,46 @@ enum FIGHT_STAGE {
|
|||||||
* 战斗助手
|
* 战斗助手
|
||||||
* TODO 页面加载已经在进行中的战斗时的正确判断
|
* TODO 页面加载已经在进行中的战斗时的正确判断
|
||||||
*/
|
*/
|
||||||
export default class AttackHelper extends WuhuBase {
|
@Injectable()
|
||||||
className = 'AttackHelper';
|
@ClassName('AttackHelper')
|
||||||
|
export default class AttackHelper {
|
||||||
|
|
||||||
private currentStage: FIGHT_STAGE = FIGHT_STAGE.OTHER;
|
private currentStage: FIGHT_STAGE = FIGHT_STAGE.OTHER;
|
||||||
|
|
||||||
constructor() {
|
constructor(
|
||||||
super();
|
private readonly localConfigWrapper: LocalConfigWrapper,
|
||||||
window.setTimeout(() => this.urlMatch(), 0);
|
private readonly commonUtils: CommonUtils,
|
||||||
|
private readonly global: Global,
|
||||||
|
private readonly mathUtils: MathUtils,
|
||||||
|
private readonly actionButtonUtils: ActionButtonUtils,
|
||||||
|
private readonly fetchUtils: FetchUtils,
|
||||||
|
private readonly logger: Logger,
|
||||||
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
private urlMatch(): void {
|
init(): void {
|
||||||
|
window.setTimeout(() => this.init(), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
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') && WuhuConfig.get('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 (CommonUtils.getInstance().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 {
|
||||||
Log.error('[AttackHelper] UID格式不正确');
|
this.logger.error('[AttackHelper] UID格式不正确');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fightingPageHandle(): void {
|
private fightingPageHandle(): void {
|
||||||
// 光速刷新按钮
|
// 光速刷新按钮
|
||||||
ActionButtonUtils.getInstance().add('光速刷新', () => this.doAttackReload());
|
this.actionButtonUtils.add('光速刷新', () => this.doAttackReload());
|
||||||
|
|
||||||
// 盯梢
|
// 盯梢
|
||||||
this.watchTarget();
|
this.watchTarget();
|
||||||
@ -64,14 +76,14 @@ export default class AttackHelper extends WuhuBase {
|
|||||||
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 && WuhuConfig.get('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');
|
||||||
Log.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;
|
||||||
Log.info('[attackHelper] currentStage', this.currentStage);
|
this.logger.info('[attackHelper] currentStage', this.currentStage);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
btnList.forEach(btn => {
|
btnList.forEach(btn => {
|
||||||
@ -87,7 +99,7 @@ export default class AttackHelper extends WuhuBase {
|
|||||||
// 无意识状态FINISHED
|
// 无意识状态FINISHED
|
||||||
this.quickFinishFight(btnList);
|
this.quickFinishFight(btnList);
|
||||||
}
|
}
|
||||||
Log.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 });
|
||||||
@ -97,17 +109,17 @@ export default class AttackHelper extends WuhuBase {
|
|||||||
private doAttackReload(): void {
|
private doAttackReload(): void {
|
||||||
if (!window.ReactDOM) {
|
if (!window.ReactDOM) {
|
||||||
new Alert('光速刷新失败:未找到React对象');
|
new Alert('光速刷新失败:未找到React对象');
|
||||||
Log.error('光速刷新失败:未找到React对象');
|
this.logger.error('光速刷新失败:未找到React对象');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!document.querySelector('#react-root #attacker')) {
|
if (!document.querySelector('#react-root #attacker')) {
|
||||||
Log.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/)) {
|
||||||
Log.error('脚本源[' + url + '] 不匹配规则');
|
this.logger.error('脚本源[' + url + '] 不匹配规则');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
window.ReactDOM.unmountComponentAtNode(document.querySelector('#react-root'));
|
window.ReactDOM.unmountComponentAtNode(document.querySelector('#react-root'));
|
||||||
@ -125,32 +137,32 @@ export default class AttackHelper extends WuhuBase {
|
|||||||
} else {
|
} else {
|
||||||
this.currentStage = FIGHT_STAGE.READY;
|
this.currentStage = FIGHT_STAGE.READY;
|
||||||
}
|
}
|
||||||
if (WuhuConfig.get('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'));
|
||||||
Log.info('操作按钮', { btn });
|
this.logger.info('操作按钮', { btn });
|
||||||
if (!btn.innerText.toLowerCase().includes('fight')) {
|
if (!btn.innerText.toLowerCase().includes('fight')) {
|
||||||
Log.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 = Global.getInstance().device;
|
let device = this.global.device;
|
||||||
Log.info(`当前设备类型是${ device }`);
|
this.logger.info(`当前设备类型是${ device }`);
|
||||||
// 区分设备
|
// 区分设备
|
||||||
switch (device) {
|
switch (device) {
|
||||||
case Device.PC: {
|
case Device.PC: {
|
||||||
Log.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 (WuhuConfig.get('quickAttIndex')) {
|
switch (this.localConfigWrapper.config.quickAttIndex) {
|
||||||
// weapon_second
|
// weapon_second
|
||||||
case 1: {
|
case 1: {
|
||||||
css_top = '97px';
|
css_top = '97px';
|
||||||
@ -180,14 +192,14 @@ export default class AttackHelper extends WuhuBase {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Device.MOBILE: {
|
case Device.MOBILE: {
|
||||||
Log.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 (WuhuConfig.get('quickAttIndex')) {
|
switch (this.localConfigWrapper.config.quickAttIndex) {
|
||||||
case 1: { // weapon_second
|
case 1: { // weapon_second
|
||||||
css_top = '76px';
|
css_top = '76px';
|
||||||
break;
|
break;
|
||||||
@ -215,7 +227,7 @@ export default class AttackHelper extends WuhuBase {
|
|||||||
// TODO 待验证
|
// TODO 待验证
|
||||||
slot_height = height + 'px';
|
slot_height = height + 'px';
|
||||||
// 根据选择的武器调整
|
// 根据选择的武器调整
|
||||||
switch (WuhuConfig.get('quickAttIndex')) {
|
switch (this.localConfigWrapper.config.quickAttIndex) {
|
||||||
case 1: { // weapon_second
|
case 1: { // weapon_second
|
||||||
css_top = `${ height }px`;
|
css_top = `${ height }px`;
|
||||||
break;
|
break;
|
||||||
@ -249,7 +261,7 @@ export default class AttackHelper extends WuhuBase {
|
|||||||
CommonUtils.addStyle(css_rule);
|
CommonUtils.addStyle(css_rule);
|
||||||
document.body.classList.toggle('wh-move-btn');
|
document.body.classList.toggle('wh-move-btn');
|
||||||
btn.onclick = () => {
|
btn.onclick = () => {
|
||||||
if (WuhuConfig.get('quickFinishAtt') !== 3) {
|
if (this.localConfigWrapper.config.quickFinishAtt !== 3) {
|
||||||
btn.remove();
|
btn.remove();
|
||||||
// 停止自动刷新
|
// 停止自动刷新
|
||||||
// stop_reload = true;
|
// stop_reload = true;
|
||||||
@ -273,50 +285,50 @@ export default class AttackHelper extends WuhuBase {
|
|||||||
} else {
|
} else {
|
||||||
this.currentStage = FIGHT_STAGE.FINISHED;
|
this.currentStage = FIGHT_STAGE.FINISHED;
|
||||||
}
|
}
|
||||||
if (WuhuConfig.get('quickFinishAtt') === 3) {
|
if (this.localConfigWrapper.config.quickFinishAtt === 3) {
|
||||||
document.body.classList.remove('wh-move-btn');
|
document.body.classList.remove('wh-move-btn');
|
||||||
Log.info('移除body class wh-move-btn');
|
this.logger.info('移除body class wh-move-btn');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const user_btn_select = ['leave', 'mug', 'hosp'][WuhuConfig.get('quickFinishAtt')];
|
const user_btn_select = ['leave', 'mug', 'hosp'][this.localConfigWrapper.config.quickFinishAtt];
|
||||||
// const wrap = document.querySelector('#react-root');
|
// const wrap = document.querySelector('#react-root');
|
||||||
Log.info('光速跑路选项选中:', user_btn_select);
|
this.logger.info('光速跑路选项选中:', user_btn_select);
|
||||||
// const btn_arr: HTMLButtonElement[] = document.querySelectorAll('div[class^="dialogButtons___"] button') as unknown as HTMLButtonElement[];
|
// const btn_arr: HTMLButtonElement[] = document.querySelectorAll('div[class^="dialogButtons___"] button') as unknown as HTMLButtonElement[];
|
||||||
if (btnList.length > 1) btnList.forEach(btn => {
|
if (btnList.length > 1) btnList.forEach(btn => {
|
||||||
const flag = btn.innerText.toLowerCase().includes(user_btn_select);
|
const flag = btn.innerText.toLowerCase().includes(user_btn_select);
|
||||||
Log.info('按钮内容:', btn.innerText, ',是否包含选中:', flag);
|
this.logger.info('按钮内容:', btn.innerText, ',是否包含选中:', flag);
|
||||||
if (!flag) btn.style.display = 'none';
|
if (!flag) btn.style.display = 'none';
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// 盯梢模式
|
// 盯梢模式
|
||||||
private watchTarget(): void {
|
private watchTarget(): void {
|
||||||
Log.info('获取目标id');
|
this.logger.info('获取目标id');
|
||||||
let targetId = window.location.href.split('user2ID=')[1];
|
let targetId = window.location.href.split('user2ID=')[1];
|
||||||
if (!CommonUtils.getInstance().isValidUid(targetId)) {
|
if (!this.commonUtils.isValidUid(targetId)) {
|
||||||
Log.error('目标id获取错误', targetId);
|
this.logger.error('目标id获取错误', targetId);
|
||||||
throw new Error('目标id获取错误:' + targetId);
|
throw new Error('目标id获取错误:' + targetId);
|
||||||
}
|
}
|
||||||
let loop = new LoopHelper(async () => {
|
let loop = new LoopHelper(async () => {
|
||||||
let userProfile;
|
let userProfile;
|
||||||
try {
|
try {
|
||||||
userProfile = await FetchUtils.getInstance().getProfile(targetId);
|
userProfile = await this.fetchUtils.getProfile(targetId);
|
||||||
} catch {
|
} catch {
|
||||||
Log.error('盯梢模式无法获取目标id');
|
this.logger.error('盯梢模式无法获取目标id');
|
||||||
throw new Error('盯梢模式无法获取目标id');
|
throw new Error('盯梢模式无法获取目标id');
|
||||||
}
|
}
|
||||||
await CommonUtils.getInstance().sleep(MathUtils.getInstance().getRandomInt(20, 50));
|
await this.commonUtils.sleep(this.mathUtils.getRandomInt(20, 50));
|
||||||
if ((userProfile.userStatus.status === 'ok' && CommonUtils.getInstance().getTravelStage() === TRAVEL_STATE.IN_TORN) ||
|
if ((userProfile.userStatus.status === 'ok' && this.commonUtils.getTravelStage() === TRAVEL_STATE.IN_TORN) ||
|
||||||
(userProfile.userStatus.status === 'abroad' && CommonUtils.getInstance().getTravelStage() === TRAVEL_STATE.ABROAD)) {
|
(userProfile.userStatus.status === 'abroad' && this.commonUtils.getTravelStage() === TRAVEL_STATE.ABROAD)) {
|
||||||
watchSwitch.getInput().checked = false;
|
watchSwitch.getInput().checked = false;
|
||||||
window.setTimeout(async () => {
|
window.setTimeout(async () => {
|
||||||
new Alert('目标已落地/出院/出狱!', { timeout: 10, force: true, sysNotify: true });
|
new Alert('目标已落地/出院/出狱!', { timeout: 10, force: true, sysNotify: true });
|
||||||
await CommonUtils.getInstance().audioPlay();
|
await this.commonUtils.audioPlay();
|
||||||
await CommonUtils.getInstance().sleep(300);
|
await this.commonUtils.sleep(300);
|
||||||
await CommonUtils.getInstance().audioPlay();
|
await this.commonUtils.audioPlay();
|
||||||
await CommonUtils.getInstance().sleep(300);
|
await this.commonUtils.sleep(300);
|
||||||
await CommonUtils.getInstance().audioPlay();
|
await this.commonUtils.audioPlay();
|
||||||
await CommonUtils.getInstance().sleep(300);
|
await this.commonUtils.sleep(300);
|
||||||
}, 0);
|
}, 0);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -327,19 +339,19 @@ export default class AttackHelper extends WuhuBase {
|
|||||||
if (watchSwitch.getInput().checked) {
|
if (watchSwitch.getInput().checked) {
|
||||||
new DialogMsgBox('检测玩家状态,当目标状态变成(海外)落地、出院或出狱时通知并播放声音提醒,后可搭配光速刷新食用<br/>确定开启?', {
|
new DialogMsgBox('检测玩家状态,当目标状态变成(海外)落地、出院或出狱时通知并播放声音提醒,后可搭配光速刷新食用<br/>确定开启?', {
|
||||||
callback: () => {
|
callback: () => {
|
||||||
if (CommonUtils.getInstance().getTravelStage() === TRAVEL_STATE.FLYING) {
|
if (this.commonUtils.getTravelStage() === TRAVEL_STATE.FLYING) {
|
||||||
new Alert('失败!已取消');
|
new Alert('失败!已取消');
|
||||||
watchSwitch.getInput().checked = false;
|
watchSwitch.getInput().checked = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Log.info('盯梢开启, 目标id' + targetId);
|
this.logger.info('盯梢开启, 目标id' + targetId);
|
||||||
loop.start(parseInt(WuhuConfig.get('WatchTargetFreq')));
|
loop.start(this.localConfigWrapper.config.WatchTargetFreq | 0);
|
||||||
},
|
},
|
||||||
cancel: () => watchSwitch.getInput().checked = false
|
cancel: () => watchSwitch.getInput().checked = false
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
loop.stop();
|
loop.stop();
|
||||||
Log.info('盯梢关闭');
|
this.logger.info('盯梢关闭');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
import WuhuBase from "../WuhuBase";
|
|
||||||
import WuhuConfig from "../WuhuConfig";
|
import WuhuConfig from "../WuhuConfig";
|
||||||
import Log from "../Log";
|
import Log from "../Log";
|
||||||
import InfoUtils from "../utils/InfoUtils";
|
import InfoUtils from "../utils/InfoUtils";
|
||||||
@ -8,27 +7,36 @@ import NOTIFY_HTML from "../../../static/html/buyBeer/notify.html";
|
|||||||
import CommonUtils from "../utils/CommonUtils";
|
import CommonUtils from "../utils/CommonUtils";
|
||||||
import Popup from "../utils/Popup";
|
import Popup from "../utils/Popup";
|
||||||
import ResponseInject from "../../interface/ResponseInject";
|
import ResponseInject from "../../interface/ResponseInject";
|
||||||
|
import LocalConfigWrapper from "../LocalConfigWrapper";
|
||||||
|
import ClassName from "../../container/ClassName";
|
||||||
|
import { Injectable } from "../../container/Injectable";
|
||||||
|
|
||||||
export default class BuyBeerHelper extends WuhuBase implements BeerMonitorLoop, ResponseInject {
|
@ClassName('BuyBeerHelper')
|
||||||
className = 'BuyBeerHelper';
|
@Injectable()
|
||||||
|
export default class BuyBeerHelper implements BeerMonitorLoop, ResponseInject {
|
||||||
|
|
||||||
private isNotifying = false;
|
private isNotifying = false;
|
||||||
private loopId: number = null;
|
private loopId: number = null;
|
||||||
private time: number;
|
private time: number;
|
||||||
private readonly notifyHtml: string = NOTIFY_HTML.replace('{{}}', MathUtils.getInstance().getRandomInt(0, 99).toString());
|
private readonly notifyHtml: string = NOTIFY_HTML.replace('{{}}', this.mathUtils.getRandomInt(0, 99).toString());
|
||||||
|
|
||||||
public constructor() {
|
public constructor(
|
||||||
super();
|
private readonly localConfigWrapper: LocalConfigWrapper,
|
||||||
this.time = WuhuConfig.get('_15AlarmTime') || 30;
|
private readonly commonUtils: CommonUtils,
|
||||||
|
private readonly infoUtils: InfoUtils,
|
||||||
|
private readonly mathUtils: MathUtils,
|
||||||
|
) {
|
||||||
|
this.time = this.localConfigWrapper.config._15AlarmTime || 30;
|
||||||
}
|
}
|
||||||
|
|
||||||
public start(): void {
|
public start(): void {
|
||||||
if (this.loopId) {
|
if (this.loopId) {
|
||||||
Log.info('啤酒助手已在运行');
|
Log.info('啤酒助手已在运行');
|
||||||
} else {
|
} else {
|
||||||
|
Log.info('啤酒助手启动');
|
||||||
this.loopId = window.setInterval(async () => {
|
this.loopId = window.setInterval(async () => {
|
||||||
// 海外取消提醒
|
// 海外取消提醒
|
||||||
let { isTravelling, isAbroad } = await InfoUtils.getInstance().getUserState();
|
let { isTravelling, isAbroad } = await this.infoUtils.getUserState();
|
||||||
if (isTravelling || isAbroad) {
|
if (isTravelling || isAbroad) {
|
||||||
this.stop();
|
this.stop();
|
||||||
return;
|
return;
|
||||||
@ -36,7 +44,7 @@ export default class BuyBeerHelper extends WuhuBase implements BeerMonitorLoop,
|
|||||||
let dt = new Date();
|
let dt = new Date();
|
||||||
// 已选当天不提醒
|
// 已选当天不提醒
|
||||||
const now = [dt.getUTCFullYear(), dt.getUTCMonth(), dt.getUTCDate()];
|
const now = [dt.getUTCFullYear(), dt.getUTCMonth(), dt.getUTCDate()];
|
||||||
const ignore_date = WuhuConfig.get('_15_alarm_ignore') || '{}';
|
const ignore_date = this.localConfigWrapper.config._15_alarm_ignore || '{}';
|
||||||
if (JSON.stringify(now) === JSON.stringify(ignore_date)) return;
|
if (JSON.stringify(now) === JSON.stringify(ignore_date)) return;
|
||||||
// 正常提醒
|
// 正常提醒
|
||||||
let m = 14 - (dt.getMinutes() % 15);
|
let m = 14 - (dt.getMinutes() % 15);
|
||||||
@ -62,10 +70,15 @@ export default class BuyBeerHelper extends WuhuBase implements BeerMonitorLoop,
|
|||||||
notify.close();
|
notify.close();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
let audioPlay = CommonUtils.getInstance().audioPlay;
|
// 声音提醒
|
||||||
window.setTimeout(audioPlay, 800);
|
{
|
||||||
window.setTimeout(audioPlay, 800 * 2);
|
let loop = 3;
|
||||||
window.setTimeout(audioPlay, 800 * 3);
|
let id = window.setInterval(async () => {
|
||||||
|
await this.commonUtils.audioPlay();
|
||||||
|
loop--;
|
||||||
|
if (!loop) window.clearInterval(id);
|
||||||
|
}, 800);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
this.isNotifying = false;
|
this.isNotifying = false;
|
||||||
}
|
}
|
||||||
@ -96,29 +109,29 @@ export default class BuyBeerHelper extends WuhuBase implements BeerMonitorLoop,
|
|||||||
const date = new Date();
|
const date = new Date();
|
||||||
WuhuConfig.set('_15_alarm_ignore', [date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate()], false);
|
WuhuConfig.set('_15_alarm_ignore', [date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate()], false);
|
||||||
// 通知
|
// 通知
|
||||||
const notify = new Alert(`明早8点前将不再提醒 <button id="wh-rd-btn-${ MathUtils.getInstance().getRandomInt(0, 100) }">取消</button>`);
|
const notify = new Alert(`明早8点前将不再提醒 <button id="wh-rd-btn-${ this.mathUtils.getRandomInt(0, 100) }">取消</button>`);
|
||||||
// 通知中的取消按钮
|
// 通知中的取消按钮
|
||||||
notify.getElement().querySelector('.wh-notify-msg button').addEventListener('click', () => WuhuConfig.set('_15_alarm_ignore', undefined, true));
|
notify.getElement().querySelector('.wh-notify-msg button').addEventListener('click', () => WuhuConfig.set('_15_alarm_ignore', undefined, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
public setTimeHandler(): void {
|
public setTimeHandler(): void {
|
||||||
let popup = new Popup(`<label>提前提醒时间(秒):<input type="number" value="${ WuhuConfig.get('_15AlarmTime') }" /></label><p>区间为 1 ~ 60,默认 50</p>`, '啤酒提醒时间设定');
|
let popup = new Popup(`<label>提前提醒时间(秒):<input type="number" value="${ this.localConfigWrapper.config._15AlarmTime }" /></label><p>区间为 1 ~ 60,默认 50</p>`, '啤酒提醒时间设定');
|
||||||
let confirm = document.createElement('button');
|
let confirm = document.createElement('button');
|
||||||
confirm.innerHTML = '确定';
|
confirm.innerHTML = '确定';
|
||||||
confirm.style.float = 'right';
|
confirm.style.float = 'right';
|
||||||
confirm.addEventListener('click', () => {
|
confirm.addEventListener('click', () => {
|
||||||
let input: HTMLInputElement = popup.getElement().querySelector('input');
|
let input: HTMLInputElement = popup.element.querySelector('input');
|
||||||
let num = (input.value as any) | 0;
|
let num = (input.value as any) | 0;
|
||||||
if (num === WuhuConfig.get('_15AlarmTime')) return;
|
if (num === this.localConfigWrapper.config._15AlarmTime) return;
|
||||||
if (num < 1 || num > 60) num = 50;
|
if (num < 1 || num > 60) num = 50;
|
||||||
input.value = num.toString();
|
input.value = num.toString();
|
||||||
WuhuConfig.set('_15AlarmTime', num);
|
this.localConfigWrapper.config._15AlarmTime = num;
|
||||||
this.set_time(num);
|
this.set_time(num);
|
||||||
// 之前的运行状态
|
// 之前的运行状态
|
||||||
if (this.is_running()) this.start();
|
if (this.is_running()) this.start();
|
||||||
popup.close();
|
popup.close();
|
||||||
});
|
});
|
||||||
popup.getElement().appendChild(confirm);
|
popup.element.appendChild(confirm);
|
||||||
}
|
}
|
||||||
|
|
||||||
public responseHandler(url: string, body: { json: unknown; text: string; isModified: boolean }, opt: { method: "GET" | "POST"; requestBody: string }) {
|
public responseHandler(url: string, body: { json: unknown; text: string; isModified: boolean }, opt: { method: "GET" | "POST"; requestBody: string }) {
|
||||||
@ -126,7 +139,7 @@ export default class BuyBeerHelper extends WuhuBase implements BeerMonitorLoop,
|
|||||||
let req = opt.requestBody;
|
let req = opt.requestBody;
|
||||||
if (req && req.includes('step=buyShopItem') && req.includes('ID=180') && body.json && body.json['success']) {
|
if (req && req.includes('step=buyShopItem') && req.includes('ID=180') && body.json && body.json['success']) {
|
||||||
new Alert('检测到已成功购买啤酒');
|
new Alert('检测到已成功购买啤酒');
|
||||||
BuyBeerHelper.getInstance().skip_today();
|
this.skip_today();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,27 +1,38 @@
|
|||||||
import WuhuBase from "../WuhuBase";
|
|
||||||
import WuhuConfig from "../WuhuConfig";
|
|
||||||
import Log from "../Log";
|
|
||||||
import CommonUtils from "../utils/CommonUtils";
|
import CommonUtils from "../utils/CommonUtils";
|
||||||
import FetchUtils from "../utils/FetchUtils";
|
import FetchUtils from "../utils/FetchUtils";
|
||||||
import InfoUtils from "../utils/InfoUtils";
|
import InfoUtils from "../utils/InfoUtils";
|
||||||
import Alert from "../utils/Alert";
|
import Alert from "../utils/Alert";
|
||||||
import TRAVEL_STATE from "../../enum/TravelState";
|
import TRAVEL_STATE from "../../enum/TravelState";
|
||||||
|
import LocalConfigWrapper from "../LocalConfigWrapper";
|
||||||
|
import { Injectable } from "../../container/Injectable";
|
||||||
|
import ClassName from "../../container/ClassName";
|
||||||
|
import Logger from "../Logger";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 公司助手
|
* 公司助手
|
||||||
*/
|
*/
|
||||||
export default class CompanyHelper extends WuhuBase {
|
@Injectable()
|
||||||
|
@ClassName('CompanyHelper')
|
||||||
|
export default class CompanyHelper {
|
||||||
className = 'CompanyHelper';
|
className = 'CompanyHelper';
|
||||||
|
|
||||||
public constructor() {
|
public constructor(
|
||||||
super();
|
private readonly localConfigWrapper: LocalConfigWrapper,
|
||||||
WuhuConfig.get('CHTrainsDetectSwitch') && this.trainsDetect().then();
|
private readonly commonUtils: CommonUtils,
|
||||||
|
private readonly fetchUtils: FetchUtils,
|
||||||
|
private readonly logger: Logger,
|
||||||
|
private readonly infoUtils: InfoUtils,
|
||||||
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public detectNow(): void {
|
init(): void {
|
||||||
this.trainsDetect(true).then();
|
this.localConfigWrapper.config.CHTrainsDetectSwitch && this.trainsDetect().then();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// public detectNow(): void {
|
||||||
|
// this.trainsDetect(true).then();
|
||||||
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 火车检测
|
* 火车检测
|
||||||
* 每日判断一次,非公司老板跳过检测
|
* 每日判断一次,非公司老板跳过检测
|
||||||
@ -29,24 +40,24 @@ export default class CompanyHelper extends WuhuBase {
|
|||||||
*/
|
*/
|
||||||
private async trainsDetect(test: boolean = false): Promise<null> {
|
private async trainsDetect(test: boolean = false): Promise<null> {
|
||||||
// 通过用户的icon判断公司老板
|
// 通过用户的icon判断公司老板
|
||||||
if ((await InfoUtils.getInstance().getSessionData()).statusIcons.icons.company.iconID !== 'icon73') {
|
if ((await this.infoUtils.getSessionData()).statusIcons.icons.company.iconID !== 'icon73') {
|
||||||
Log.info('火车检测跳过:非公司老板');
|
this.logger.info('火车检测跳过:非公司老板');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 上次检测时间戳
|
// 上次检测时间戳
|
||||||
let lastDetect: number = WuhuConfig.get('CHTrainsDetect') || 0;
|
let lastDetect: number = this.localConfigWrapper.config.CHTrainsDetect || 0;
|
||||||
// 检测是否过了一天
|
// 检测是否过了一天
|
||||||
if (test || CommonUtils.getInstance().isNewDay(lastDetect, -6)) {
|
if (test || this.commonUtils.isNewDay(lastDetect, -6)) {
|
||||||
let travelStage = CommonUtils.getInstance().getTravelStage(),
|
let travelStage = this.commonUtils.getTravelStage(),
|
||||||
userStatus = (await InfoUtils.getInstance().getUserState()).status;
|
userStatus = (await this.infoUtils.getUserState()).status;
|
||||||
test && Log.info({ travelStage, userStatus });
|
test && this.logger.info({ travelStage, userStatus });
|
||||||
if (travelStage === TRAVEL_STATE.IN_TORN && userStatus === 'ok')
|
if (travelStage === TRAVEL_STATE.IN_TORN && userStatus === 'ok')
|
||||||
FetchUtils.getInstance().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 = CommonUtils.getInstance().matchOne(res, /<body.+>/);
|
let bodyTagStart = this.commonUtils.matchOne(res, /<body.+>/);
|
||||||
if (!bodyTagStart) {
|
if (!bodyTagStart) {
|
||||||
Log.warn('火车检测: 无法获取数据');
|
this.logger.warn('火车检测: 无法获取数据');
|
||||||
throw new Error('火车检测: 无法获取数据');
|
throw new Error('火车检测: 无法获取数据');
|
||||||
}
|
}
|
||||||
tmp.innerHTML = res.split(bodyTagStart)[1].split('</body>')[0].trim()
|
tmp.innerHTML = res.split(bodyTagStart)[1].split('</body>')[0].trim()
|
||||||
@ -55,14 +66,15 @@ export default class CompanyHelper extends WuhuBase {
|
|||||||
.replaceAll('type="text/javascript"', 'type="application/json"');
|
.replaceAll('type="text/javascript"', 'type="application/json"');
|
||||||
let trainsNode = tmp.querySelector('span.trains');
|
let trainsNode = tmp.querySelector('span.trains');
|
||||||
if (!trainsNode) {
|
if (!trainsNode) {
|
||||||
Log.error('火车检测出错: 无法获取火车数');
|
this.logger.error('火车检测出错: 无法获取火车数');
|
||||||
throw new Error('火车检测出错: 无法获取火车数');
|
throw new Error('火车检测出错: 无法获取火车数');
|
||||||
}
|
}
|
||||||
let trains: number = parseInt(trainsNode.innerText);
|
let trains: number = parseInt(trainsNode.innerText);
|
||||||
let stars: number = tmp.querySelectorAll('.company-rating .active').length / 2 || 1;
|
let stars: number = tmp.querySelectorAll('.company-rating .active').length / 2 || 1;
|
||||||
WuhuConfig.set('CHTrainsDetect', Date.now());
|
// WuhuConfig.set('CHTrainsDetect', Date.now());
|
||||||
Log.info('火车检测: 火车/星级: ' + trains + '/' + stars);
|
this.localConfigWrapper.config.CHTrainsDetect = Date.now();
|
||||||
Log.info({ tmp });
|
this.logger.info('火车检测: 火车/星级: ' + trains + '/' + stars);
|
||||||
|
this.logger.info({ tmp });
|
||||||
if (trains + stars > 20) {
|
if (trains + stars > 20) {
|
||||||
new Alert(`公司助手<br/><br/>火车检测:火车明日将溢出!${ trains }/20火车`, {
|
new Alert(`公司助手<br/><br/>火车检测:火车明日将溢出!${ trains }/20火车`, {
|
||||||
timeout: 15,
|
timeout: 15,
|
||||||
@ -74,11 +86,11 @@ export default class CompanyHelper extends WuhuBase {
|
|||||||
tmp = null;
|
tmp = null;
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
Log.error('火车检测出错', error);
|
this.logger.error('火车检测出错', error);
|
||||||
});
|
});
|
||||||
else Log.warn('[火车检测] 用户状态错误,跳过火车检测', { travelStage, userStatus });
|
else this.logger.warn('[火车检测] 用户状态错误,跳过火车检测', { travelStage, userStatus });
|
||||||
} else {
|
} else {
|
||||||
Log.info('火车检测:今日已提醒,跳过');
|
this.logger.info('火车检测:今日已提醒,跳过');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,15 +1,26 @@
|
|||||||
import { MiniProfile } from "../../interface/responseType/MiniProfile";
|
import { MiniProfile } from "../../interface/responseType/MiniProfile";
|
||||||
import CommonUtils from "../utils/CommonUtils";
|
import CommonUtils from "../utils/CommonUtils";
|
||||||
import WuhuConfig from "../WuhuConfig";
|
|
||||||
import Provider from "../provider/Provider";
|
import Provider from "../provider/Provider";
|
||||||
import ResponseInject from "../../interface/ResponseInject";
|
import ResponseInject from "../../interface/ResponseInject";
|
||||||
|
import { Injectable } from "../../container/Injectable";
|
||||||
|
import ClassName from "../../container/ClassName";
|
||||||
|
import LocalConfigWrapper from "../LocalConfigWrapper";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* fetch 事件监听回调
|
* fetch 事件监听回调
|
||||||
*/
|
*/
|
||||||
|
@Injectable()
|
||||||
|
@ClassName("FetchEventCallback")
|
||||||
export default class FetchEventCallback extends Provider implements ResponseInject {
|
export default class FetchEventCallback extends Provider implements ResponseInject {
|
||||||
className = "FetchEventCallback";
|
className = "FetchEventCallback";
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
private readonly localConfigWrapper: LocalConfigWrapper,
|
||||||
|
private readonly commonUtils: CommonUtils,
|
||||||
|
) {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* fetch 返回后处理
|
* fetch 返回后处理
|
||||||
* @param url
|
* @param url
|
||||||
@ -17,12 +28,12 @@ export default class FetchEventCallback extends Provider implements ResponseInje
|
|||||||
*/
|
*/
|
||||||
public responseHandler(url: string, response) {
|
public responseHandler(url: string, response) {
|
||||||
// mini profile 中添加上次动作
|
// mini profile 中添加上次动作
|
||||||
if (url.includes('profiles.php?step=getUserNameContextMenu') && WuhuConfig.get('ShowMiniProfLastAct')) {
|
if (url.includes('profiles.php?step=getUserNameContextMenu') && this.localConfigWrapper.config.ShowMiniProfLastAct) {
|
||||||
window.setTimeout(async () => {
|
window.setTimeout(async () => {
|
||||||
let cont = CommonUtils.querySelector('[class*=profile-mini-_userProfileWrapper___]');
|
let cont = CommonUtils.querySelector('[class*=profile-mini-_userProfileWrapper___]');
|
||||||
let resp: MiniProfile = response.json as MiniProfile;
|
let resp: MiniProfile = response.json as MiniProfile;
|
||||||
let newNode = document.createElement('div');
|
let newNode = document.createElement('div');
|
||||||
let formatted = CommonUtils.getInstance().secondsFormat(resp.user.lastAction.seconds);
|
let formatted = this.commonUtils.secondsFormat(resp.user.lastAction.seconds);
|
||||||
|
|
||||||
newNode.innerText = '上次动作: ' + formatted;
|
newNode.innerText = '上次动作: ' + formatted;
|
||||||
(await cont).append(newNode);
|
(await cont).append(newNode);
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
import WuhuBase from "../WuhuBase";
|
|
||||||
import Log from "../Log";
|
import Log from "../Log";
|
||||||
import InfoUtils from "../utils/InfoUtils";
|
import InfoUtils from "../utils/InfoUtils";
|
||||||
import MathUtils from "../utils/MathUtils";
|
import MathUtils from "../utils/MathUtils";
|
||||||
@ -6,12 +5,15 @@ import CommonUtils from "../utils/CommonUtils";
|
|||||||
import TornStyleBlock from "../utils/TornStyleBlock";
|
import TornStyleBlock from "../utils/TornStyleBlock";
|
||||||
import Timer from "../utils/Timer";
|
import Timer from "../utils/Timer";
|
||||||
import FetchUtils from "../utils/FetchUtils";
|
import FetchUtils from "../utils/FetchUtils";
|
||||||
|
import { Injectable } from "../../container/Injectable";
|
||||||
|
import ClassName from "../../container/ClassName";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 彩票助手
|
* 彩票助手
|
||||||
*/
|
*/
|
||||||
export default class LotteryHelper extends WuhuBase {
|
@Injectable()
|
||||||
className = 'LotteryHelper';
|
@ClassName('LotteryHelper')
|
||||||
|
export default class LotteryHelper {
|
||||||
private loopFlag = true;
|
private loopFlag = true;
|
||||||
|
|
||||||
private radioDaily: HTMLInputElement = null;
|
private radioDaily: HTMLInputElement = null;
|
||||||
@ -24,7 +26,13 @@ export default class LotteryHelper extends WuhuBase {
|
|||||||
private status: HTMLElement = null;
|
private status: HTMLElement = null;
|
||||||
private desc: HTMLElement = null;
|
private desc: HTMLElement = null;
|
||||||
|
|
||||||
private readonly mathUtils = MathUtils.getInstance();
|
constructor(
|
||||||
|
private readonly mathUtils: MathUtils,
|
||||||
|
private readonly commonUtils: CommonUtils,
|
||||||
|
private readonly fetchUtils: FetchUtils,
|
||||||
|
private readonly infoUtils: InfoUtils,
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
public init() {
|
public init() {
|
||||||
let startTime = new Timer();
|
let startTime = new Timer();
|
||||||
@ -118,7 +126,7 @@ export default class LotteryHelper extends WuhuBase {
|
|||||||
if (inputNumber > 0) {
|
if (inputNumber > 0) {
|
||||||
let msg = document.querySelector('.info-msg-wrap .msg').innerText.trim().split(' ');
|
let msg = document.querySelector('.info-msg-wrap .msg').innerText.trim().split(' ');
|
||||||
let current = {
|
let current = {
|
||||||
money: (await InfoUtils.getInstance().getSessionData()).user.money.value,
|
money: (await this.infoUtils.getSessionData()).user.money.value,
|
||||||
token: parseInt(msg[4])
|
token: parseInt(msg[4])
|
||||||
};
|
};
|
||||||
let lotteryType = 1;
|
let lotteryType = 1;
|
||||||
@ -136,12 +144,12 @@ export default class LotteryHelper extends WuhuBase {
|
|||||||
rsMsg = `终止操作,已完成${ i }/${ inputNumber }`;
|
rsMsg = `终止操作,已完成${ i }/${ inputNumber }`;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
await FetchUtils.getInstance().ajaxFetch({
|
await this.fetchUtils.ajaxFetch({
|
||||||
url: window.addRFC('https://www.torn.com/loader.php?sid=lotteryPlay&step=buyTicket&lotteryID=' + lotteryType),
|
url: window.addRFC('https://www.torn.com/loader.php?sid=lotteryPlay&step=buyTicket&lotteryID=' + lotteryType),
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
referrer: '/loader.php?sid=lottery',
|
referrer: '/loader.php?sid=lottery',
|
||||||
});
|
});
|
||||||
await CommonUtils.getInstance().sleep(this.mathUtils.getRandomInt(20, 50));
|
await this.commonUtils.sleep(this.mathUtils.getRandomInt(20, 50));
|
||||||
i++;
|
i++;
|
||||||
this.desc.innerHTML = `已买${ i }张彩票`;
|
this.desc.innerHTML = `已买${ i }张彩票`;
|
||||||
this.status.innerHTML = `${ i }/${ inputNumber }`;
|
this.status.innerHTML = `${ i }/${ inputNumber }`;
|
||||||
|
|||||||
@ -1,16 +1,19 @@
|
|||||||
import WuhuBase from "../WuhuBase";
|
|
||||||
import TornStyleBlock from "../utils/TornStyleBlock";
|
import TornStyleBlock from "../utils/TornStyleBlock";
|
||||||
import WuhuConfig from "../WuhuConfig";
|
|
||||||
import Alert from "../utils/Alert";
|
import Alert from "../utils/Alert";
|
||||||
import TornStyleSwitch from "../utils/TornStyleSwitch";
|
import TornStyleSwitch from "../utils/TornStyleSwitch";
|
||||||
|
import { Injectable } from "../../container/Injectable";
|
||||||
|
import ClassName from "../../container/ClassName";
|
||||||
|
import LocalConfigWrapper from "../LocalConfigWrapper";
|
||||||
|
|
||||||
export default class PTHelper extends WuhuBase {
|
@Injectable()
|
||||||
className = 'PTHelper';
|
@ClassName('PTHelper')
|
||||||
|
export default class PTHelper {
|
||||||
private readonly observer;
|
private readonly observer;
|
||||||
private readonly usersPointSell;
|
private readonly usersPointSell;
|
||||||
|
|
||||||
constructor() {
|
constructor(
|
||||||
super();
|
private readonly localConfigWrapper: LocalConfigWrapper,
|
||||||
|
) {
|
||||||
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))
|
||||||
@ -22,7 +25,7 @@ export default class PTHelper extends WuhuBase {
|
|||||||
let switcher = new TornStyleSwitch('开启');
|
let switcher = new TornStyleSwitch('开启');
|
||||||
block.append(switcher.getBase());
|
block.append(switcher.getBase());
|
||||||
let toggle = switcher.getInput();
|
let toggle = switcher.getInput();
|
||||||
toggle.checked = WuhuConfig.get('ptQuickBuy');
|
toggle.checked = this.localConfigWrapper.config.ptQuickBuy;
|
||||||
if (toggle.checked) {
|
if (toggle.checked) {
|
||||||
new Alert('一键购买已开启');
|
new Alert('一键购买已开启');
|
||||||
for (const index in this.usersPointSell.children) {
|
for (const index in this.usersPointSell.children) {
|
||||||
@ -31,7 +34,7 @@ export default class PTHelper extends WuhuBase {
|
|||||||
this.observer.observe(this.usersPointSell, { childList: true })
|
this.observer.observe(this.usersPointSell, { childList: true })
|
||||||
}
|
}
|
||||||
toggle.addEventListener('change', () => {
|
toggle.addEventListener('change', () => {
|
||||||
WuhuConfig.set('ptQuickBuy', toggle.checked, false);
|
this.localConfigWrapper.config.ptQuickBuy = toggle.checked;
|
||||||
if (toggle.checked) {
|
if (toggle.checked) {
|
||||||
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])
|
||||||
|
|||||||
@ -1,5 +1,3 @@
|
|||||||
import WuhuBase from "../WuhuBase";
|
|
||||||
import Log from "../Log";
|
|
||||||
import WuhuConfig from "../WuhuConfig";
|
import WuhuConfig from "../WuhuConfig";
|
||||||
import CommonUtils from "../utils/CommonUtils";
|
import CommonUtils from "../utils/CommonUtils";
|
||||||
import TornStyleBlock from "../utils/TornStyleBlock";
|
import TornStyleBlock from "../utils/TornStyleBlock";
|
||||||
@ -7,37 +5,45 @@ import TornStyleSwitch from "../utils/TornStyleSwitch";
|
|||||||
import ResponseInject from "../../interface/ResponseInject";
|
import ResponseInject from "../../interface/ResponseInject";
|
||||||
import globVars from "../../globVars";
|
import globVars from "../../globVars";
|
||||||
import IUserProfileData from "../../interface/IUserProfileData";
|
import IUserProfileData from "../../interface/IUserProfileData";
|
||||||
|
import ClassName from "../../container/ClassName";
|
||||||
|
import { Injectable } from "../../container/Injectable";
|
||||||
|
import LocalConfigWrapper from "../LocalConfigWrapper";
|
||||||
|
import Logger from "../Logger";
|
||||||
|
|
||||||
export default class ProfileHelper extends WuhuBase implements ResponseInject {
|
@ClassName('ProfileHelper')
|
||||||
className = 'ProfileHelper';
|
@Injectable()
|
||||||
|
export default class ProfileHelper implements ResponseInject {
|
||||||
|
|
||||||
private readonly block;
|
private readonly block;
|
||||||
|
|
||||||
// 曾用名已检测过标记
|
// 曾用名已检测过标记
|
||||||
private task = true;
|
private task = true;
|
||||||
|
|
||||||
constructor() {
|
constructor(
|
||||||
super();
|
private readonly localConfigWrapper: LocalConfigWrapper,
|
||||||
|
private readonly commonUtils: CommonUtils,
|
||||||
|
private readonly logger: Logger,
|
||||||
|
) {
|
||||||
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');
|
||||||
// id获取格式判断
|
// id获取格式判断
|
||||||
if (!CommonUtils.getInstance().isValidUid(id)) {
|
if (!this.commonUtils.isValidUid(id)) {
|
||||||
Log.error('[ProfileHelper] id格式错误');
|
this.logger.error('[ProfileHelper] id格式错误');
|
||||||
}
|
}
|
||||||
if (WuhuConfig.get('HideProfileImg')) {
|
if (this.localConfigWrapper.config.HideProfileImg) {
|
||||||
Log.info('[ProfileHelper] 隐藏头像');
|
this.logger.info('[ProfileHelper] 隐藏头像');
|
||||||
document.body.classList.toggle('wh-hide_profile_img');
|
document.body.classList.toggle('wh-hide_profile_img');
|
||||||
}
|
}
|
||||||
this.block = new TornStyleBlock('芜湖助手').insert2Dom();
|
this.block = new TornStyleBlock('芜湖助手').insert2Dom();
|
||||||
// 隐藏头像
|
// 隐藏头像
|
||||||
let hideImgSwitch = new TornStyleSwitch('隐藏头像', WuhuConfig.get('HideProfileImg'));
|
let hideImgSwitch = new TornStyleSwitch('隐藏头像', this.localConfigWrapper.config.HideProfileImg);
|
||||||
this.block.append(hideImgSwitch.getBase());
|
this.block.append(hideImgSwitch.getBase());
|
||||||
hideImgSwitch.getInput().addEventListener('change', () => {
|
hideImgSwitch.getInput().addEventListener('change', () => {
|
||||||
document.body.classList.toggle('wh-hide_profile_img');
|
document.body.classList.toggle('wh-hide_profile_img');
|
||||||
WuhuConfig.set('HideProfileImg', hideImgSwitch.getInput().checked, true);
|
WuhuConfig.set('HideProfileImg', hideImgSwitch.getInput().checked, true);
|
||||||
});
|
});
|
||||||
if (WuhuConfig.get('ShowNameHistory')) {
|
if (this.localConfigWrapper.config.ShowNameHistory) {
|
||||||
globVars.responseHandlers.push((url, body) => this.responseHandler(url, body));
|
globVars.responseHandlers.push((url, body) => this.responseHandler(url, body));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,14 +1,17 @@
|
|||||||
import WuhuBase from "../WuhuBase";
|
|
||||||
import TornStyleBlock from "../utils/TornStyleBlock";
|
import TornStyleBlock from "../utils/TornStyleBlock";
|
||||||
import TornStyleSwitch from "../utils/TornStyleSwitch";
|
import TornStyleSwitch from "../utils/TornStyleSwitch";
|
||||||
import CommonUtils from "../utils/CommonUtils";
|
import CommonUtils from "../utils/CommonUtils";
|
||||||
import WuhuConfig from "../WuhuConfig";
|
import ClassName from "../../container/ClassName";
|
||||||
|
import { Injectable } from "../../container/Injectable";
|
||||||
|
import LocalConfigWrapper from "../LocalConfigWrapper";
|
||||||
|
|
||||||
export default class SearchHelper extends WuhuBase {
|
@ClassName('SearchHelper')
|
||||||
className = 'SearchHelper';
|
@Injectable()
|
||||||
|
export default class SearchHelper {
|
||||||
|
|
||||||
constructor() {
|
constructor(
|
||||||
super();
|
private readonly localConfigWrapper: LocalConfigWrapper,
|
||||||
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public init(): void {
|
public init(): void {
|
||||||
@ -16,7 +19,7 @@ export default class SearchHelper extends WuhuBase {
|
|||||||
let placeholderSwitch = new TornStyleSwitch('底部空白占位区');
|
let placeholderSwitch = new TornStyleSwitch('底部空白占位区');
|
||||||
block.append(placeholderSwitch.getBase()).insert2Dom();
|
block.append(placeholderSwitch.getBase()).insert2Dom();
|
||||||
CommonUtils.addStyle('body.WHSearchPagePlaceholder .content.logged-in {margin-bottom: 340px;}');
|
CommonUtils.addStyle('body.WHSearchPagePlaceholder .content.logged-in {margin-bottom: 340px;}');
|
||||||
let config = WuhuConfig.get('SearchPagePlaceholder');
|
let config = this.localConfigWrapper.config.SearchPagePlaceholder;
|
||||||
placeholderSwitch.getInput().checked = config || false;
|
placeholderSwitch.getInput().checked = config || false;
|
||||||
config ? this.enable() : this.disable();
|
config ? this.enable() : this.disable();
|
||||||
placeholderSwitch.getInput().addEventListener('change', () => {
|
placeholderSwitch.getInput().addEventListener('change', () => {
|
||||||
@ -26,11 +29,11 @@ export default class SearchHelper extends WuhuBase {
|
|||||||
|
|
||||||
private enable(): void {
|
private enable(): void {
|
||||||
document.body.classList.add('WHSearchPagePlaceholder');
|
document.body.classList.add('WHSearchPagePlaceholder');
|
||||||
WuhuConfig.set('SearchPagePlaceholder', true);
|
this.localConfigWrapper.config.SearchPagePlaceholder = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private disable(): void {
|
private disable(): void {
|
||||||
document.body.classList.remove('WHSearchPagePlaceholder');
|
document.body.classList.remove('WHSearchPagePlaceholder');
|
||||||
WuhuConfig.set('SearchPagePlaceholder', false);
|
this.localConfigWrapper.config.SearchPagePlaceholder = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,27 +1,34 @@
|
|||||||
import WuhuBase from "../WuhuBase";
|
|
||||||
import WuhuConfig from "../WuhuConfig";
|
|
||||||
import CommonUtils from "../utils/CommonUtils";
|
import CommonUtils from "../utils/CommonUtils";
|
||||||
import Global from "../Global";
|
import Global from "../Global";
|
||||||
import Device from "../../enum/Device";
|
import Device from "../../enum/Device";
|
||||||
import Log from "../Log";
|
import Log from "../Log";
|
||||||
|
import ClassName from "../../container/ClassName";
|
||||||
|
import { Injectable } from "../../container/Injectable";
|
||||||
|
import LocalConfigWrapper from "../LocalConfigWrapper";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ### 边栏助手
|
* ### 边栏助手
|
||||||
* - 隐藏按钮
|
* - 隐藏按钮
|
||||||
* - 4条转跳
|
* - 4条转跳
|
||||||
*/
|
*/
|
||||||
export default class SidebarHelper extends WuhuBase {
|
@ClassName('SidebarHelper')
|
||||||
className = 'SidebarHelper';
|
@Injectable()
|
||||||
|
export default class SidebarHelper {
|
||||||
|
|
||||||
private readonly sidebarRootNode: HTMLElement;
|
private readonly sidebarRootNode: HTMLElement;
|
||||||
private readonly toggleBtn: HTMLButtonElement;
|
private readonly toggleBtn: HTMLButtonElement;
|
||||||
private isHide: boolean;
|
private isHide: boolean;
|
||||||
|
|
||||||
constructor() {
|
constructor(
|
||||||
super();
|
private readonly localConfigWrapper: LocalConfigWrapper,
|
||||||
|
private readonly global: Global,
|
||||||
|
) {
|
||||||
this.sidebarRootNode = document.querySelector('#sidebarroot');
|
this.sidebarRootNode = document.querySelector('#sidebarroot');
|
||||||
this.toggleBtn = document.createElement('button');
|
this.toggleBtn = document.createElement('button');
|
||||||
this.isHide = !!WuhuConfig.get('HideSidebar');
|
}
|
||||||
|
|
||||||
|
init(): void {
|
||||||
|
this.isHide = !!this.localConfigWrapper.config.HideSidebar;
|
||||||
|
|
||||||
if (!document.body.classList.contains('without-sidebar') || window.location.href.includes('christmas_town.php')) {
|
if (!document.body.classList.contains('without-sidebar') || window.location.href.includes('christmas_town.php')) {
|
||||||
this.initToggleBtn();
|
this.initToggleBtn();
|
||||||
@ -33,7 +40,7 @@ export default class SidebarHelper extends WuhuBase {
|
|||||||
|
|
||||||
// 初始化隐藏按钮
|
// 初始化隐藏按钮
|
||||||
private initToggleBtn(): void {
|
private initToggleBtn(): void {
|
||||||
if (Global.getInstance().device === Device.PC && this.sidebarRootNode && WuhuConfig.get('HideSidebarBtn')) {
|
if (this.global.device === Device.PC && this.sidebarRootNode && this.localConfigWrapper.config.HideSidebarBtn) {
|
||||||
this.isHide ? this.hideHandler() : this.showHandler();
|
this.isHide ? this.hideHandler() : this.showHandler();
|
||||||
let container = document.createElement('div');
|
let container = document.createElement('div');
|
||||||
container.append(this.toggleBtn);
|
container.append(this.toggleBtn);
|
||||||
@ -50,19 +57,21 @@ export default class SidebarHelper extends WuhuBase {
|
|||||||
|
|
||||||
private hideHandler(): void {
|
private hideHandler(): void {
|
||||||
this.sidebarRootNode.classList.add('wh-hide');
|
this.sidebarRootNode.classList.add('wh-hide');
|
||||||
this.isHide = WuhuConfig.set('HideSidebar', true);
|
this.localConfigWrapper.config.HideSidebar = true;
|
||||||
|
this.isHide = true;
|
||||||
this.toggleBtn.innerHTML = '>>';
|
this.toggleBtn.innerHTML = '>>';
|
||||||
}
|
}
|
||||||
|
|
||||||
private showHandler(): void {
|
private showHandler(): void {
|
||||||
this.sidebarRootNode.classList.remove('wh-hide');
|
this.sidebarRootNode.classList.remove('wh-hide');
|
||||||
this.isHide = WuhuConfig.set('HideSidebar', false);
|
this.localConfigWrapper.config.HideSidebar = false;
|
||||||
|
this.isHide = false;
|
||||||
this.toggleBtn.innerHTML = '<<';
|
this.toggleBtn.innerHTML = '<<';
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4条转跳
|
// 4条转跳
|
||||||
private barRedirect(): void {
|
private barRedirect(): void {
|
||||||
if (WuhuConfig.get('barsRedirect')) {
|
if (this.localConfigWrapper.config.barsRedirect) {
|
||||||
const eb = document.getElementById('barEnergy') as HTMLAnchorElement;
|
const eb = document.getElementById('barEnergy') as HTMLAnchorElement;
|
||||||
const nb = document.getElementById('barNerve') as HTMLAnchorElement;
|
const nb = document.getElementById('barNerve') as HTMLAnchorElement;
|
||||||
const hb = document.getElementById('barHappy') as HTMLAnchorElement;
|
const hb = document.getElementById('barHappy') as HTMLAnchorElement;
|
||||||
|
|||||||
@ -1,16 +1,26 @@
|
|||||||
import WuhuBase from "../WuhuBase";
|
|
||||||
import TornStyleBlock from "../utils/TornStyleBlock";
|
import TornStyleBlock from "../utils/TornStyleBlock";
|
||||||
import InfoUtils from "../utils/InfoUtils";
|
import InfoUtils from "../utils/InfoUtils";
|
||||||
import Log from "../Log";
|
import Log from "../Log";
|
||||||
import FetchUtils from "../utils/FetchUtils";
|
import FetchUtils from "../utils/FetchUtils";
|
||||||
import CommonUtils from "../utils/CommonUtils";
|
import CommonUtils from "../utils/CommonUtils";
|
||||||
import MathUtils from "../utils/MathUtils";
|
import MathUtils from "../utils/MathUtils";
|
||||||
|
import ClassName from "../../container/ClassName";
|
||||||
|
import { Injectable } from "../../container/Injectable";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 老虎机批量购买助手
|
* 老虎机批量购买助手
|
||||||
*/
|
*/
|
||||||
export default class SlotsHelper extends WuhuBase {
|
@ClassName("SlotsHelper")
|
||||||
className = "SlotsHelper";
|
@Injectable()
|
||||||
|
export default class SlotsHelper {
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
private readonly mathUtils: MathUtils,
|
||||||
|
private readonly commonUtils: CommonUtils,
|
||||||
|
private readonly fetchUtils: FetchUtils,
|
||||||
|
private readonly infoUtils: InfoUtils,
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
private block = new TornStyleBlock("芜湖助手");
|
private block = new TornStyleBlock("芜湖助手");
|
||||||
|
|
||||||
@ -68,7 +78,7 @@ export default class SlotsHelper extends WuhuBase {
|
|||||||
private async goBtnHandler(ev: MouseEvent, nodes: SlotsHelperNodes) {
|
private async goBtnHandler(ev: MouseEvent, nodes: SlotsHelperNodes) {
|
||||||
let { counterInput, select, msgBox } = nodes;
|
let { counterInput, select, msgBox } = nodes;
|
||||||
// 现金
|
// 现金
|
||||||
let cash = (await InfoUtils.getInstance().getSessionData())?.user?.money?.value;
|
let cash = (await this.infoUtils.getSessionData())?.user?.money?.value;
|
||||||
msgBox.innerText = '等待加载中';
|
msgBox.innerText = '等待加载中';
|
||||||
// 代币
|
// 代币
|
||||||
let tokens: number = parseInt((await CommonUtils.querySelector('.player-info-cont #tokens')).innerText);
|
let tokens: number = parseInt((await CommonUtils.querySelector('.player-info-cont #tokens')).innerText);
|
||||||
@ -89,7 +99,7 @@ export default class SlotsHelper extends WuhuBase {
|
|||||||
// 实际购买数量
|
// 实际购买数量
|
||||||
let i: number;
|
let i: number;
|
||||||
for (i = 0; i < count; i++) {
|
for (i = 0; i < count; i++) {
|
||||||
let res: SlotsResponse = await (await FetchUtils.getInstance().ajaxFetch({
|
let res: SlotsResponse = await (await this.fetchUtils.ajaxFetch({
|
||||||
url: window.addRFC("https://www.torn.com/loader.php?sid=slotsInterface&step=play&stake=" + price),
|
url: window.addRFC("https://www.torn.com/loader.php?sid=slotsInterface&step=play&stake=" + price),
|
||||||
referrer: "/loader.php?sid=slots",
|
referrer: "/loader.php?sid=slots",
|
||||||
method: "GET"
|
method: "GET"
|
||||||
@ -100,7 +110,7 @@ export default class SlotsHelper extends WuhuBase {
|
|||||||
msgBox.innerHTML += '<br/>代币不足';
|
msgBox.innerHTML += '<br/>代币不足';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
await CommonUtils.getInstance().sleep(MathUtils.getInstance().getRandomInt(1800, 2400));
|
await this.commonUtils.sleep(this.mathUtils.getRandomInt(1800, 2400));
|
||||||
}
|
}
|
||||||
// 利润
|
// 利润
|
||||||
let profit = wonTotal - i * price;
|
let profit = wonTotal - i * price;
|
||||||
|
|||||||
@ -1,17 +1,21 @@
|
|||||||
import WuhuBase from "../WuhuBase";
|
|
||||||
import TornStyleBlock from "../utils/TornStyleBlock";
|
import TornStyleBlock from "../utils/TornStyleBlock";
|
||||||
import WuhuConfig from "../WuhuConfig";
|
import WuhuConfig from "../WuhuConfig";
|
||||||
import TornStyleSwitch from "../utils/TornStyleSwitch";
|
import TornStyleSwitch from "../utils/TornStyleSwitch";
|
||||||
|
import { Injectable } from "../../container/Injectable";
|
||||||
|
import ClassName from "../../container/ClassName";
|
||||||
|
import LocalConfigWrapper from "../LocalConfigWrapper";
|
||||||
|
|
||||||
export default class StackHelper extends WuhuBase {
|
@Injectable()
|
||||||
className = 'StackHelper';
|
@ClassName('StackHelper')
|
||||||
constructor() {
|
export default class StackHelper {
|
||||||
super();
|
constructor(
|
||||||
|
private readonly localConfigWrapper: LocalConfigWrapper,
|
||||||
|
) {
|
||||||
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();
|
||||||
block.append(switcher.getBase());
|
block.append(switcher.getBase());
|
||||||
input.checked = WuhuConfig.get('SEProtect');
|
input.checked = this.localConfigWrapper.config.SEProtect;
|
||||||
if (input.checked) document.body.classList.add('wh-gym-stack');
|
if (input.checked) document.body.classList.add('wh-gym-stack');
|
||||||
// 绑定点击事件
|
// 绑定点击事件
|
||||||
input.onchange = e => {
|
input.onchange = e => {
|
||||||
|
|||||||
@ -1,15 +1,15 @@
|
|||||||
import WuhuBase from "../WuhuBase";
|
|
||||||
import { chatDict, eventsDict, headerDict, propertyDict, sidebarDict } from "../../dictionary/translation";
|
import { chatDict, eventsDict, headerDict, propertyDict, sidebarDict } from "../../dictionary/translation";
|
||||||
import Log from "../Log";
|
import Log from "../Log";
|
||||||
import Timer from "../utils/Timer";
|
import Timer from "../utils/Timer";
|
||||||
|
|
||||||
export default class Translate extends WuhuBase {
|
/**
|
||||||
className = 'Translate';
|
* @deprecated 使用TranslateNew替代
|
||||||
|
*/
|
||||||
|
export default class Translate {
|
||||||
|
|
||||||
public translateVer: string = '1.0';
|
public translateVer: string = '1.0';
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
|
||||||
Log.info('翻译开始');
|
Log.info('翻译开始');
|
||||||
let start = new Timer();
|
let start = new Timer();
|
||||||
// 时分秒转换
|
// 时分秒转换
|
||||||
|
|||||||
@ -1,18 +1,29 @@
|
|||||||
import ResponseInject from "../../interface/ResponseInject";
|
import ResponseInject from "../../interface/ResponseInject";
|
||||||
import WuhuConfig from "../WuhuConfig";
|
|
||||||
import { Button, MiniProfile } from "../../interface/responseType/MiniProfile";
|
import { Button, MiniProfile } from "../../interface/responseType/MiniProfile";
|
||||||
import Log from "../Log";
|
|
||||||
import Sidebar from "../../interface/responseType/Sidebar";
|
import Sidebar from "../../interface/responseType/Sidebar";
|
||||||
import InventoryItemInfo from "../../interface/responseType/InventoryItemInfo";
|
import InventoryItemInfo from "../../interface/responseType/InventoryItemInfo";
|
||||||
import CommonUtils from "../utils/CommonUtils";
|
import CommonUtils from "../utils/CommonUtils";
|
||||||
import { itemNameDict, itemPageDict } from "../../dictionary/translation";
|
import { itemNameDict, itemPageDict } from "../../dictionary/translation";
|
||||||
import Provider from "../provider/Provider";
|
import Provider from "../provider/Provider";
|
||||||
|
import ClassName from "../../container/ClassName";
|
||||||
|
import { Injectable } from "../../container/Injectable";
|
||||||
|
import LocalConfigWrapper from "../LocalConfigWrapper";
|
||||||
|
import Logger from "../Logger";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 翻译重构
|
* 翻译重构
|
||||||
*/
|
*/
|
||||||
|
@ClassName('TranslateNew')
|
||||||
|
@Injectable()
|
||||||
export default class TranslateNew extends Provider implements ResponseInject {
|
export default class TranslateNew extends Provider implements ResponseInject {
|
||||||
className = 'TranslateNew';
|
|
||||||
|
constructor(
|
||||||
|
private readonly localConfigWrapper: LocalConfigWrapper,
|
||||||
|
private readonly logger: Logger,
|
||||||
|
private readonly commonUtils: CommonUtils,
|
||||||
|
) {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* fetch xhr 返回数据的翻译处理
|
* fetch xhr 返回数据的翻译处理
|
||||||
@ -20,8 +31,12 @@ export default class TranslateNew extends Provider implements ResponseInject {
|
|||||||
* @param body
|
* @param body
|
||||||
* @param opt
|
* @param opt
|
||||||
*/
|
*/
|
||||||
public responseHandler(url: string, body: { json: unknown, text: string, isModified: boolean }, opt: { method: 'GET' | 'POST', requestBody: string }): void {
|
public responseHandler(
|
||||||
if (!WuhuConfig.get('transNew')) return;
|
url: string,
|
||||||
|
body: { json: unknown, text: string, isModified: boolean },
|
||||||
|
opt: { method: 'GET' | 'POST', requestBody: string }
|
||||||
|
): void {
|
||||||
|
if (!this.localConfigWrapper.config.transNew) return;
|
||||||
// TODO 字典抽取
|
// TODO 字典抽取
|
||||||
let map = {
|
let map = {
|
||||||
iconMap: {
|
iconMap: {
|
||||||
@ -66,7 +81,7 @@ export default class TranslateNew extends Provider implements ResponseInject {
|
|||||||
'Attacked': '攻击',
|
'Attacked': '攻击',
|
||||||
'Defeated': '击败',
|
'Defeated': '击败',
|
||||||
},
|
},
|
||||||
{ 'someone': '某人' },
|
{ 'someone': '某人2' },
|
||||||
{ '<br><i>Early discharge available</i>': '<br><i>提前出院(ED)可用</i>' },
|
{ '<br><i>Early discharge available</i>': '<br><i>提前出院(ED)可用</i>' },
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
@ -206,7 +221,7 @@ export default class TranslateNew extends Provider implements ResponseInject {
|
|||||||
// Mini Profile
|
// Mini Profile
|
||||||
if (url.includes('profiles.php?step=getUserNameContextMenu')) {
|
if (url.includes('profiles.php?step=getUserNameContextMenu')) {
|
||||||
let jsonObj: MiniProfile = body.json as MiniProfile;
|
let jsonObj: MiniProfile = body.json as MiniProfile;
|
||||||
Log.info('翻译mini profile返回内容');
|
this.logger.info('翻译mini profile返回内容');
|
||||||
// 状态图标
|
// 状态图标
|
||||||
jsonObj.icons.forEach(icon => {
|
jsonObj.icons.forEach(icon => {
|
||||||
let iconMap = map.iconMap;
|
let iconMap = map.iconMap;
|
||||||
@ -223,7 +238,7 @@ export default class TranslateNew extends Provider implements ResponseInject {
|
|||||||
if (desc.attachedMap) {
|
if (desc.attachedMap) {
|
||||||
desc.attachedMap.forEach((item, index) => {
|
desc.attachedMap.forEach((item, index) => {
|
||||||
let factor = oriDesc.replace(new RegExp(desc.replace[0]), '$' + (index + 1));
|
let factor = oriDesc.replace(new RegExp(desc.replace[0]), '$' + (index + 1));
|
||||||
Log.info({ factor });
|
this.logger.info({ factor });
|
||||||
let cn = item[factor];
|
let cn = item[factor];
|
||||||
cn && (icon.description = icon.description.replace(factor, cn));
|
cn && (icon.description = icon.description.replace(factor, cn));
|
||||||
});
|
});
|
||||||
@ -282,7 +297,7 @@ export default class TranslateNew extends Provider implements ResponseInject {
|
|||||||
}
|
}
|
||||||
body.isModified = true;
|
body.isModified = true;
|
||||||
|
|
||||||
Log.info({ 'localized': jsonObj });
|
this.logger.info({ 'localized': jsonObj });
|
||||||
}
|
}
|
||||||
// TODO 边栏
|
// TODO 边栏
|
||||||
else if (url.includes('sidebarAjaxAction.php?q=sync')) {
|
else if (url.includes('sidebarAjaxAction.php?q=sync')) {
|
||||||
@ -306,7 +321,7 @@ export default class TranslateNew extends Provider implements ResponseInject {
|
|||||||
// 物品详情
|
// 物品详情
|
||||||
else if ((url.includes('inventory.php?step=info')) || (url.includes('inventory.php') && opt?.method === 'POST' &&
|
else if ((url.includes('inventory.php?step=info')) || (url.includes('inventory.php') && opt?.method === 'POST' &&
|
||||||
typeof opt?.requestBody === 'string' && opt?.requestBody.includes('step=info'))) {
|
typeof opt?.requestBody === 'string' && opt?.requestBody.includes('step=info'))) {
|
||||||
Log.info('responseHandler');
|
this.logger.info('responseHandler');
|
||||||
let resp = body.json as InventoryItemInfo;
|
let resp = body.json as InventoryItemInfo;
|
||||||
// TODO 维护通用物品数据(对应名称、描述、类型)缓存
|
// TODO 维护通用物品数据(对应名称、描述、类型)缓存
|
||||||
let map: { [k: string]: Partial<InventoryItemInfo> } = {
|
let map: { [k: string]: Partial<InventoryItemInfo> } = {
|
||||||
@ -322,7 +337,7 @@ export default class TranslateNew extends Provider implements ResponseInject {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
let idMap = { 816: 'Glass of Beer' };
|
let idMap = { 816: 'Glass of Beer' };
|
||||||
let itemInfo = CommonUtils.getInstance().getItemByIdOrName(resp.itemName, idMap, map);
|
let itemInfo = this.commonUtils.getItemByIdOrName(resp.itemName, idMap, map);
|
||||||
if (itemInfo) {
|
if (itemInfo) {
|
||||||
body.isModified = true;
|
body.isModified = true;
|
||||||
resp.itemInfo = itemInfo.itemInfo;
|
resp.itemInfo = itemInfo.itemInfo;
|
||||||
@ -349,7 +364,7 @@ export default class TranslateNew extends Provider implements ResponseInject {
|
|||||||
if (resp.html) {
|
if (resp.html) {
|
||||||
let tmp = document.createElement('div');
|
let tmp = document.createElement('div');
|
||||||
tmp.innerHTML = resp.html;
|
tmp.innerHTML = resp.html;
|
||||||
Log.info(tmp);
|
this.logger.info(tmp);
|
||||||
tmp.childNodes.forEach(li => {
|
tmp.childNodes.forEach(li => {
|
||||||
if (li.nodeType === 1) {
|
if (li.nodeType === 1) {
|
||||||
let elem = li as Element;
|
let elem = li as Element;
|
||||||
@ -380,7 +395,7 @@ export default class TranslateNew extends Provider implements ResponseInject {
|
|||||||
typeof opt?.requestBody === 'string' && opt?.requestBody.includes('step=getList')) {
|
typeof opt?.requestBody === 'string' && opt?.requestBody.includes('step=getList')) {
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
Log.error('responseHandler', e.stack || e.message);
|
this.logger.error('responseHandler', e.stack || e.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,4 @@
|
|||||||
import CommonUtils from "../utils/CommonUtils";
|
import CommonUtils from "../utils/CommonUtils";
|
||||||
import Log from "../Log";
|
|
||||||
import WuhuBase from "../WuhuBase";
|
|
||||||
import UserScriptEngine from "../../enum/UserScriptEngine";
|
import UserScriptEngine from "../../enum/UserScriptEngine";
|
||||||
import Popup from "../utils/Popup";
|
import Popup from "../utils/Popup";
|
||||||
import STOCK_IMG_HTML from "../../../static/html/stock_img.html";
|
import STOCK_IMG_HTML from "../../../static/html/stock_img.html";
|
||||||
@ -8,27 +6,38 @@ import * as FILTER from "../../../static/json/for_stock_item_filter.json";
|
|||||||
import WindowActiveState from "./WindowActiveState";
|
import WindowActiveState from "./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";
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
@ClassName('TravelItem')
|
@ClassName('TravelItem')
|
||||||
export default class TravelItem extends WuhuBase {
|
export default class TravelItem {
|
||||||
className = 'TravelItem';
|
|
||||||
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;
|
||||||
|
|
||||||
public constructor() {
|
public constructor(
|
||||||
super();
|
private readonly windowActiveState: WindowActiveState,
|
||||||
|
private readonly logger: Logger,
|
||||||
|
private readonly commonUtils: CommonUtils,
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public init() {
|
||||||
|
|
||||||
window.setInterval(async () => {
|
window.setInterval(async () => {
|
||||||
if (!WindowActiveState.getInstance().get()) return;
|
if (!this.windowActiveState.get()) return;
|
||||||
Log.info('COFetch ', this.apiUrl);
|
this.logger.info('COFetch ', this.apiUrl);
|
||||||
this.foreignStockInfo = JSON.parse(await CommonUtils.COFetch(this.apiUrl));
|
try {
|
||||||
Log.info({ info: 'TravelItem 跨域返回', 'returned': this.foreignStockInfo });
|
this.foreignStockInfo = JSON.parse(await CommonUtils.COFetch(this.apiUrl));
|
||||||
|
} catch (e) {
|
||||||
|
this.logger.error('解析错误', e.stack || e.message || e);
|
||||||
|
}
|
||||||
|
this.logger.info({ info: 'TravelItem 跨域返回', 'returned': this.foreignStockInfo });
|
||||||
}, 30 * 1000);
|
}, 30 * 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 呈现内容
|
// 呈现内容
|
||||||
public async clickHandler(): Promise<void> {
|
public async clickHandler(): Promise<void> {
|
||||||
if (CommonUtils.getScriptEngine() === UserScriptEngine.RAW) {
|
if (this.commonUtils.getScriptEngine() === UserScriptEngine.RAW) {
|
||||||
new Popup(STOCK_IMG_HTML.replace('{{}}', performance.now().toString()), '飞花库存');
|
new Popup(STOCK_IMG_HTML.replace('{{}}', performance.now().toString()), '飞花库存');
|
||||||
} else {
|
} else {
|
||||||
const popup = new Popup("请稍后 " + CommonUtils.loading_gif_html(), '飞花库存');
|
const popup = new Popup("请稍后 " + CommonUtils.loading_gif_html(), '飞花库存');
|
||||||
@ -36,7 +45,7 @@ export default class TravelItem extends WuhuBase {
|
|||||||
const dest = FILTER.default;
|
const dest = FILTER.default;
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
const res = await this.get();
|
const res = await this.get();
|
||||||
Log.info({ res })
|
this.logger.info({ res })
|
||||||
if (!res || !res.stocks) return;
|
if (!res || !res.stocks) return;
|
||||||
dest.forEach(el => {
|
dest.forEach(el => {
|
||||||
const update = (now.getTime() - new Date(res.stocks[el.name]['update'] * 1000).getTime()) / 1000 | 0
|
const update = (now.getTime() - new Date(res.stocks[el.name]['update'] * 1000).getTime()) / 1000 | 0
|
||||||
@ -60,6 +69,11 @@ export default class TravelItem extends WuhuBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async get() {
|
private async get() {
|
||||||
return this.foreignStockInfo ||= JSON.parse(await CommonUtils.COFetch(this.apiUrl));
|
try {
|
||||||
|
return this.foreignStockInfo ||= JSON.parse(await CommonUtils.COFetch(this.apiUrl));
|
||||||
|
} catch (e) {
|
||||||
|
this.logger.error('解析出错', e.stack || e.message || e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,13 +1,14 @@
|
|||||||
import uuidv4 from "../../func/utils/uuidv4";
|
import uuidv4 from "../../func/utils/uuidv4";
|
||||||
import WuhuBase from "../WuhuBase";
|
import ClassName from "../../container/ClassName";
|
||||||
|
import { Injectable } from "../../container/Injectable";
|
||||||
|
|
||||||
export default class WindowActiveState extends WuhuBase {
|
@ClassName('WindowActiveState')
|
||||||
className = 'WindowActiveState';
|
@Injectable()
|
||||||
isFocus = false;
|
export default class WindowActiveState {
|
||||||
uuid = uuidv4();
|
private isFocus = false;
|
||||||
|
private uuid = uuidv4();
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
|
||||||
if (self !== top) return null;
|
if (self !== top) return null;
|
||||||
localStorage.setItem('whuuid', this.uuid);
|
localStorage.setItem('whuuid', this.uuid);
|
||||||
document.addEventListener('visibilitychange',
|
document.addEventListener('visibilitychange',
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
import WuhuBase from "../WuhuBase";
|
|
||||||
import XUNZHAOMUZHUANG_HTML from "../../../static/html/xunzhaomuzhuang/index.html";
|
import XUNZHAOMUZHUANG_HTML from "../../../static/html/xunzhaomuzhuang/index.html";
|
||||||
import * as MUZHUANG_ID_LIST_JSON from "../../../static/json/muzhuang_id_list.json";
|
import * as MUZHUANG_ID_LIST_JSON from "../../../static/json/muzhuang_id_list.json";
|
||||||
import CommonUtils from "../utils/CommonUtils";
|
import CommonUtils from "../utils/CommonUtils";
|
||||||
@ -6,12 +5,16 @@ import XUNZHAOMUZHUANG_CSS from "../../../static/css/xunzhaomuzhuang.css";
|
|||||||
import TornStyleBlock from "../utils/TornStyleBlock";
|
import TornStyleBlock from "../utils/TornStyleBlock";
|
||||||
import MathUtils from "../utils/MathUtils";
|
import MathUtils from "../utils/MathUtils";
|
||||||
import FetchUtils from "../utils/FetchUtils";
|
import FetchUtils from "../utils/FetchUtils";
|
||||||
|
import ClassName from "../../container/ClassName";
|
||||||
|
import { Injectable } from "../../container/Injectable";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 寻找木桩
|
* 寻找木桩
|
||||||
* /item.php?temp=4#xunzhaomuzhuang
|
* /item.php?temp=4#xunzhaomuzhuang
|
||||||
*/
|
*/
|
||||||
export default class XZMZ extends WuhuBase {
|
@ClassName('XZMZ')
|
||||||
|
@Injectable()
|
||||||
|
export default class XZMZ {
|
||||||
className = 'XZMZ';
|
className = 'XZMZ';
|
||||||
private mainRoleContainer: HTMLElement;
|
private mainRoleContainer: HTMLElement;
|
||||||
private IDList: number[];
|
private IDList: number[];
|
||||||
@ -21,8 +24,11 @@ export default class XZMZ extends WuhuBase {
|
|||||||
private tips: HTMLElement;
|
private tips: HTMLElement;
|
||||||
private counter: number;
|
private counter: number;
|
||||||
|
|
||||||
public constructor() {
|
public constructor(
|
||||||
super();
|
private readonly mathUtils: MathUtils,
|
||||||
|
private readonly commonUtils: CommonUtils,
|
||||||
|
private readonly fetchUtils: FetchUtils,
|
||||||
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public init() {
|
public init() {
|
||||||
@ -65,7 +71,7 @@ export default class XZMZ extends WuhuBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async SearchDeadman(id) {
|
private async SearchDeadman(id) {
|
||||||
FetchUtils.getInstance().getProfile(id).then((res) => {
|
this.fetchUtils.getProfile(id).then((res) => {
|
||||||
if (res.userStatus.status.type === 'ok') {
|
if (res.userStatus.status.type === 'ok') {
|
||||||
this.addRow({
|
this.addRow({
|
||||||
player_id: res.user.userID,
|
player_id: res.user.userID,
|
||||||
@ -74,7 +80,7 @@ export default class XZMZ extends WuhuBase {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
await CommonUtils.getInstance().sleep(MathUtils.getInstance().getRandomInt(100, 200));
|
await this.commonUtils.sleep(this.mathUtils.getRandomInt(100, 200));
|
||||||
}
|
}
|
||||||
|
|
||||||
private addRow(data) {
|
private addRow(data) {
|
||||||
|
|||||||
@ -16,6 +16,10 @@ const defaultConfig = {
|
|||||||
trvAlarm: true,
|
trvAlarm: true,
|
||||||
// 啤酒提醒
|
// 啤酒提醒
|
||||||
_15Alarm: true,
|
_15Alarm: true,
|
||||||
|
// 啤酒提醒时间
|
||||||
|
_15AlarmTime: 50,
|
||||||
|
// 啤酒提醒忽略当天
|
||||||
|
_15_alarm_ignore: '',
|
||||||
// 捡垃圾助手
|
// 捡垃圾助手
|
||||||
cityFinder: false,
|
cityFinder: false,
|
||||||
// 叠E保护
|
// 叠E保护
|
||||||
@ -34,8 +38,6 @@ const defaultConfig = {
|
|||||||
priceWatcher: { xan: -1, pt: -1 },
|
priceWatcher: { xan: -1, pt: -1 },
|
||||||
// 开发者模式
|
// 开发者模式
|
||||||
isDev: false,
|
isDev: false,
|
||||||
// 啤酒提醒时间
|
|
||||||
_15AlarmTime: 50,
|
|
||||||
// 4条转跳
|
// 4条转跳
|
||||||
barsRedirect: true,
|
barsRedirect: true,
|
||||||
// 浮动存钱框
|
// 浮动存钱框
|
||||||
@ -69,7 +71,7 @@ const defaultConfig = {
|
|||||||
// 解决一直转圈(加载中)的问题
|
// 解决一直转圈(加载中)的问题
|
||||||
SolveGoogleScriptPendingIssue: false,
|
SolveGoogleScriptPendingIssue: false,
|
||||||
// 图标坐标
|
// 图标坐标
|
||||||
IconPosition: {},
|
IconPosition: {} as { x: number, y: number },
|
||||||
// 记住图标位置
|
// 记住图标位置
|
||||||
SaveIconPosition: false,
|
SaveIconPosition: false,
|
||||||
// 现金变动提醒
|
// 现金变动提醒
|
||||||
@ -80,7 +82,101 @@ const defaultConfig = {
|
|||||||
ShowMiniProfLastAct: true,
|
ShowMiniProfLastAct: true,
|
||||||
// 自定义css
|
// 自定义css
|
||||||
CustomCss: '',
|
CustomCss: '',
|
||||||
|
|
||||||
|
/** @deprecated */
|
||||||
|
attRelocate: false,
|
||||||
};
|
};
|
||||||
// } as const;
|
// } as const;
|
||||||
|
|
||||||
export default defaultConfig;
|
// export default defaultConfig;
|
||||||
|
|
||||||
|
class DefaultConfigType {
|
||||||
|
// 开启翻译
|
||||||
|
transEnable = false;
|
||||||
|
transNew = true;
|
||||||
|
// 快速犯罪
|
||||||
|
quickCrime = true;
|
||||||
|
// 任务助手
|
||||||
|
missionHint = true;
|
||||||
|
// 小镇攻略
|
||||||
|
xmasTownWT = true;
|
||||||
|
// 小镇提醒
|
||||||
|
xmasTownNotify = true;
|
||||||
|
// 起飞爆e
|
||||||
|
energyAlert = true;
|
||||||
|
// 飞行闹钟
|
||||||
|
trvAlarm = true;
|
||||||
|
// 啤酒提醒
|
||||||
|
_15Alarm = true;
|
||||||
|
_15_alarm_ignore = false;
|
||||||
|
// 啤酒提醒时间
|
||||||
|
_15AlarmTime = 50;
|
||||||
|
// 捡垃圾助手
|
||||||
|
cityFinder = false;
|
||||||
|
// 叠E保护
|
||||||
|
SEProtect = false;
|
||||||
|
// PT一键购买
|
||||||
|
ptQuickBuy = false;
|
||||||
|
// 光速拔刀 6-关闭
|
||||||
|
quickAttIndex = 2;
|
||||||
|
// 光速跑路 0-leave 1-mug 2-hos 3-关闭
|
||||||
|
quickFinishAtt = 3;
|
||||||
|
// 自动开打和结束
|
||||||
|
autoStartFinish = false;
|
||||||
|
// 攻击自刷新 0-无间隔 1-5s 6-关闭
|
||||||
|
attReload = 6;
|
||||||
|
/** @deprecated */
|
||||||
|
attRelocate = false;
|
||||||
|
// 价格监视
|
||||||
|
priceWatcher = { xan: -1, pt: -1 };
|
||||||
|
// 开发者模式
|
||||||
|
isDev = false;
|
||||||
|
// 4条转跳
|
||||||
|
barsRedirect = true;
|
||||||
|
// 浮动存钱框
|
||||||
|
floatDepo = true;
|
||||||
|
// 公司转跳存钱
|
||||||
|
companyRedirect = true;
|
||||||
|
// 收起公司冰蛙效率表
|
||||||
|
companyBWCollapse = true;
|
||||||
|
// 海外警告
|
||||||
|
abroadWarning = true;
|
||||||
|
// 落地转跳
|
||||||
|
landedRedirect = '';
|
||||||
|
// 任何位置一键存钱
|
||||||
|
companyDepositAnywhere = false;
|
||||||
|
// 火车提醒时间
|
||||||
|
CHTrainsDetect = 0;
|
||||||
|
// 火车提醒开关
|
||||||
|
CHTrainsDetectSwitch = true;
|
||||||
|
// 隐藏个人资料头像
|
||||||
|
HideProfileImg = false;
|
||||||
|
// 显示曾用名
|
||||||
|
ShowNameHistory = true;
|
||||||
|
// 盯梢模式强度 0-550 1-950 2-1450 ms
|
||||||
|
WatchTargetFreq = 1;
|
||||||
|
// 隐藏侧边栏
|
||||||
|
HideSidebar = false;
|
||||||
|
// 添加隐藏边栏按钮
|
||||||
|
HideSidebarBtn = true;
|
||||||
|
// 搜索页占位区
|
||||||
|
SearchPagePlaceholder = true;
|
||||||
|
// 解决一直转圈(加载中)的问题
|
||||||
|
SolveGoogleScriptPendingIssue = false;
|
||||||
|
// 图标坐标
|
||||||
|
IconPosition: Partial<{ x: number, y: number }> = {};
|
||||||
|
// 记住图标位置
|
||||||
|
SaveIconPosition = false;
|
||||||
|
// 现金变动提醒
|
||||||
|
CashChangeAlert = false;
|
||||||
|
// 收集数据以改进翻译质量
|
||||||
|
CollectPlayerData = true;
|
||||||
|
// 迷你资料卡显示上次行动时间
|
||||||
|
ShowMiniProfLastAct = true;
|
||||||
|
// 自定义css
|
||||||
|
CustomCss = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export type Config = DefaultConfigType;
|
||||||
|
export default new DefaultConfigType() as Readonly<Config>;
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
import WuhuBase from "../WuhuBase";
|
|
||||||
import Popup from "../utils/Popup";
|
import Popup from "../utils/Popup";
|
||||||
import Alert from "../utils/Alert";
|
import Alert from "../utils/Alert";
|
||||||
import DialogMsgBox from "../utils/DialogMsgBox";
|
import DialogMsgBox from "../utils/DialogMsgBox";
|
||||||
@ -6,9 +5,18 @@ import CommonUtils from "../utils/CommonUtils";
|
|||||||
import { MenuItemConfig } from "../ZhongIcon";
|
import { MenuItemConfig } from "../ZhongIcon";
|
||||||
import IFrameCrimeHandler from "./IFrameCrimeHandler";
|
import IFrameCrimeHandler from "./IFrameCrimeHandler";
|
||||||
import loadGS from "../../func/module/loadGS";
|
import loadGS from "../../func/module/loadGS";
|
||||||
|
import ClassName from "../../container/ClassName";
|
||||||
|
import { Injectable } from "../../container/Injectable";
|
||||||
|
import { Container } from "../../container/Container";
|
||||||
|
|
||||||
export default class AdditionalSettingsHandler extends WuhuBase {
|
@ClassName('AdditionalSettingsHandler')
|
||||||
className = 'AdditionalSettingsHandler';
|
@Injectable()
|
||||||
|
export default class AdditionalSettingsHandler {
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
private readonly commonUtils: CommonUtils,
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
public show(): void {
|
public show(): void {
|
||||||
let pop = new Popup('', '更多设定');
|
let pop = new Popup('', '更多设定');
|
||||||
@ -59,7 +67,7 @@ export default class AdditionalSettingsHandler extends WuhuBase {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
domType: 'button', domId: '', domText: '小窗犯罪', clickFunc() {
|
domType: 'button', domId: '', domText: '小窗犯罪', clickFunc() {
|
||||||
IFrameCrimeHandler.getInstance().handle()
|
Container.factory(IFrameCrimeHandler).handle()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -67,11 +75,11 @@ export default class AdditionalSettingsHandler extends WuhuBase {
|
|||||||
domId: '',
|
domId: '',
|
||||||
domText: '飞贼小助手',
|
domText: '飞贼小助手',
|
||||||
tip: '加载从PC端移植的伞佬的油猴版飞贼小助手',
|
tip: '加载从PC端移植的伞佬的油猴版飞贼小助手',
|
||||||
clickFunc() {
|
clickFunc: () => {
|
||||||
loadGS(CommonUtils.getScriptEngine())
|
loadGS(this.commonUtils.getScriptEngine())
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
menuList.forEach(i => pop.getElement().append(CommonUtils.getInstance().elemGenerator(i, pop.getElement())));
|
menuList.forEach(i => pop.element.append(this.commonUtils.elemGenerator(i, pop.element)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,15 +4,24 @@ import MDUtils from "../utils/MDUtils";
|
|||||||
import Log from "../Log";
|
import Log from "../Log";
|
||||||
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 { Injectable } from "../../container/Injectable";
|
||||||
|
import { Container } from "../../container/Container";
|
||||||
|
|
||||||
|
@ClassName('ChangeLogHandler')
|
||||||
|
@Injectable()
|
||||||
class ChangeLogHandler extends Provider {
|
class ChangeLogHandler extends Provider {
|
||||||
className = 'ChangeLogHandler';
|
constructor(
|
||||||
|
private readonly mdUtils: MDUtils,
|
||||||
|
) {
|
||||||
|
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/>',
|
||||||
'更新历史'
|
'更新历史'
|
||||||
).getElement();
|
).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';
|
||||||
@ -31,7 +40,7 @@ class ChangeLogHandler extends Provider {
|
|||||||
.then(update => {
|
.then(update => {
|
||||||
progressBar.style.width = '60%';
|
progressBar.style.width = '60%';
|
||||||
progressText.innerText = '解析中……';
|
progressText.innerText = '解析中……';
|
||||||
let md = MDUtils.getInstance().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 = '加载完成';
|
||||||
@ -53,5 +62,5 @@ class ChangeLogHandler extends Provider {
|
|||||||
export default {
|
export default {
|
||||||
domType: MENU_ITEM_TYPE.BUTTON,
|
domType: MENU_ITEM_TYPE.BUTTON,
|
||||||
domText: '🐞 更新历史',
|
domText: '🐞 更新历史',
|
||||||
clickFunc: () => ChangeLogHandler.getInstance().show()
|
clickFunc: () => Container.factory(ChangeLogHandler).show()
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,19 +1,23 @@
|
|||||||
import WuhuBase from "../WuhuBase";
|
|
||||||
import Popup from "../utils/Popup";
|
import Popup from "../utils/Popup";
|
||||||
import WuhuConfig from "../WuhuConfig";
|
import WuhuConfig from "../WuhuConfig";
|
||||||
|
import ClassName from "../../container/ClassName";
|
||||||
|
import { Injectable } from "../../container/Injectable";
|
||||||
|
import LocalConfigWrapper from "../LocalConfigWrapper";
|
||||||
|
|
||||||
export default class CustomCssHandler extends WuhuBase {
|
@ClassName('CustomCssHandler')
|
||||||
className = 'CustomCssHandler';
|
@Injectable()
|
||||||
|
export default class CustomCssHandler {
|
||||||
|
|
||||||
constructor() {
|
constructor(
|
||||||
super();
|
private readonly localConfigWrapper: LocalConfigWrapper,
|
||||||
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public handle(): void {
|
public handle(): void {
|
||||||
let pop = new Popup('<div><textarea></textarea><button class="torn-btn">保存</button><style>#wh-popup textarea{display: block;}</style></div>', '自定义CSS');
|
let pop = new Popup('<div><textarea></textarea><button class="torn-btn">保存</button><style>#wh-popup textarea{display: block;}</style></div>', '自定义CSS');
|
||||||
let textarea = pop.getElement().querySelector('textarea');
|
let textarea = pop.element.querySelector('textarea');
|
||||||
let button = pop.getElement().querySelector('button');
|
let button = pop.element.querySelector('button');
|
||||||
textarea.value = WuhuConfig.get('CustomCss') || '';
|
textarea.value = this.localConfigWrapper.config.CustomCss || '';
|
||||||
button.addEventListener('click', () => {
|
button.addEventListener('click', () => {
|
||||||
WuhuConfig.set('CustomCss', textarea.value || '', true);
|
WuhuConfig.set('CustomCss', textarea.value || '', true);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,10 +1,12 @@
|
|||||||
import WuhuBase from "../WuhuBase";
|
|
||||||
import CommonUtils from "../utils/CommonUtils";
|
import CommonUtils from "../utils/CommonUtils";
|
||||||
import Popup from "../utils/Popup";
|
import Popup from "../utils/Popup";
|
||||||
import QUICK_CRIMES_HTML from "../../../static/html/quick_crimes.html";
|
import QUICK_CRIMES_HTML from "../../../static/html/quick_crimes.html";
|
||||||
|
import ClassName from "../../container/ClassName";
|
||||||
|
import { Injectable } from "../../container/Injectable";
|
||||||
|
|
||||||
export default class IFrameCrimeHandler extends WuhuBase {
|
@ClassName('IFrameCrimeHandler')
|
||||||
className = 'IFrameCrimeHandler';
|
@Injectable()
|
||||||
|
export default class IFrameCrimeHandler {
|
||||||
|
|
||||||
public handle(): void {
|
public handle(): void {
|
||||||
// 弹出小窗口
|
// 弹出小窗口
|
||||||
|
|||||||
@ -1,26 +1,35 @@
|
|||||||
import WuhuBase from "../WuhuBase";
|
|
||||||
import WuhuConfig from "../WuhuConfig";
|
|
||||||
import PRICE_WATCHER_HTML from "../../../static/html/price_watcher.html";
|
import PRICE_WATCHER_HTML from "../../../static/html/price_watcher.html";
|
||||||
import Popup from "../utils/Popup";
|
import Popup from "../utils/Popup";
|
||||||
import Global from "../Global";
|
import { Injectable } from "../../container/Injectable";
|
||||||
|
import ClassName from "../../container/ClassName";
|
||||||
|
import LocalConfigWrapper from "../LocalConfigWrapper";
|
||||||
|
import TornPDAUtils from "../utils/TornPDAUtils";
|
||||||
|
|
||||||
export default class ItemPriceWatcherHandler extends WuhuBase {
|
@Injectable()
|
||||||
className = 'ItemPriceWatcherHandler';
|
@ClassName('ItemPriceWatcherHandler')
|
||||||
|
export default class ItemPriceWatcherHandler {
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
private readonly localConfigWrapper: LocalConfigWrapper,
|
||||||
|
private readonly tornPDAUtils: TornPDAUtils,
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
public handle(): void {
|
public handle(): void {
|
||||||
const watcher_conf = WuhuConfig.get('priceWatcher');
|
const watcher_conf = this.localConfigWrapper.config.priceWatcher;
|
||||||
const pre_str = JSON.stringify(watcher_conf);
|
const pre_str = JSON.stringify(watcher_conf);
|
||||||
const html = PRICE_WATCHER_HTML
|
const html = PRICE_WATCHER_HTML
|
||||||
.replace('{{}}', localStorage.getItem('APIKey') || '不可用')
|
.replace('{{}}', localStorage.getItem('APIKey') || '不可用')
|
||||||
.replace('{{}}', Global.getInstance().isPDA ? Global.getInstance().PDA_APIKey : '不可用')
|
.replace('{{}}', this.tornPDAUtils.isPDA() ? this.tornPDAUtils.APIKey : '不可用')
|
||||||
.replace('{{}}', watcher_conf['pt'] || -1)
|
.replace('{{}}', (watcher_conf['pt'] || -1).toString())
|
||||||
.replace('{{}}', watcher_conf['xan'] || -1);
|
.replace('{{}}', (watcher_conf['xan'] || -1).toString());
|
||||||
const popup = new Popup(html, '价格监视设置');
|
const popup = new Popup(html, '价格监视设置');
|
||||||
popup.getElement().querySelector('button').onclick = () => {
|
popup.getElement().querySelector('button').onclick = () => {
|
||||||
const [pt_node, xan_node] = Array.from(<NodeListOf<HTMLInputElement>>popup.getElement().querySelectorAll('input[type="number"]'));
|
const [pt_node, xan_node] = Array.from(<NodeListOf<HTMLInputElement>>popup.getElement().querySelectorAll('input[type="number"]'));
|
||||||
watcher_conf.pt = (pt_node.value as any) | 0;
|
watcher_conf.pt = (pt_node.value as any) | 0;
|
||||||
watcher_conf.xan = (xan_node.value as any) | 0;
|
watcher_conf.xan = (xan_node.value as any) | 0;
|
||||||
if (JSON.stringify(watcher_conf) !== pre_str) WuhuConfig.set('priceWatcher', watcher_conf);
|
if (JSON.stringify(watcher_conf) !== pre_str)
|
||||||
|
this.localConfigWrapper.config.priceWatcher = watcher_conf;
|
||||||
popup.close();
|
popup.close();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,21 +0,0 @@
|
|||||||
import WuhuBase from "../WuhuBase";
|
|
||||||
import Popup from "../utils/Popup";
|
|
||||||
import Elem from "../provider/Elem";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 快速查价
|
|
||||||
*/
|
|
||||||
export default class ItemValueQueryHandler extends WuhuBase {
|
|
||||||
className = "ItemValueQueryHandler";
|
|
||||||
|
|
||||||
constructor() {
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
|
|
||||||
public show() {
|
|
||||||
let pop = new Popup('', '快速查价');
|
|
||||||
pop.getElement().append(
|
|
||||||
new Elem('div').html('<p>test</p>').class('wh-test').el()
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,17 +1,24 @@
|
|||||||
import WuhuBase from "../WuhuBase";
|
|
||||||
import NNB_INFO_HTML from "../../../static/html/nnb_info.html";
|
import NNB_INFO_HTML from "../../../static/html/nnb_info.html";
|
||||||
import Popup from "../utils/Popup";
|
import Popup from "../utils/Popup";
|
||||||
import Global from "../Global";
|
import ClassName from "../../container/ClassName";
|
||||||
|
import { Injectable } from "../../container/Injectable";
|
||||||
|
import TornPDAUtils from "../utils/TornPDAUtils";
|
||||||
|
|
||||||
export default class NNB extends WuhuBase {
|
@ClassName('NNB')
|
||||||
|
@Injectable()
|
||||||
|
export default class NNB {
|
||||||
className = 'NNB';
|
className = 'NNB';
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
private readonly tornPDAUtils: TornPDAUtils,
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
public handle(): void {
|
public handle(): void {
|
||||||
let { isPDA, PDA_APIKey } = Global.getInstance();
|
|
||||||
const insert = NNB_INFO_HTML
|
const insert = NNB_INFO_HTML
|
||||||
.replace('{{}}', localStorage.getItem('APIKey') || '不可用')
|
.replace('{{}}', localStorage.getItem('APIKey') || '不可用')
|
||||||
.replace('{{}}', isPDA ? PDA_APIKey : '不可用');
|
.replace('{{}}', this.tornPDAUtils.isPDA() ? this.tornPDAUtils.APIKey : '不可用');
|
||||||
const popup = new Popup(insert, '查看NNB').getElement();
|
const popup = new Popup(insert, '查看NNB').element;
|
||||||
const select = popup.querySelector('input');
|
const select = popup.querySelector('input');
|
||||||
const node = popup.querySelector('p');
|
const node = popup.querySelector('p');
|
||||||
popup.querySelector('button').addEventListener('click', ev => {
|
popup.querySelector('button').addEventListener('click', ev => {
|
||||||
@ -20,7 +27,7 @@ export default class NNB extends WuhuBase {
|
|||||||
node.innerHTML = '加载中';
|
node.innerHTML = '加载中';
|
||||||
// API 计算
|
// API 计算
|
||||||
if (select.checked) {
|
if (select.checked) {
|
||||||
const api_key = isPDA ? PDA_APIKey : window.localStorage.getItem('APIKey');
|
const api_key = this.tornPDAUtils.isPDA() ? this.tornPDAUtils.APIKey : window.localStorage.getItem('APIKey');
|
||||||
window.fetch(`https://api.torn.com/user/?selections=bars,perks&key=${ api_key }`)
|
window.fetch(`https://api.torn.com/user/?selections=bars,perks&key=${ api_key }`)
|
||||||
.then(res => res.json())
|
.then(res => res.json())
|
||||||
.then(data => {
|
.then(data => {
|
||||||
|
|||||||
@ -1,16 +1,26 @@
|
|||||||
import WuhuBase from "../WuhuBase";
|
|
||||||
import CommonUtils from "../utils/CommonUtils";
|
import CommonUtils from "../utils/CommonUtils";
|
||||||
import QUICK_FLY_CSS from "../../../static/css/quick_fly.css";
|
import QUICK_FLY_CSS from "../../../static/css/quick_fly.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 "../action/TravelItem";
|
||||||
|
import ClassName from "../../container/ClassName";
|
||||||
|
import { Injectable } from "../../container/Injectable";
|
||||||
|
import Logger from "../Logger";
|
||||||
|
|
||||||
export default class QuickFlyBtnHandler extends WuhuBase {
|
@ClassName('QuickFlyBtnHandler')
|
||||||
|
@Injectable()
|
||||||
|
export default class QuickFlyBtnHandler {
|
||||||
className = 'QuickFlyBtnHandler';
|
className = 'QuickFlyBtnHandler';
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
private readonly logger: Logger,
|
||||||
|
private readonly travelItem: TravelItem,
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
public static doQuickFly(): void {
|
public static doQuickFly(): void {
|
||||||
// [id: dest, _type: (1...4), ts: timestamp]
|
// [id: dest, _type: (1...4), ts: timestamp]
|
||||||
const [_id, _type, ts] = sessionStorage['wh-quick-fly'].trim().split(' ');
|
const [_id, _type, ts] = window.sessionStorage['wh-quick-fly'].trim().split(' ');
|
||||||
if (new Date().getTime() - ts > 20000) {
|
if (new Date().getTime() - ts > 20000) {
|
||||||
new Alert('超时,一键起飞计划已取消');
|
new Alert('超时,一键起飞计划已取消');
|
||||||
return;
|
return;
|
||||||
@ -69,8 +79,7 @@ export default class QuickFlyBtnHandler extends WuhuBase {
|
|||||||
});
|
});
|
||||||
node.querySelector('a').addEventListener('click', (e) => {
|
node.querySelector('a').addEventListener('click', (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
// forStock();
|
this.travelItem.clickHandler().then();
|
||||||
TravelItem.getInstance().clickHandler();
|
|
||||||
});
|
});
|
||||||
node.querySelector('input').addEventListener('click', (e) => {
|
node.querySelector('input').addEventListener('click', (e) => {
|
||||||
node.classList.toggle('wh-quick-fly-opt-hide');
|
node.classList.toggle('wh-quick-fly-opt-hide');
|
||||||
|
|||||||
@ -1,16 +1,13 @@
|
|||||||
import WuhuBase from "../WuhuBase";
|
|
||||||
import CommonUtils from "../utils/CommonUtils";
|
import CommonUtils from "../utils/CommonUtils";
|
||||||
import QUICK_LINK_CSS from "../../../static/css/quick_link.css";
|
import QUICK_LINK_CSS from "../../../static/css/quick_link.css";
|
||||||
import Popup from "../utils/Popup";
|
import Popup from "../utils/Popup";
|
||||||
|
|
||||||
export default class QuickLinksHandler extends WuhuBase {
|
export default class QuickLinksHandler {
|
||||||
className = 'QuickLinksHandler';
|
|
||||||
|
|
||||||
private styleAdded: boolean = false;
|
private styleAdded: boolean = false;
|
||||||
private list = [];
|
private list = [];
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
|
||||||
let list = this.list;
|
let list = this.list;
|
||||||
// 生存手册
|
// 生存手册
|
||||||
list.push({
|
list.push({
|
||||||
@ -82,8 +79,8 @@ export default class QuickLinksHandler extends WuhuBase {
|
|||||||
});
|
});
|
||||||
insert += '</p>'
|
insert += '</p>'
|
||||||
let popup = new Popup(insert, '常用链接');
|
let popup = new Popup(insert, '常用链接');
|
||||||
popup.getElement().classList.add('wh-link-collection-cont');
|
popup.element.classList.add('wh-link-collection-cont');
|
||||||
popup.getElement().addEventListener('click', ev => {
|
popup.element.addEventListener('click', ev => {
|
||||||
let target = ev.target as HTMLElement;
|
let target = ev.target as HTMLElement;
|
||||||
if (target.tagName.toLowerCase() === 'a' || target.tagName.toLowerCase() === 'span') {
|
if (target.tagName.toLowerCase() === 'a' || target.tagName.toLowerCase() === 'span') {
|
||||||
popup.close();
|
popup.close();
|
||||||
|
|||||||
@ -12,13 +12,25 @@ import CommonUtils from "../utils/CommonUtils";
|
|||||||
import CustomCssHandler from "./CustomCssHandler";
|
import CustomCssHandler from "./CustomCssHandler";
|
||||||
import Provider from "../provider/Provider";
|
import Provider from "../provider/Provider";
|
||||||
import { MENU_ITEM_TYPE } from "../../interface/MenuItem";
|
import { MENU_ITEM_TYPE } from "../../interface/MenuItem";
|
||||||
|
import ClassName from "../../container/ClassName";
|
||||||
|
import { Injectable } from "../../container/Injectable";
|
||||||
|
import { Container } from "../../container/Container";
|
||||||
|
|
||||||
|
@ClassName('SettingsHandler')
|
||||||
|
@Injectable()
|
||||||
class SettingsHandler extends Provider {
|
class SettingsHandler extends Provider {
|
||||||
className = 'SettingsHandler';
|
className = 'SettingsHandler';
|
||||||
|
|
||||||
private list: MenuItemConfig[] = [];
|
private list: MenuItemConfig[] = [];
|
||||||
|
|
||||||
constructor() {
|
constructor(
|
||||||
|
private readonly buyBeerHelper: BuyBeerHelper,
|
||||||
|
private readonly commonUtils: CommonUtils,
|
||||||
|
private readonly updateTranslateDict: UpdateTranslateDict,
|
||||||
|
private readonly customCssHandler: CustomCssHandler,
|
||||||
|
private readonly viewLogsHandler: ViewLogsHandler,
|
||||||
|
private readonly additionalSettingsHandler: AdditionalSettingsHandler,
|
||||||
|
) {
|
||||||
super();
|
super();
|
||||||
this.constructWuhuSettingList();
|
this.constructWuhuSettingList();
|
||||||
}
|
}
|
||||||
@ -30,10 +42,10 @@ class SettingsHandler extends Provider {
|
|||||||
window.setTimeout(() => {
|
window.setTimeout(() => {
|
||||||
let tmp = document.createElement('div');
|
let tmp = document.createElement('div');
|
||||||
tmp.classList.add('gSetting');
|
tmp.classList.add('gSetting');
|
||||||
this.list.forEach(set => CommonUtils.getInstance().elemGenerator(set, tmp));
|
this.list.forEach(set => this.commonUtils.elemGenerator(set, tmp));
|
||||||
// 本日不提醒
|
// 本日不提醒
|
||||||
tmp.querySelector('#wh-qua-alarm-check-btn')
|
tmp.querySelector('#wh-qua-alarm-check-btn')
|
||||||
.addEventListener('click', () => BuyBeerHelper.getInstance().skip_today());
|
.addEventListener('click', () => this.buyBeerHelper.skip_today());
|
||||||
pop.getElement().innerHTML = '';
|
pop.getElement().innerHTML = '';
|
||||||
pop.getElement().appendChild(tmp);
|
pop.getElement().appendChild(tmp);
|
||||||
(window.initializeTooltip) && (window.initializeTooltip('#wh-popup-cont', 'white-tooltip'));
|
(window.initializeTooltip) && (window.initializeTooltip('#wh-popup-cont', 'white-tooltip'));
|
||||||
@ -47,7 +59,7 @@ class SettingsHandler extends Provider {
|
|||||||
Log.info('构造设置列表开始');
|
Log.info('构造设置列表开始');
|
||||||
const date = new Date();
|
const date = new Date();
|
||||||
|
|
||||||
let beer = BuyBeerHelper.getInstance();
|
let beer = this.buyBeerHelper;
|
||||||
|
|
||||||
let list = this.list;
|
let list = this.list;
|
||||||
|
|
||||||
@ -103,7 +115,7 @@ class SettingsHandler extends Provider {
|
|||||||
domId: '',
|
domId: '',
|
||||||
domText: '更新翻译词库',
|
domText: '更新翻译词库',
|
||||||
isTornBtn: true,
|
isTornBtn: true,
|
||||||
clickFunc: () => UpdateTranslateDict.getInstance().handle()
|
clickFunc: () => this.updateTranslateDict.handle()
|
||||||
});
|
});
|
||||||
// 收集数据以改进翻译质量
|
// 收集数据以改进翻译质量
|
||||||
list.push({
|
list.push({
|
||||||
@ -384,7 +396,7 @@ class SettingsHandler extends Provider {
|
|||||||
domText: '啤酒提醒时间设定',
|
domText: '啤酒提醒时间设定',
|
||||||
isTornBtn: true,
|
isTornBtn: true,
|
||||||
// tip: '通知提前时间',
|
// tip: '通知提前时间',
|
||||||
clickFunc: () => BuyBeerHelper.getInstance().setTimeHandler()
|
clickFunc: () => this.buyBeerHelper.setTimeHandler()
|
||||||
});
|
});
|
||||||
|
|
||||||
// 个人资料
|
// 个人资料
|
||||||
@ -537,13 +549,13 @@ class SettingsHandler extends Provider {
|
|||||||
dictName: 'isDev',
|
dictName: 'isDev',
|
||||||
isHide: true,
|
isHide: true,
|
||||||
});
|
});
|
||||||
// 查看logs
|
// 自定义CSS
|
||||||
list.push({
|
list.push({
|
||||||
domType: 'button',
|
domType: 'button',
|
||||||
domId: null,
|
domId: null,
|
||||||
domText: '自定义CSS',
|
domText: '自定义CSS',
|
||||||
isTornBtn: true,
|
isTornBtn: true,
|
||||||
clickFunc: () => CustomCssHandler.getInstance().handle()
|
clickFunc: () => this.customCssHandler.handle()
|
||||||
});
|
});
|
||||||
// 查看logs
|
// 查看logs
|
||||||
list.push({
|
list.push({
|
||||||
@ -551,13 +563,13 @@ class SettingsHandler extends Provider {
|
|||||||
domId: null,
|
domId: null,
|
||||||
domText: '查看日志',
|
domText: '查看日志',
|
||||||
isTornBtn: true,
|
isTornBtn: true,
|
||||||
clickFunc: () => ViewLogsHandler.getInstance().handle()
|
clickFunc: () => this.viewLogsHandler.handle()
|
||||||
});
|
});
|
||||||
// 更多设定
|
// 更多设定
|
||||||
list.push({
|
list.push({
|
||||||
domType: 'button', domId: 'wh-otherBtn', domText: '更多设定',
|
domType: 'button', domId: 'wh-otherBtn', domText: '更多设定',
|
||||||
isTornBtn: true,
|
isTornBtn: true,
|
||||||
clickFunc: () => AdditionalSettingsHandler.getInstance().show()
|
clickFunc: () => this.additionalSettingsHandler.show()
|
||||||
});
|
});
|
||||||
|
|
||||||
Log.info('构造设置列表结束' + timer.getTimeMs());
|
Log.info('构造设置列表结束' + timer.getTimeMs());
|
||||||
@ -568,5 +580,5 @@ class SettingsHandler extends Provider {
|
|||||||
export default {
|
export default {
|
||||||
domType: MENU_ITEM_TYPE.BUTTON,
|
domType: MENU_ITEM_TYPE.BUTTON,
|
||||||
domText: '⚙️ 助手设置',
|
domText: '⚙️ 助手设置',
|
||||||
clickFunc: () => SettingsHandler.getInstance().show()
|
clickFunc: () => Container.factory(SettingsHandler).show()
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,8 +1,10 @@
|
|||||||
import WuhuBase from "../WuhuBase";
|
|
||||||
import Alert from "../utils/Alert";
|
import Alert from "../utils/Alert";
|
||||||
|
import ClassName from "../../container/ClassName";
|
||||||
|
import { Injectable } from "../../container/Injectable";
|
||||||
|
|
||||||
export default class UpdateTranslateDict extends WuhuBase {
|
@ClassName('UpdateTranslateDict')
|
||||||
className = 'UpdateTranslateDict';
|
@Injectable()
|
||||||
|
export default class UpdateTranslateDict {
|
||||||
|
|
||||||
public handle(): void {
|
public handle(): void {
|
||||||
new Alert('计划中');
|
new Alert('计划中');
|
||||||
|
|||||||
@ -1,11 +1,18 @@
|
|||||||
import WuhuBase from "../WuhuBase";
|
|
||||||
import Log from "../Log";
|
import Log from "../Log";
|
||||||
import Popup from "../utils/Popup";
|
import Popup from "../utils/Popup";
|
||||||
import CommonUtils from "../utils/CommonUtils";
|
import CommonUtils from "../utils/CommonUtils";
|
||||||
import VIEW_LOGS_HANDLER_HTML from "../../../static/html/view_logs_handler.html";
|
import VIEW_LOGS_HANDLER_HTML from "../../../static/html/view_logs_handler.html";
|
||||||
|
import ClassName from "../../container/ClassName";
|
||||||
|
import { Injectable } from "../../container/Injectable";
|
||||||
|
|
||||||
export default class ViewLogsHandler extends WuhuBase {
|
@ClassName('ViewLogsHandler')
|
||||||
className = 'ViewLogsHandler';
|
@Injectable()
|
||||||
|
export default class ViewLogsHandler {
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
private readonly commonUtils: CommonUtils,
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
public handle(): void {
|
public handle(): void {
|
||||||
let logCounter = Log.getCounter();
|
let logCounter = Log.getCounter();
|
||||||
@ -14,7 +21,7 @@ export default class ViewLogsHandler extends WuhuBase {
|
|||||||
.replace('{{}}', logCounter.warning.toString())
|
.replace('{{}}', logCounter.warning.toString())
|
||||||
.replace('{{}}', logCounter.error.toString()), '查看日志');
|
.replace('{{}}', logCounter.error.toString()), '查看日志');
|
||||||
window.setTimeout(() => {
|
window.setTimeout(() => {
|
||||||
let container = pop.getElement().querySelector('div');
|
let container = pop.element.querySelector('div');
|
||||||
let text = document.createElement('div');
|
let text = document.createElement('div');
|
||||||
let logs = Log.getLogs().split('\r\n');
|
let logs = Log.getLogs().split('\r\n');
|
||||||
logs.forEach(log => {
|
logs.forEach(log => {
|
||||||
@ -27,18 +34,17 @@ export default class ViewLogsHandler extends WuhuBase {
|
|||||||
}
|
}
|
||||||
text.append(p);
|
text.append(p);
|
||||||
});
|
});
|
||||||
pop.getElement().querySelector('button').addEventListener('click', () => window.setTimeout(() => {
|
pop.element.querySelector('button').addEventListener('click', () => window.setTimeout(() => {
|
||||||
CommonUtils.getInstance()
|
this.commonUtils.exportTextFile(
|
||||||
.exportTextFile(
|
'wuhu_log_' + Log.getTime()
|
||||||
'wuhu_log_' + Log.getTime()
|
.replace('[', '')
|
||||||
.replace('[', '')
|
.replace(']', '')
|
||||||
.replace(']', '')
|
.replace(' ', '')
|
||||||
.replace(' ', '')
|
.replace('.', '')
|
||||||
.replace('.', '')
|
.replaceAll('-', '')
|
||||||
.replaceAll('-', '')
|
.replaceAll(':', '') + '.log',
|
||||||
.replaceAll(':', '') + '.log',
|
[Log.getLogs()]
|
||||||
[Log.getLogs()]
|
);
|
||||||
);
|
|
||||||
}, 0));
|
}, 0));
|
||||||
container.innerHTML = '';
|
container.innerHTML = '';
|
||||||
container.append(text);
|
container.append(text);
|
||||||
|
|||||||
@ -1,4 +1,6 @@
|
|||||||
import Log from "../Log";
|
import { GetClassName } from "../../container/ClassName";
|
||||||
|
import Logger from "../Logger";
|
||||||
|
import { Container } from "../../container/Container";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 方法装饰器
|
* 方法装饰器
|
||||||
@ -7,21 +9,37 @@ import Log from "../Log";
|
|||||||
* @param descriptor
|
* @param descriptor
|
||||||
*/
|
*/
|
||||||
export default function (target: any, propertyKey: string, descriptor: PropertyDescriptor) {
|
export default function (target: any, propertyKey: string, descriptor: PropertyDescriptor) {
|
||||||
|
const logger: Logger = Container.factory(Logger);
|
||||||
|
|
||||||
const original = descriptor.value;
|
const original = descriptor.value;
|
||||||
|
|
||||||
descriptor.value = function (...args) {
|
descriptor.value = function (...args) {
|
||||||
Log.info('[debug] 参数 ', JSON.stringify({
|
// Log.info('[debug] 参数 ', JSON.stringify({
|
||||||
class: target.className || target.name,
|
// class: target.className || target.name,
|
||||||
method: propertyKey,
|
// method: propertyKey,
|
||||||
args
|
// args
|
||||||
}));
|
// }));
|
||||||
|
|
||||||
let result;
|
let result;
|
||||||
try {
|
try {
|
||||||
result = original.call(this, ...args) || null;
|
result = original.call(this, ...args) || null;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
Log.error('[debug] 异常 ', err.stack || err.message || err);
|
logger.error('[debug]', err.stack || err.message || err, '参数' + JSON.stringify({
|
||||||
|
class: GetClassName(target) ?? target.name,
|
||||||
|
method: propertyKey,
|
||||||
|
args
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
result && Log.info('[debug] 结果 ', { result });
|
logger.info(
|
||||||
|
'[debug]',
|
||||||
|
'参数' + JSON.stringify({
|
||||||
|
class: GetClassName(target) ?? target.name,
|
||||||
|
method: propertyKey,
|
||||||
|
args
|
||||||
|
}),
|
||||||
|
'结果',
|
||||||
|
{ result }
|
||||||
|
);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,14 +1,21 @@
|
|||||||
import WuhuBase from "../WuhuBase";
|
|
||||||
import Log from "../Log";
|
|
||||||
import ZhongIcon from "../ZhongIcon";
|
import ZhongIcon from "../ZhongIcon";
|
||||||
|
import ClassName from "../../container/ClassName";
|
||||||
|
import { Injectable } from "../../container/Injectable";
|
||||||
|
import Logger from "../Logger";
|
||||||
|
|
||||||
export default class ActionButtonUtils extends WuhuBase {
|
@ClassName('ActionButtonUtils')
|
||||||
className = 'ActionButtonUtils';
|
@Injectable()
|
||||||
|
export default class ActionButtonUtils {
|
||||||
private hasAdded: boolean = false;
|
private hasAdded: boolean = false;
|
||||||
|
|
||||||
|
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);
|
if (!this.hasAdded) this.handle(txt, func);
|
||||||
else Log.warn('ActionButton已存在');
|
else this.logger.warn('ActionButton已存在');
|
||||||
}
|
}
|
||||||
|
|
||||||
private handle(txt, func): void {
|
private handle(txt, func): void {
|
||||||
@ -20,6 +27,6 @@ export default class ActionButtonUtils extends WuhuBase {
|
|||||||
btn.addEventListener('click', func);
|
btn.addEventListener('click', func);
|
||||||
ZhongIcon.ZhongNode.querySelector('button').after(btn);
|
ZhongIcon.ZhongNode.querySelector('button').after(btn);
|
||||||
this.hasAdded = true;
|
this.hasAdded = true;
|
||||||
Log.info('ActionButton已添加', { txt, func, btn });
|
this.logger.info('ActionButton已添加', { txt, func, btn });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,13 +1,14 @@
|
|||||||
import Log from "../Log";
|
|
||||||
import IWHNotify from "../../interface/IWHNotify";
|
import IWHNotify from "../../interface/IWHNotify";
|
||||||
import NotificationUtils from "./NotificationUtils";
|
import NotificationUtils from "./NotificationUtils";
|
||||||
import WuhuBase from "../WuhuBase";
|
|
||||||
import MathUtils from "./MathUtils";
|
import MathUtils from "./MathUtils";
|
||||||
import NOTIFY_HTML from "../../../static/html/notify.html";
|
import NOTIFY_HTML from "../../../static/html/notify.html";
|
||||||
import WindowActiveState from "../action/WindowActiveState";
|
import WindowActiveState from "../action/WindowActiveState";
|
||||||
|
import { Container } from "../../container/Container";
|
||||||
|
import Logger from "../Logger";
|
||||||
|
import ClassName from "../../container/ClassName";
|
||||||
|
|
||||||
export default class Alert extends WuhuBase {
|
@ClassName('Alert')
|
||||||
className = 'Alert';
|
export default class Alert {
|
||||||
private static container: HTMLElement = null;
|
private static container: HTMLElement = null;
|
||||||
private static totalCounter: number = 0;
|
private static totalCounter: number = 0;
|
||||||
|
|
||||||
@ -15,35 +16,41 @@ export default class Alert extends WuhuBase {
|
|||||||
private intervalID = -1;
|
private intervalID = -1;
|
||||||
private readonly callback: Function;
|
private readonly callback: Function;
|
||||||
|
|
||||||
public constructor(msg: string, options: IWHNotify = {}) {
|
public constructor(
|
||||||
super();
|
msg: string,
|
||||||
|
options: IWHNotify = {},
|
||||||
|
private readonly mathUtils: MathUtils = Container.factory(MathUtils),
|
||||||
|
private readonly windowActiveState: WindowActiveState = Container.factory(WindowActiveState),
|
||||||
|
private readonly notificationUtils: NotificationUtils = Container.factory(NotificationUtils),
|
||||||
|
private readonly logger: Logger = Container.factory(Logger),
|
||||||
|
) {
|
||||||
|
|
||||||
let { timeout, callback, sysNotify, force } = options;
|
let { timeout, callback, sysNotify, force } = options;
|
||||||
|
|
||||||
// 后台窗口、iframe内判断
|
// 后台窗口、iframe内判断
|
||||||
if (!WindowActiveState.getInstance().get() || (self !== top)) {
|
if (!this.windowActiveState.get() || (self !== top)) {
|
||||||
if (!force) {
|
if (!force) {
|
||||||
Log.warn('后台通知已被屏蔽');
|
this.logger.warn('后台通知已被屏蔽');
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
Log.info('强制后台通知');
|
this.logger.info('强制后台通知');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 通知的容器
|
// 通知的容器
|
||||||
Log.info('通知的容器', Alert.container);
|
this.logger.info('通知的容器', Alert.container);
|
||||||
if (!Alert.container || !document.contains(Alert.container)) Alert.initContainer();
|
if (!Alert.container || !document.contains(Alert.container)) Alert.initContainer();
|
||||||
|
|
||||||
this.callback = callback || (() => null);
|
this.callback = callback || (() => null);
|
||||||
Alert.create(this, msg, timeout || 3);
|
Alert.create(this, msg, timeout || 3);
|
||||||
Alert.totalCounter++;
|
Alert.totalCounter++;
|
||||||
Log.info('创建新通知:', this, msg);
|
this.logger.info('创建新通知:', this, msg);
|
||||||
if (sysNotify) NotificationUtils.getInstance().push(msg, options);
|
if (sysNotify) this.notificationUtils.push(msg, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static create(that: Alert, msg, timeout): void {
|
private static create(that: Alert, msg, timeout): void {
|
||||||
// 通知的唯一id
|
// 通知的唯一id
|
||||||
const uid = '' + MathUtils.getInstance().getRandomInt(1000, 9999);
|
const uid = '' + that.mathUtils.getRandomInt(1000, 9999);
|
||||||
// 每条通知
|
// 每条通知
|
||||||
const element: MyHTMLElement = document.createElement('div');
|
const element: MyHTMLElement = document.createElement('div');
|
||||||
element.id = `wh-notify-${ uid }`;
|
element.id = `wh-notify-${ uid }`;
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
import UserScriptEngine from "../../enum/UserScriptEngine";
|
import UserScriptEngine from "../../enum/UserScriptEngine";
|
||||||
import WuhuBase from "../WuhuBase";
|
|
||||||
import Log from "../Log";
|
import Log from "../Log";
|
||||||
import Device from "../../enum/Device";
|
import Device from "../../enum/Device";
|
||||||
import LOADING_IMG_HTML from "../../../static/html/loading_img.html";
|
import LOADING_IMG_HTML from "../../../static/html/loading_img.html";
|
||||||
@ -12,19 +11,36 @@ import TRAVEL_STATE from "../../enum/TravelState";
|
|||||||
import InventoryItemInfo from "../../interface/responseType/InventoryItemInfo";
|
import InventoryItemInfo from "../../interface/responseType/InventoryItemInfo";
|
||||||
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 Logger from "../Logger";
|
||||||
|
import Global from "../Global";
|
||||||
|
import { Container } from "../../container/Container";
|
||||||
|
import TornPDAUtils from "./TornPDAUtils";
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
@ClassName('CommonUtils')
|
@ClassName('CommonUtils')
|
||||||
export default class CommonUtils extends WuhuBase {
|
export default class CommonUtils {
|
||||||
className = 'CommonUtils';
|
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
private readonly localConfigWrapper: LocalConfigWrapper,
|
||||||
|
private readonly fetchUtils: FetchUtils,
|
||||||
|
private readonly logger: Logger,
|
||||||
|
private readonly global: Global,
|
||||||
|
private readonly tornPDAUtils: TornPDAUtils,
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
static getScriptEngine() {
|
static getScriptEngine() {
|
||||||
let glob = CommonUtils.glob;
|
let glob = Container.factory(Global);
|
||||||
return glob.GM_xmlhttpRequest ? UserScriptEngine.GM : glob.isPDA
|
let tornPDAUtils = Container.factory(TornPDAUtils);
|
||||||
|
return glob.GM_xmlhttpRequest ? UserScriptEngine.GM : tornPDAUtils.isPDA()
|
||||||
? UserScriptEngine.PDA : UserScriptEngine.RAW;
|
? UserScriptEngine.PDA : UserScriptEngine.RAW;
|
||||||
}
|
}
|
||||||
|
|
||||||
static COFetch(url: URL | string, method: 'get' | 'post' = 'get', body: any = null): Promise<string> {
|
static COFetch(url: URL | string, method: 'get' | 'post' | string = 'get', body: any = null): Promise<string> {
|
||||||
let start = new Timer();
|
let start = new Timer();
|
||||||
const engine = this.getScriptEngine();
|
const engine = this.getScriptEngine();
|
||||||
Log.info('跨域获取数据开始, 脚本引擎: ' + engine);
|
Log.info('跨域获取数据开始, 脚本引擎: ' + engine);
|
||||||
@ -69,7 +85,7 @@ export default class CommonUtils extends WuhuBase {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case UserScriptEngine.GM: {
|
case UserScriptEngine.GM: {
|
||||||
let { GM_xmlhttpRequest } = CommonUtils.glob;
|
let { GM_xmlhttpRequest } = Container.factory(Global);
|
||||||
if (typeof GM_xmlhttpRequest !== 'function') {
|
if (typeof GM_xmlhttpRequest !== 'function') {
|
||||||
Log.error('COFetch网络错误:用户脚本扩展API错误');
|
Log.error('COFetch网络错误:用户脚本扩展API错误');
|
||||||
reject('错误:用户脚本扩展API错误');
|
reject('错误:用户脚本扩展API错误');
|
||||||
@ -91,6 +107,13 @@ export default class CommonUtils extends WuhuBase {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getScriptEngine() {
|
||||||
|
// let glob = Container.factory(Global);
|
||||||
|
// let tornPDAUtils = Container.factory(TornPDAUtils);
|
||||||
|
return this.global.GM_xmlhttpRequest ? UserScriptEngine.GM : this.tornPDAUtils.isPDA()
|
||||||
|
? UserScriptEngine.PDA : UserScriptEngine.RAW;
|
||||||
|
}
|
||||||
|
|
||||||
// /**
|
// /**
|
||||||
// * 返回玩家信息的对象 { playername: string, userID: number }
|
// * 返回玩家信息的对象 { playername: string, userID: number }
|
||||||
// * @return {PlayerInfo} rs
|
// * @return {PlayerInfo} rs
|
||||||
@ -210,12 +233,19 @@ export default class CommonUtils extends WuhuBase {
|
|||||||
* @param {string} url 播放的音频URL
|
* @param {string} url 播放的音频URL
|
||||||
* @returns {undefined}
|
* @returns {undefined}
|
||||||
*/
|
*/
|
||||||
public audioPlay(url: string = 'https://www.torn.com/js/chat/sounds/Warble_1.mp3') {
|
public audioPlay(url: string = 'https://www.torn.com/js/chat/sounds/Warble_1.mp3'): Promise<void> {
|
||||||
const audio = new Audio(url);
|
return new Promise((resolve, reject) => {
|
||||||
audio.addEventListener("canplaythrough", () => {
|
const audio = new Audio(url);
|
||||||
audio.play()
|
audio.addEventListener("canplaythrough", () => {
|
||||||
.catch(err => Log.error('播放音频出错', err.message, err.stack))
|
audio.play()
|
||||||
.then();
|
.catch(err => {
|
||||||
|
this.logger.error('播放音频出错', err.message, err.stack);
|
||||||
|
reject();
|
||||||
|
})
|
||||||
|
.then(
|
||||||
|
() => resolve()
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -233,11 +263,11 @@ export default class CommonUtils extends WuhuBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public jQueryReady(): Promise<null> {
|
public jQueryReady(): Promise<null> {
|
||||||
Log.info('等待jQuery加载中...');
|
this.logger.info('等待jQuery加载中...');
|
||||||
FetchUtils.getInstance().fetchText('/js/script/lib/jquery-1.8.2.js?v=f9128651g')
|
this.fetchUtils.fetchText('/js/script/lib/jquery-1.8.2.js?v=f9128651g')
|
||||||
.then(res => window.eval(res));
|
.then(res => window.eval(res));
|
||||||
let intervalId = window.setInterval(() => {
|
let intervalId = window.setInterval(() => {
|
||||||
Log.info('仍在等待jQuery加载中...');
|
this.logger.info('仍在等待jQuery加载中...');
|
||||||
}, 1000);
|
}, 1000);
|
||||||
return new Promise(async resolve => {
|
return new Promise(async resolve => {
|
||||||
while (true) {
|
while (true) {
|
||||||
@ -245,7 +275,7 @@ export default class CommonUtils extends WuhuBase {
|
|||||||
await this.sleep(100);
|
await this.sleep(100);
|
||||||
}
|
}
|
||||||
window.clearInterval(intervalId);
|
window.clearInterval(intervalId);
|
||||||
Log.info('jQuery已加载');
|
this.logger.info('jQuery已加载');
|
||||||
resolve(null);
|
resolve(null);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -272,7 +302,7 @@ export default class CommonUtils extends WuhuBase {
|
|||||||
let _input = switcher.getInput();
|
let _input = switcher.getInput();
|
||||||
switcher.getBase().id = domId;
|
switcher.getBase().id = domId;
|
||||||
(tip) && (switcher.getBase().setAttribute('title', tip));
|
(tip) && (switcher.getBase().setAttribute('title', tip));
|
||||||
_input.checked = WuhuConfig.get(dictName);
|
_input.checked = this.localConfigWrapper.config[dictName];
|
||||||
_input.onchange = e => {
|
_input.onchange = e => {
|
||||||
WuhuConfig.set(dictName, _input.checked, true);
|
WuhuConfig.set(dictName, _input.checked, true);
|
||||||
if (changeEv) changeEv(e);
|
if (changeEv) changeEv(e);
|
||||||
@ -305,7 +335,7 @@ export default class CommonUtils extends WuhuBase {
|
|||||||
let option = document.createElement('option');
|
let option = document.createElement('option');
|
||||||
option.value = domVal;
|
option.value = domVal;
|
||||||
option.innerHTML = domText;
|
option.innerHTML = domText;
|
||||||
option.selected = i === WuhuConfig.get(dictName);
|
option.selected = i === this.localConfigWrapper.config[dictName];
|
||||||
option.innerHTML = domText;
|
option.innerHTML = domText;
|
||||||
select.appendChild(option);
|
select.appendChild(option);
|
||||||
});
|
});
|
||||||
@ -345,7 +375,7 @@ export default class CommonUtils extends WuhuBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public getTravelStage(): TRAVEL_STATE {
|
public getTravelStage(): TRAVEL_STATE {
|
||||||
let global = CommonUtils.glob;
|
let global = Container.factory(Global);
|
||||||
if (global.bodyAttrs["data-abroad"] === 'false') {
|
if (global.bodyAttrs["data-abroad"] === 'false') {
|
||||||
return TRAVEL_STATE.IN_TORN;
|
return TRAVEL_STATE.IN_TORN;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,10 +1,16 @@
|
|||||||
import WuhuBase from "../WuhuBase";
|
|
||||||
import Log from "../Log";
|
|
||||||
import AjaxFetchOption from "../../interface/AjaxFetchOption";
|
import AjaxFetchOption from "../../interface/AjaxFetchOption";
|
||||||
import IUserProfileData from "../../interface/IUserProfileData";
|
import IUserProfileData from "../../interface/IUserProfileData";
|
||||||
|
import ClassName from "../../container/ClassName";
|
||||||
|
import { Injectable } from "../../container/Injectable";
|
||||||
|
import Logger from "../Logger";
|
||||||
|
|
||||||
export default class FetchUtils extends WuhuBase {
|
@ClassName('FetchUtils')
|
||||||
className = 'FetchUtils';
|
@Injectable()
|
||||||
|
export default class FetchUtils {
|
||||||
|
constructor(
|
||||||
|
private readonly logger: Logger,
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 包装jquery ajax 异步返回string
|
* 包装jquery ajax 异步返回string
|
||||||
@ -55,7 +61,7 @@ export default class FetchUtils extends WuhuBase {
|
|||||||
.then(res => res.text())
|
.then(res => res.text())
|
||||||
.then(t => resolve(t))
|
.then(t => resolve(t))
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
Log.error('fetchText出错了', err);
|
this.logger.error('fetchText出错了', err);
|
||||||
reject(err);
|
reject(err);
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
@ -70,11 +76,11 @@ export default class FetchUtils extends WuhuBase {
|
|||||||
o.json().then((res) => {
|
o.json().then((res) => {
|
||||||
resolve(res);
|
resolve(res);
|
||||||
}).catch(e => {
|
}).catch(e => {
|
||||||
Log.error('[ProfileHelper] JSON解析错误: ', e.message, '错误堆栈: ', e.stack);
|
this.logger.error('[ProfileHelper] JSON解析错误: ', e.message, '错误堆栈: ', e.stack);
|
||||||
reject(e);
|
reject(e);
|
||||||
});
|
});
|
||||||
}).catch(e => {
|
}).catch(e => {
|
||||||
Log.error('[ProfileHelper] 网络错误: ', e.message, '错误堆栈: ', e.stack);
|
this.logger.error('[ProfileHelper] 网络错误: ', e.message, '错误堆栈: ', e.stack);
|
||||||
reject(e);
|
reject(e);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,12 +1,22 @@
|
|||||||
import WuhuBase from "../WuhuBase";
|
|
||||||
import Alert from "./Alert";
|
import Alert from "./Alert";
|
||||||
import ISidebarData from "../../interface/ISidebarData";
|
import ISidebarData from "../../interface/ISidebarData";
|
||||||
import Log from "../Log";
|
import Log from "../Log";
|
||||||
import CommonUtils from "./CommonUtils";
|
|
||||||
import FetchUtils from "./FetchUtils";
|
import FetchUtils from "./FetchUtils";
|
||||||
|
import ClassName from "../../container/ClassName";
|
||||||
|
import { Injectable } from "../../container/Injectable";
|
||||||
|
import Logger from "../Logger";
|
||||||
|
|
||||||
export default class InfoUtils extends WuhuBase {
|
@ClassName('InfoUtils')
|
||||||
className = 'InfoUtils';
|
@Injectable()
|
||||||
|
export default class InfoUtils {
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
// TODO 循环依赖
|
||||||
|
// private readonly commonUtils: CommonUtils,
|
||||||
|
private readonly fetchUtils: FetchUtils,
|
||||||
|
private readonly logger: Logger,
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 返回玩家信息的对象 { playername: string, userID: number }
|
* 返回玩家信息的对象 { playername: string, userID: number }
|
||||||
@ -20,7 +30,7 @@ export default class InfoUtils extends WuhuBase {
|
|||||||
userID: parseInt(node.getAttribute('uid')),
|
userID: parseInt(node.getAttribute('uid')),
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
new Alert('严重错误:芜湖助手无法获取用户数据,已退出');
|
(() => new Alert('严重错误:芜湖助手无法获取用户数据,已退出'))();
|
||||||
throw '芜湖助手无法获取用户数据';
|
throw '芜湖助手无法获取用户数据';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -35,19 +45,30 @@ export default class InfoUtils extends WuhuBase {
|
|||||||
let c = 0;
|
let c = 0;
|
||||||
while (!sessionStorage.getItem(field) && c < 50) {
|
while (!sessionStorage.getItem(field) && c < 50) {
|
||||||
c++;
|
c++;
|
||||||
await CommonUtils.getInstance().sleep(10);
|
// await (async () => await this.commonUtils.sleep(10))();
|
||||||
|
await (async () => window.setTimeout(() => Promise.resolve(), 10))();
|
||||||
}
|
}
|
||||||
if (sessionStorage.getItem(field)) {
|
if (sessionStorage.getItem(field)) {
|
||||||
ret = JSON.parse(sessionStorage.getItem(field));
|
try {
|
||||||
|
ret = JSON.parse(sessionStorage.getItem(field));
|
||||||
|
} catch (e) {
|
||||||
|
this.logger.error('解析出错', e.stack || e.message || e);
|
||||||
|
ret = {};
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
Log.info('无法从sessionStorage获取数据')
|
Log.info('无法从sessionStorage获取数据')
|
||||||
ret = await (await FetchUtils.getInstance().ajaxFetch({
|
ret = await (await this.fetchUtils.ajaxFetch({
|
||||||
url: window.addRFC('/sidebarAjaxAction.php?q=getSidebarData'),
|
url: window.addRFC('/sidebarAjaxAction.php?q=getSidebarData'),
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
})).json();
|
})).json();
|
||||||
sessionStorage.setItem(field, JSON.stringify(ret));
|
sessionStorage.setItem(field, JSON.stringify(ret));
|
||||||
}
|
}
|
||||||
ret.headerData = JSON.parse(sessionStorage.getItem('headerData'));
|
try {
|
||||||
|
ret.headerData = JSON.parse(sessionStorage.getItem('headerData'));
|
||||||
|
} catch (e) {
|
||||||
|
this.logger.error('解析出错', e.stack || e.message || e);
|
||||||
|
ret.headerData = null;
|
||||||
|
}
|
||||||
resolve(ret);
|
resolve(ret);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,13 +1,20 @@
|
|||||||
import WuhuBase from "../WuhuBase";
|
|
||||||
import InventoryItemInfo from "../../interface/responseType/InventoryItemInfo";
|
import InventoryItemInfo from "../../interface/responseType/InventoryItemInfo";
|
||||||
import FetchUtils from "./FetchUtils";
|
import FetchUtils from "./FetchUtils";
|
||||||
import CommonUtils from "./CommonUtils";
|
import CommonUtils from "./CommonUtils";
|
||||||
import Log from "../Log";
|
import Log from "../Log";
|
||||||
import PriceData from "../../interface/PriceData";
|
import PriceData from "../../interface/PriceData";
|
||||||
import Asyncable from "../../interface/Asyncable";
|
import Asyncable from "../../interface/Asyncable";
|
||||||
|
import ClassName from "../../container/ClassName";
|
||||||
|
import { Injectable } from "../../container/Injectable";
|
||||||
|
|
||||||
export default class ItemHelper extends WuhuBase {
|
@ClassName('ItemHelper')
|
||||||
className = "ItemHelper";
|
@Injectable()
|
||||||
|
export default class ItemHelper {
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
private readonly fetchUtils: FetchUtils,
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
/** 保存物品名-ID对应关系 */
|
/** 保存物品名-ID对应关系 */
|
||||||
private itemNameMap: { [name: string]: number } = null;
|
private itemNameMap: { [name: string]: number } = null;
|
||||||
@ -32,11 +39,6 @@ export default class ItemHelper extends WuhuBase {
|
|||||||
// 缓存过期时间 分钟
|
// 缓存过期时间 分钟
|
||||||
private readonly priceTimeout = 720;
|
private readonly priceTimeout = 720;
|
||||||
|
|
||||||
// TODO 定时
|
|
||||||
constructor() {
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
|
|
||||||
/** TODO 通过 name 查询 */
|
/** TODO 通过 name 查询 */
|
||||||
public async getItemData(idOrName: string): Promise<Partial<InventoryItemInfo>> {
|
public async getItemData(idOrName: string): Promise<Partial<InventoryItemInfo>> {
|
||||||
let _itemId: number = null;
|
let _itemId: number = null;
|
||||||
@ -50,7 +52,7 @@ export default class ItemHelper extends WuhuBase {
|
|||||||
} else {
|
} else {
|
||||||
itemId = (await this.getItemNameMap().promise)[idOrName];
|
itemId = (await this.getItemNameMap().promise)[idOrName];
|
||||||
}
|
}
|
||||||
return await (await FetchUtils.getInstance().ajaxFetch({
|
return await (await this.fetchUtils.ajaxFetch({
|
||||||
url: '/inventory.php',
|
url: '/inventory.php',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
|
|||||||
@ -1,7 +1,9 @@
|
|||||||
import WuhuBase from "../WuhuBase";
|
import ClassName from "../../container/ClassName";
|
||||||
|
import { Injectable } from "../../container/Injectable";
|
||||||
|
|
||||||
export default class MDUtils extends WuhuBase {
|
@ClassName('MDUtils')
|
||||||
className = 'MDUtils';
|
@Injectable()
|
||||||
|
export default class MDUtils {
|
||||||
/**
|
/**
|
||||||
* 解析 Markdown 内容
|
* 解析 Markdown 内容
|
||||||
* @param {String} from
|
* @param {String} from
|
||||||
|
|||||||
@ -1,7 +1,11 @@
|
|||||||
import WuhuBase from "../WuhuBase";
|
import ClassName from "../../container/ClassName";
|
||||||
|
import { Injectable } from "../../container/Injectable";
|
||||||
|
|
||||||
export default class MathUtils extends WuhuBase {
|
@ClassName('MathUtils')
|
||||||
|
@Injectable()
|
||||||
|
export default class MathUtils {
|
||||||
className = 'MathUtils';
|
className = 'MathUtils';
|
||||||
|
|
||||||
// 得到一个两数之间的随机整数
|
// 得到一个两数之间的随机整数
|
||||||
public getRandomInt(min: number, max: number): number {
|
public getRandomInt(min: number, max: number): number {
|
||||||
min = Math.ceil(min);
|
min = Math.ceil(min);
|
||||||
|
|||||||
@ -1,13 +1,21 @@
|
|||||||
import IWHNotify from "../../interface/IWHNotify";
|
import IWHNotify from "../../interface/IWHNotify";
|
||||||
import Log from "../Log";
|
import Log from "../Log";
|
||||||
import WuhuBase from "../WuhuBase";
|
import ClassName from "../../container/ClassName";
|
||||||
|
import { Injectable } from "../../container/Injectable";
|
||||||
|
|
||||||
|
@ClassName('NotificationUtils')
|
||||||
|
@Injectable()
|
||||||
|
export default class NotificationUtils {
|
||||||
|
constructor(
|
||||||
|
// TODO 循环依赖
|
||||||
|
// private readonly global: Global,
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
export default class NotificationUtils extends WuhuBase {
|
|
||||||
className = 'NotificationUtils';
|
|
||||||
private permission: boolean = window.Notification && window.Notification.permission === 'granted';
|
private permission: boolean = window.Notification && window.Notification.permission === 'granted';
|
||||||
|
|
||||||
public push(msg: string, options: IWHNotify = {}): void {
|
public push(msg: string, options: IWHNotify = {}): void {
|
||||||
let { notifies } = NotificationUtils.glob;
|
// let { notifies } = this.global;
|
||||||
|
|
||||||
if (options.sysNotify && this.permission) {
|
if (options.sysNotify && this.permission) {
|
||||||
let tmpNode = document.createElement('p');
|
let tmpNode = document.createElement('p');
|
||||||
@ -18,14 +26,14 @@ export default class NotificationUtils extends WuhuBase {
|
|||||||
// renotify: true,
|
// renotify: true,
|
||||||
// tag: '芜湖助手' + Utils.getRandomInt(0, 99),
|
// tag: '芜湖助手' + Utils.getRandomInt(0, 99),
|
||||||
});
|
});
|
||||||
let id = notifies.count++;
|
// let id = notifies.count++;
|
||||||
notifies[id] = notify;
|
// notifies[id] = notify;
|
||||||
notify.addEventListener(
|
// notify.addEventListener(
|
||||||
'close',
|
// 'close',
|
||||||
() => {
|
// () => {
|
||||||
notifies[id] = null;
|
// notifies[id] = null;
|
||||||
}
|
// }
|
||||||
);
|
// );
|
||||||
notify.addEventListener(
|
notify.addEventListener(
|
||||||
'click',
|
'click',
|
||||||
() => {
|
() => {
|
||||||
@ -33,13 +41,13 @@ export default class NotificationUtils extends WuhuBase {
|
|||||||
window.focus();
|
window.focus();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
notify.addEventListener(
|
// notify.addEventListener(
|
||||||
'show',
|
// 'show',
|
||||||
() => {
|
// () => {
|
||||||
// setTimeout(() => notify.close(), (options.timeout || 3) * 1000);
|
// // setTimeout(() => notify.close(), (options.timeout || 3) * 1000);
|
||||||
Log.info('通知id: ', id)
|
// Log.info('通知id: ', id)
|
||||||
}
|
// }
|
||||||
);
|
// );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,12 +1,13 @@
|
|||||||
import WuhuBase from "../WuhuBase";
|
|
||||||
import POPUP_HTML from "../../../static/html/popup.html";
|
import POPUP_HTML from "../../../static/html/popup.html";
|
||||||
import Log from "../Log";
|
import { Container } from "../../container/Container";
|
||||||
|
import Global from "../Global";
|
||||||
|
import Logger from "../Logger";
|
||||||
|
import globVars from "../../globVars";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 弹窗
|
* 弹窗
|
||||||
*/
|
*/
|
||||||
export default class Popup extends WuhuBase {
|
export default class Popup {
|
||||||
className = 'Popup';
|
|
||||||
private readonly container: HTMLElement = null;
|
private readonly container: HTMLElement = null;
|
||||||
private readonly node: HTMLElement = null;
|
private readonly node: HTMLElement = null;
|
||||||
private onClosing: () => unknown;
|
private onClosing: () => unknown;
|
||||||
@ -16,16 +17,23 @@ export default class Popup extends WuhuBase {
|
|||||||
* @param innerHTML
|
* @param innerHTML
|
||||||
* @param title
|
* @param title
|
||||||
* @param onClosing
|
* @param onClosing
|
||||||
|
* @param global
|
||||||
|
* @param logger
|
||||||
*/
|
*/
|
||||||
constructor(innerHTML: string, title: string = '芜湖助手', onClosing: () => unknown = () => {
|
constructor(
|
||||||
}) {
|
innerHTML: string,
|
||||||
super();
|
title: string = '芜湖助手',
|
||||||
|
onClosing: () => unknown = () => {
|
||||||
|
},
|
||||||
|
private readonly global: Global = Container.factory(Global),
|
||||||
|
private readonly logger: Logger = Container.factory(Logger),
|
||||||
|
) {
|
||||||
this.onClosing = onClosing;
|
this.onClosing = onClosing;
|
||||||
if (Popup.glob.popup_node) {
|
if (globVars.popup_node) {
|
||||||
Log.info('关闭前一个弹窗');
|
this.logger.info('关闭前一个弹窗');
|
||||||
Popup.glob.popup_node.close();
|
globVars.popup_node.close();
|
||||||
}
|
}
|
||||||
Log.info('新建弹窗', { innerHTML, title });
|
this.logger.info('新建弹窗', { innerHTML, title });
|
||||||
const popup = document.createElement('div');
|
const popup = document.createElement('div');
|
||||||
popup.id = 'wh-popup';
|
popup.id = 'wh-popup';
|
||||||
popup.innerHTML = POPUP_HTML.replace('{{}}', title).replace('{{}}', innerHTML);
|
popup.innerHTML = POPUP_HTML.replace('{{}}', title).replace('{{}}', innerHTML);
|
||||||
@ -37,7 +45,7 @@ export default class Popup extends WuhuBase {
|
|||||||
this.container = popup;
|
this.container = popup;
|
||||||
this.node = popup.querySelector('#wh-popup-cont');
|
this.node = popup.querySelector('#wh-popup-cont');
|
||||||
this.hideChat();
|
this.hideChat();
|
||||||
Popup.glob.popup_node = this;
|
globVars.popup_node = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public close() {
|
public close() {
|
||||||
@ -53,6 +61,7 @@ export default class Popup extends WuhuBase {
|
|||||||
/**
|
/**
|
||||||
* @return {HTMLElement} id=wh-popup-cont
|
* @return {HTMLElement} id=wh-popup-cont
|
||||||
* @deprecated
|
* @deprecated
|
||||||
|
* 使用element替代
|
||||||
*/
|
*/
|
||||||
public getElement(): HTMLElement {
|
public getElement(): HTMLElement {
|
||||||
return this.node;
|
return this.node;
|
||||||
|
|||||||
16
src/ts/class/utils/TornPDAUtils.ts
Normal file
16
src/ts/class/utils/TornPDAUtils.ts
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
import ClassName from "../../container/ClassName";
|
||||||
|
import { Injectable } from "../../container/Injectable";
|
||||||
|
|
||||||
|
@ClassName('TornPDAUtils')
|
||||||
|
@Injectable()
|
||||||
|
export default class TornPDAUtils {
|
||||||
|
private readonly _APIKey: string = '###PDA-APIKEY###';
|
||||||
|
|
||||||
|
public get APIKey(): string {
|
||||||
|
return this._APIKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public isPDA(): boolean {
|
||||||
|
return !this._APIKey.startsWith('#');
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,12 +1,16 @@
|
|||||||
import Log from "../Log";
|
import Log from "../Log";
|
||||||
import MathUtils from "./MathUtils";
|
import MathUtils from "./MathUtils";
|
||||||
|
import { Container } from "../../container/Container";
|
||||||
|
|
||||||
export default class TornStyleBlock {
|
export default class TornStyleBlock {
|
||||||
private readonly baseElement: HTMLElement;
|
private readonly baseElement: HTMLElement;
|
||||||
private readonly headElement: HTMLElement;
|
private readonly headElement: HTMLElement;
|
||||||
private readonly elem: HTMLElement;
|
private readonly elem: HTMLElement;
|
||||||
|
|
||||||
public constructor(title: string) {
|
public constructor(
|
||||||
|
private readonly title: string,
|
||||||
|
private readonly mathUtils: MathUtils = Container.factory(MathUtils),
|
||||||
|
) {
|
||||||
this.baseElement = document.createElement('div');
|
this.baseElement = document.createElement('div');
|
||||||
this.headElement = document.createElement('div');
|
this.headElement = document.createElement('div');
|
||||||
this.elem = document.createElement('div');
|
this.elem = document.createElement('div');
|
||||||
@ -19,7 +23,7 @@ export default class TornStyleBlock {
|
|||||||
// hr.classList.add('delimiter-999', 'm-top10', 'm-bottom10');
|
// hr.classList.add('delimiter-999', 'm-top10', 'm-bottom10');
|
||||||
|
|
||||||
this.baseElement.append(this.headElement, this.elem);
|
this.baseElement.append(this.headElement, this.elem);
|
||||||
this.baseElement.id = 'WHTornStyleBlock' + MathUtils.getInstance().getRandomInt(0, 100);
|
this.baseElement.id = 'WHTornStyleBlock' + mathUtils.getRandomInt(0, 100);
|
||||||
this.baseElement.insertAdjacentHTML('beforeend', '<hr class="delimiter-999 m-top10 m-bottom10" />');
|
this.baseElement.insertAdjacentHTML('beforeend', '<hr class="delimiter-999 m-top10 m-bottom10" />');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,12 +1,17 @@
|
|||||||
import MathUtils from "./MathUtils";
|
import MathUtils from "./MathUtils";
|
||||||
|
import { Container } from "../../container/Container";
|
||||||
|
|
||||||
export default class TornStyleSwitch {
|
export default class TornStyleSwitch {
|
||||||
private readonly baseElement;
|
private readonly baseElement;
|
||||||
private readonly randomId;
|
private readonly randomId;
|
||||||
private readonly input;
|
private readonly input;
|
||||||
|
|
||||||
constructor(label: string, checked: boolean = false) {
|
constructor(
|
||||||
this.randomId = MathUtils.getInstance().getRandomInt(100, 2000);
|
private readonly label: string,
|
||||||
|
private readonly checked: boolean = false,
|
||||||
|
private readonly mathUtils: MathUtils = Container.factory(MathUtils),
|
||||||
|
) {
|
||||||
|
this.randomId = mathUtils.getRandomInt(100, 2000);
|
||||||
this.baseElement = document.createElement('span');
|
this.baseElement = document.createElement('span');
|
||||||
this.baseElement.id = 'WHSwitch' + this.randomId;
|
this.baseElement.id = 'WHSwitch' + this.randomId;
|
||||||
this.baseElement.innerHTML = `<input class="checkbox-css" type="checkbox" id="WHCheck${ this.randomId }" ${ checked ? 'checked' : '' }/>
|
this.baseElement.innerHTML = `<input class="checkbox-css" type="checkbox" id="WHCheck${ this.randomId }" ${ checked ? 'checked' : '' }/>
|
||||||
|
|||||||
@ -1,10 +1,7 @@
|
|||||||
import WuhuBase from "../WuhuBase";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 收集数据上传
|
* 收集数据上传
|
||||||
*/
|
*/
|
||||||
export default class Uploader extends WuhuBase {
|
export default class Uploader {
|
||||||
className = "Uploader";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 上传数据
|
* 上传数据
|
||||||
@ -12,7 +9,8 @@ export default class Uploader extends WuhuBase {
|
|||||||
* @param uname 玩家昵称 可选
|
* @param uname 玩家昵称 可选
|
||||||
* @param meta_data 上传数据json格式
|
* @param meta_data 上传数据json格式
|
||||||
*/
|
*/
|
||||||
upload(uid:string, uname:string, meta_data:string) {}
|
upload(uid: string, uname: string, meta_data: string) {
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取服务端的数据
|
* 获取服务端的数据
|
||||||
|
|||||||
@ -1,9 +1,8 @@
|
|||||||
/**
|
|
||||||
* 记录类名、避免打包后丢失原类名
|
|
||||||
*/
|
|
||||||
|
|
||||||
const CLASSNAME_METADATA_KEY = Symbol("CLASSNAME_KEY");
|
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.name, target);
|
||||||
|
|||||||
@ -2,27 +2,27 @@ import { assertInjectable } from "./Injectable";
|
|||||||
import { GetClassName } from "./ClassName";
|
import { GetClassName } from "./ClassName";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 一个简单的类注入容器
|
* 一个简单的类容器
|
||||||
*/
|
*/
|
||||||
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(k: any, v: any): void {
|
||||||
if (Container._container.has(k)) {
|
if (!this._container.has(k)) {
|
||||||
Container._container.set(k, v);
|
this._container.set(k, v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static get(k: any): any {
|
static get(k: any): any {
|
||||||
return Container._container.get(k);
|
return this._container.get(k);
|
||||||
}
|
}
|
||||||
|
|
||||||
static factory<T>(target: Constructor<T>): T {
|
static factory<T>(target: Constructor<T>): T {
|
||||||
assertInjectable(target);
|
assertInjectable(target);
|
||||||
if (Container.get(target))
|
// if (Container.get(target))
|
||||||
return Container.get(target);
|
// return Container.get(target);
|
||||||
return Container.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: { info(...o: any[]), error(...o: any[]), warn(...o: any[]) }): void {
|
||||||
@ -32,22 +32,17 @@ export class Container {
|
|||||||
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) => {
|
||||||
assertInjectable(provider);
|
return this.factory(provider);
|
||||||
let inject;
|
|
||||||
if (Container.get(provider)) {
|
|
||||||
inject = Container.get(provider)
|
|
||||||
} else {
|
|
||||||
inject = Container.initParam(provider);
|
|
||||||
Container.set(provider, inject)
|
|
||||||
}
|
|
||||||
return inject;
|
|
||||||
}) : [];
|
}) : [];
|
||||||
let _target = new target(...args);
|
let _target = new target(...args);
|
||||||
this.logger?.info(
|
this.logger?.info(
|
||||||
`[${ GetClassName(target) || target.name }] 实例化`
|
`[${ GetClassName(target) || target.name }] 实例化`
|
||||||
);
|
);
|
||||||
Container.set(target, _target);
|
this.set(target, _target);
|
||||||
return _target;
|
return _target;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,7 +18,7 @@ export function Injectable(injectMode: INJECT_MODE = INJECT_MODE.Singleton): Cla
|
|||||||
export function assertInjectable(target: any) {
|
export function assertInjectable(target: any) {
|
||||||
if (!Reflect.getMetadata(INJECTABLE_METADATA_KEY, target)) {
|
if (!Reflect.getMetadata(INJECTABLE_METADATA_KEY, target)) {
|
||||||
throw new TypeError(
|
throw new TypeError(
|
||||||
`[${ GetClassName(target) || target.constructor?.name || target.name }] not injectable`
|
`[${ GetClassName(target) || target.name }] not injectable`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1002,7 +1002,7 @@ export const awDict = {
|
|||||||
'This upgrade will give you a 5% boost in money that you mug from opponents. Perfect for experienced muggers, looking for some extra cash.':
|
'This upgrade will give you a 5% boost in money that you mug from opponents. Perfect for experienced muggers, looking for some extra cash.':
|
||||||
'这个升级将使你从对手那里抢来的钱增加5%。非常适合有经验的抢劫者,赚些额外的钱钱。',
|
'这个升级将使你从对手那里抢来的钱增加5%。非常适合有经验的抢劫者,赚些额外的钱钱。',
|
||||||
"This upgrade will make you more likely to stay stealthed when beating an opponent by increasing your stealth level by 0.2 per increment. When you're stealthed, your name will be listed as 'Someone' so your enemy will not know who hit them.":
|
"This upgrade will make you more likely to stay stealthed when beating an opponent by increasing your stealth level by 0.2 per increment. When you're stealthed, your name will be listed as 'Someone' so your enemy will not know who hit them.":
|
||||||
'这个升级将提升 0.2 隐身级别,使你在击败对手时更有可能保持隐身状态。当你处于隐身状态时,你的名字将被列为“某人”,所以你的敌人不会知道是谁攻击了他们。',
|
'这个升级将提升 0.2 隐身级别,使你在击败对手时更有可能保持隐身状态。当你处于隐身状态时,你的名字将被列为「某人」,所以你的敌人不会知道是谁攻击了他们。',
|
||||||
"This upgrade will increase the amount of time you hospitalize someone by 5%. Make sure they feel the burn with 50% extra hospital time when fully upgraded.":
|
"This upgrade will increase the amount of time you hospitalize someone by 5%. Make sure they feel the burn with 50% extra hospital time when fully upgraded.":
|
||||||
'这项升级将使你增加 5% 被强制住院玩家的住院时间。完全升级后,确保他们感受到50%的额外住院时间。',
|
'这项升级将使你增加 5% 被强制住院玩家的住院时间。完全升级后,确保他们感受到50%的额外住院时间。',
|
||||||
"This upgrade will reduce the negative effects addiction causes towards your battle stats, employee effectiveness, and education / gym access.":
|
"This upgrade will reduce the negative effects addiction causes towards your battle stats, employee effectiveness, and education / gym access.":
|
||||||
@ -1185,7 +1185,7 @@ export const profileDict = {
|
|||||||
}
|
}
|
||||||
export const sendCashDict = {
|
export const sendCashDict = {
|
||||||
'Some players may be out to part you from your money, using any means necessary. Use the secure trade feature if you want to protect an exchange and check the contents very carefully.':
|
'Some players may be out to part you from your money, using any means necessary. Use the secure trade feature if you want to protect an exchange and check the contents very carefully.':
|
||||||
'有些玩家可能会利用任何必要的手段来骗走你的钱。如果你想保护交易,请使用更安全的“交易”功能,并仔细检查交易的内容。',
|
'有些玩家可能会利用任何必要的手段来骗走你的钱。如果你想保护交易,请使用更安全的「交易」功能,并仔细检查交易的内容。',
|
||||||
'Do not fall for scams!': '切勿上当受骗!',
|
'Do not fall for scams!': '切勿上当受骗!',
|
||||||
'For more info please visit here.': '欲了解更多信息,请点击访问。',
|
'For more info please visit here.': '欲了解更多信息,请点击访问。',
|
||||||
'SEND': '发送',
|
'SEND': '发送',
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
import WuhuConfig from "../../class/WuhuConfig";
|
|
||||||
import WT_HTML from "../../../static/html/xmasTown/wt.html";
|
import WT_HTML from "../../../static/html/xmasTown/wt.html";
|
||||||
import WT_XMAS_TOWN_HTML from "../../../static/html/xmasTown/wt_xmas_town.html";
|
import WT_XMAS_TOWN_HTML from "../../../static/html/xmasTown/wt_xmas_town.html";
|
||||||
import WT_MALTESE_SNOW_GLOBE_HTML from "../../../static/html/xmasTown/wt_maltese_snow_globe.html";
|
import WT_MALTESE_SNOW_GLOBE_HTML from "../../../static/html/xmasTown/wt_maltese_snow_globe.html";
|
||||||
@ -13,10 +12,15 @@ import WT_DOGGOQUEST_HTML from "../../../static/html/xmasTown/wt_doggoQuest.html
|
|||||||
import WT_POKEMON_CT_HTML from "../../../static/html/xmasTown/wt_pokemon_ct.html";
|
import WT_POKEMON_CT_HTML from "../../../static/html/xmasTown/wt_pokemon_ct.html";
|
||||||
import WT_WINTER_IN_GATLIN_HTML from "../../../static/html/xmasTown/wt_winter_in_gatlin.html";
|
import WT_WINTER_IN_GATLIN_HTML from "../../../static/html/xmasTown/wt_winter_in_gatlin.html";
|
||||||
import XMAS_TOWN_NOTIFY_HTML from "../../../static/html/xmasTown/xmas_town_notify.html";
|
import XMAS_TOWN_NOTIFY_HTML from "../../../static/html/xmasTown/xmas_town_notify.html";
|
||||||
|
import { Container } from "../../container/Container";
|
||||||
|
import LocalConfigWrapper from "../../class/LocalConfigWrapper";
|
||||||
|
|
||||||
export default function christmasTownHelper() {
|
export default function christmasTownHelper() {
|
||||||
|
const localConfigWrapper = Container.factory(LocalConfigWrapper);
|
||||||
|
|
||||||
let $root = document.querySelector('#christmastownroot');
|
let $root = document.querySelector('#christmastownroot');
|
||||||
const [xmasTownWT, xmasTownNotify] = WuhuConfig.get(['xmasTownWT', 'xmasTownNotify']);
|
const xmasTownWT = localConfigWrapper.config.xmasTownWT;
|
||||||
|
const xmasTownNotify = localConfigWrapper.config.xmasTownNotify;
|
||||||
// 解密攻略
|
// 解密攻略
|
||||||
if (xmasTownWT) {
|
if (xmasTownWT) {
|
||||||
const insert_html = WT_HTML;
|
const insert_html = WT_HTML;
|
||||||
|
|||||||
@ -3,6 +3,7 @@ import CommonUtils from "../../class/utils/CommonUtils";
|
|||||||
import CITY_FINDER_CSS from "../../../static/css/city_finder.css";
|
import CITY_FINDER_CSS from "../../../static/css/city_finder.css";
|
||||||
import TornStyleBlock from "../../class/utils/TornStyleBlock";
|
import TornStyleBlock from "../../class/utils/TornStyleBlock";
|
||||||
import ItemHelper from "../../class/utils/ItemHelper";
|
import ItemHelper from "../../class/utils/ItemHelper";
|
||||||
|
import { Container } from "../../container/Container";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 2023-02-22 修改物品价格查询逻辑,缓存优先
|
* 2023-02-22 修改物品价格查询逻辑,缓存优先
|
||||||
@ -39,7 +40,7 @@ export default function cityFinder(_base: TornStyleBlock): void {
|
|||||||
// Log.error(err);
|
// Log.error(err);
|
||||||
// items = undefined
|
// items = undefined
|
||||||
// });
|
// });
|
||||||
let itemHelper = ItemHelper.getInstance();
|
let itemHelper = Container.factory(ItemHelper);
|
||||||
CommonUtils.elementReady('div.leaflet-marker-pane').then(elem => {
|
CommonUtils.elementReady('div.leaflet-marker-pane').then(elem => {
|
||||||
// document.querySelector('.content-wrapper').prepend(base);
|
// document.querySelector('.content-wrapper').prepend(base);
|
||||||
|
|
||||||
|
|||||||
@ -1,23 +1,26 @@
|
|||||||
import WuhuBase from "../../class/WuhuBase";
|
|
||||||
import CommonUtils from "../../class/utils/CommonUtils";
|
import CommonUtils from "../../class/utils/CommonUtils";
|
||||||
import Log from "../../class/Log";
|
import Log from "../../class/Log";
|
||||||
import Alert from "../../class/utils/Alert";
|
import Alert from "../../class/utils/Alert";
|
||||||
import ActionButtonUtils from "../../class/utils/ActionButtonUtils";
|
import ActionButtonUtils from "../../class/utils/ActionButtonUtils";
|
||||||
import WuhuConfig from "../../class/WuhuConfig";
|
|
||||||
import FetchUtils from "../../class/utils/FetchUtils";
|
import FetchUtils from "../../class/utils/FetchUtils";
|
||||||
import DEPO_CSS from "../../../static/css/depo.css";
|
import DEPO_CSS from "../../../static/css/depo.css";
|
||||||
import TornStyleBlock from "../../class/utils/TornStyleBlock";
|
import TornStyleBlock from "../../class/utils/TornStyleBlock";
|
||||||
|
import { Container } from "../../container/Container";
|
||||||
|
import LocalConfigWrapper from "../../class/LocalConfigWrapper";
|
||||||
|
|
||||||
|
const fetchUtils = Container.factory(FetchUtils);
|
||||||
|
|
||||||
export default function depoHelper() {
|
export default function depoHelper() {
|
||||||
let actionButtonUtils: ActionButtonUtils = ActionButtonUtils.getInstance();
|
let actionButtonUtils: ActionButtonUtils = Container.factory(ActionButtonUtils);
|
||||||
let { href } = WuhuBase.glob;
|
let localConfigWrapper: LocalConfigWrapper = Container.factory(LocalConfigWrapper);
|
||||||
|
let href = window.location.href;
|
||||||
let channel: 'CMPY' | 'FAC';
|
let channel: 'CMPY' | 'FAC';
|
||||||
const selector = { 'CMPY': "div#funds div.deposit", 'FAC': "div#armoury-donate div.cash" };
|
const selector = { 'CMPY': "div#funds div.deposit", 'FAC': "div#armoury-donate div.cash" };
|
||||||
// 公司
|
// 公司
|
||||||
if (href.includes('companies.php')) {
|
if (href.includes('companies.php')) {
|
||||||
channel = "CMPY";
|
channel = "CMPY";
|
||||||
// 公司转跳存钱
|
// 公司转跳存钱
|
||||||
if (!href.includes('funds') && WuhuConfig.get('companyRedirect')) {
|
if (!href.includes('funds') && localConfigWrapper.config.companyRedirect) {
|
||||||
const btn = document.getElementById('ui-id-9');
|
const btn = document.getElementById('ui-id-9');
|
||||||
if (btn) {
|
if (btn) {
|
||||||
btn.click();
|
btn.click();
|
||||||
@ -25,7 +28,7 @@ export default function depoHelper() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 收起冰蛙表格
|
// 收起冰蛙表格
|
||||||
if (WuhuConfig.get('companyBWCollapse')) {
|
if (localConfigWrapper.config.companyBWCollapse) {
|
||||||
CommonUtils.elementReady('#effectiveness-wrap').then(BWTable_node => {
|
CommonUtils.elementReady('#effectiveness-wrap').then(BWTable_node => {
|
||||||
document.body.classList.add('wh-bwtable-ctrl');
|
document.body.classList.add('wh-bwtable-ctrl');
|
||||||
CommonUtils.addStyle(`.wh-bwtable-ctrl #effectiveness-wrap {display:none !important;}`);
|
CommonUtils.addStyle(`.wh-bwtable-ctrl #effectiveness-wrap {display:none !important;}`);
|
||||||
@ -48,7 +51,7 @@ export default function depoHelper() {
|
|||||||
actionButtonUtils.add('一键存钱', factionDeposit);
|
actionButtonUtils.add('一键存钱', factionDeposit);
|
||||||
}
|
}
|
||||||
// 存钱框浮动
|
// 存钱框浮动
|
||||||
if (WuhuConfig.get('floatDepo') && channel) {
|
if (localConfigWrapper.config.floatDepo && channel) {
|
||||||
document.body.classList.add('wh-depo-helper');
|
document.body.classList.add('wh-depo-helper');
|
||||||
CommonUtils.addStyle(DEPO_CSS);
|
CommonUtils.addStyle(DEPO_CSS);
|
||||||
CommonUtils.elementReady(selector[channel]).then(node => {
|
CommonUtils.elementReady(selector[channel]).then(node => {
|
||||||
@ -89,7 +92,7 @@ export default function depoHelper() {
|
|||||||
let getTraceMoney = async () => {
|
let getTraceMoney = async () => {
|
||||||
if (typeof addRFC === 'function') {
|
if (typeof addRFC === 'function') {
|
||||||
let url = addRFC('/trade.php?step=getFullMoney&ID=' + traceId);
|
let url = addRFC('/trade.php?step=getFullMoney&ID=' + traceId);
|
||||||
return (await FetchUtils.getInstance().ajaxFetch({
|
return (await fetchUtils.ajaxFetch({
|
||||||
url: url,
|
url: url,
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
referrer: 'trade.php'
|
referrer: 'trade.php'
|
||||||
@ -152,7 +155,7 @@ export default function depoHelper() {
|
|||||||
new Alert('无法定额取钱,原因:数不对');
|
new Alert('无法定额取钱,原因:数不对');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await FetchUtils.getInstance().ajaxFetch({
|
await fetchUtils.ajaxFetch({
|
||||||
url: addRFC('/trade.php'),
|
url: addRFC('/trade.php'),
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
referrer: 'trade.php',
|
referrer: 'trade.php',
|
||||||
@ -164,7 +167,7 @@ export default function depoHelper() {
|
|||||||
buttonDepositAll.addEventListener('click', async () => {
|
buttonDepositAll.addEventListener('click', async () => {
|
||||||
let money = await getTraceMoney();
|
let money = await getTraceMoney();
|
||||||
if (money === '0') return;
|
if (money === '0') return;
|
||||||
await FetchUtils.getInstance().ajaxFetch({
|
await fetchUtils.ajaxFetch({
|
||||||
url: addRFC('/trade.php'),
|
url: addRFC('/trade.php'),
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
referrer: 'trade.php',
|
referrer: 'trade.php',
|
||||||
@ -174,7 +177,7 @@ export default function depoHelper() {
|
|||||||
});
|
});
|
||||||
// 全取
|
// 全取
|
||||||
buttonWithdrawAll.addEventListener('click', async () => {
|
buttonWithdrawAll.addEventListener('click', async () => {
|
||||||
await FetchUtils.getInstance().ajaxFetch({
|
await fetchUtils.ajaxFetch({
|
||||||
url: addRFC('/trade.php'),
|
url: addRFC('/trade.php'),
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
referrer: 'trade.php',
|
referrer: 'trade.php',
|
||||||
@ -199,14 +202,14 @@ export default function depoHelper() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 任何位置公司一键存钱
|
// 任何位置公司一键存钱
|
||||||
if (WuhuConfig.get('companyDepositAnywhere')) {
|
if (localConfigWrapper.config.companyDepositAnywhere) {
|
||||||
actionButtonUtils.add('公司存钱', companyDepositAnywhere);
|
actionButtonUtils.add('公司存钱', () => companyDepositAnywhere());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 公司一键存钱
|
// 公司一键存钱
|
||||||
async function companyDeposit() {
|
async function companyDeposit() {
|
||||||
let fetchUtils: FetchUtils = FetchUtils.getInstance();
|
// let fetchUtils: FetchUtils = FetchUtils.getInstance();
|
||||||
if (!location.href.contains('option=funds')) {
|
if (!location.href.contains('option=funds')) {
|
||||||
new Alert('请先打开公司金库');
|
new Alert('请先打开公司金库');
|
||||||
return;
|
return;
|
||||||
@ -228,7 +231,7 @@ async function companyDeposit() {
|
|||||||
|
|
||||||
// 帮派一键存钱
|
// 帮派一键存钱
|
||||||
async function factionDeposit() {
|
async function factionDeposit() {
|
||||||
let fetchUtils: FetchUtils = FetchUtils.getInstance();
|
// let fetchUtils: FetchUtils = FetchUtils.getInstance();
|
||||||
let form = document.querySelector('#armoury-donate form');
|
let form = document.querySelector('#armoury-donate form');
|
||||||
if (!location.hash.includes('tab=armoury') || !form) {
|
if (!location.hash.includes('tab=armoury') || !form) {
|
||||||
new Alert('请先打开金库');
|
new Alert('请先打开金库');
|
||||||
@ -258,7 +261,7 @@ async function factionDeposit() {
|
|||||||
|
|
||||||
// 所有页面公司一键存钱
|
// 所有页面公司一键存钱
|
||||||
async function companyDepositAnywhere() {
|
async function companyDepositAnywhere() {
|
||||||
let fetchUtils: FetchUtils = FetchUtils.getInstance();
|
// let fetchUtils: FetchUtils = FetchUtils.getInstance();
|
||||||
let { addRFC } = window;
|
let { addRFC } = window;
|
||||||
if (typeof addRFC !== 'function') return;
|
if (typeof addRFC !== 'function') return;
|
||||||
let url = addRFC('https://www.torn.com/inputMoneyAction.php?step=generalAction');
|
let url = addRFC('https://www.torn.com/inputMoneyAction.php?step=generalAction');
|
||||||
|
|||||||
@ -1,8 +1,12 @@
|
|||||||
import WuhuConfig from "../../class/WuhuConfig";
|
import WuhuConfig from "../../class/WuhuConfig";
|
||||||
import Popup from "../../class/utils/Popup";
|
import Popup from "../../class/utils/Popup";
|
||||||
|
import LocalConfigWrapper from "../../class/LocalConfigWrapper";
|
||||||
|
import { Container } from "../../container/Container";
|
||||||
|
|
||||||
// 落地转跳设置
|
// 落地转跳设置
|
||||||
export default function landedRedirect() {
|
export default function landedRedirect() {
|
||||||
|
let localConfigWrapper: LocalConfigWrapper = Container.factory(LocalConfigWrapper);
|
||||||
|
|
||||||
let p = document.createElement('p');
|
let p = document.createElement('p');
|
||||||
let input = document.createElement('input');
|
let input = document.createElement('input');
|
||||||
let buttonSave = document.createElement('button');
|
let buttonSave = document.createElement('button');
|
||||||
@ -13,7 +17,7 @@ export default function landedRedirect() {
|
|||||||
|
|
||||||
p.innerHTML = '飞机落地后转跳的页面,关闭功能请置空:';
|
p.innerHTML = '飞机落地后转跳的页面,关闭功能请置空:';
|
||||||
input.placeholder = 'URL';
|
input.placeholder = 'URL';
|
||||||
input.value = WuhuConfig.get('landedRedirect') || '';
|
input.value = localConfigWrapper.config.landedRedirect ?? '';
|
||||||
input.style.display = 'block';
|
input.style.display = 'block';
|
||||||
input.style.textAlign = 'left';
|
input.style.textAlign = 'left';
|
||||||
input.style.width = '100%';
|
input.style.width = '100%';
|
||||||
|
|||||||
@ -1,11 +1,12 @@
|
|||||||
import UserScriptEngine from "../../enum/UserScriptEngine";
|
import UserScriptEngine from "../../enum/UserScriptEngine";
|
||||||
import addStyle from "../utils/@deprecated/addStyle";
|
|
||||||
import log from "../utils/@deprecated/log";
|
|
||||||
import CommonUtils from "../../class/utils/CommonUtils";
|
import CommonUtils from "../../class/utils/CommonUtils";
|
||||||
import Alert from "../../class/utils/Alert";
|
import Alert from "../../class/utils/Alert";
|
||||||
|
import { Container } from "../../container/Container";
|
||||||
|
import Logger from "../../class/Logger";
|
||||||
|
|
||||||
// gs loader
|
// gs loader
|
||||||
export default function loadGS(use) {
|
export default function loadGS(use) {
|
||||||
|
let logger = Container.factory(Logger);
|
||||||
if (use === UserScriptEngine.PDA) {
|
if (use === UserScriptEngine.PDA) {
|
||||||
let ifr: HTMLIFrameElement = document.querySelector('#wh-gs-loader-ifr');
|
let ifr: HTMLIFrameElement = document.querySelector('#wh-gs-loader-ifr');
|
||||||
if (ifr) {
|
if (ifr) {
|
||||||
@ -19,7 +20,7 @@ export default function loadGS(use) {
|
|||||||
ifr.src = 'https://www.torn.com/crimes.php';
|
ifr.src = 'https://www.torn.com/crimes.php';
|
||||||
container.append(ifr);
|
container.append(ifr);
|
||||||
document.body.append(container);
|
document.body.append(container);
|
||||||
addStyle(`
|
CommonUtils.addStyle(`
|
||||||
#wh-gs-loader {
|
#wh-gs-loader {
|
||||||
position:fixed;
|
position:fixed;
|
||||||
top:0;
|
top:0;
|
||||||
@ -75,7 +76,7 @@ z-index:100001;
|
|||||||
};
|
};
|
||||||
new MutationObserver(thisRun).observe(gsp, { childList: true, subtree: true });
|
new MutationObserver(thisRun).observe(gsp, { childList: true, subtree: true });
|
||||||
thisRun();
|
thisRun();
|
||||||
if (log.debug()) _window.GM_setValue("gsp_showContent", true)
|
if (logger.debug()) _window.GM_setValue("gsp_showContent", true)
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@ -103,7 +104,7 @@ z-index:100001;
|
|||||||
CommonUtils.COFetch(`https://gitee.com/ameto_kasao/tornjs/raw/master/GoldenSnitch.js?${ performance.now() }`)
|
CommonUtils.COFetch(`https://gitee.com/ameto_kasao/tornjs/raw/master/GoldenSnitch.js?${ performance.now() }`)
|
||||||
.then(GSJS => {
|
.then(GSJS => {
|
||||||
window.eval(GSJS);
|
window.eval(GSJS);
|
||||||
if (log.debug()) window.GM_setValue("gsp_showContent", true);
|
if (logger.debug()) window.GM_setValue("gsp_showContent", true);
|
||||||
notify.close();
|
notify.close();
|
||||||
notify = new Alert('已载入飞贼助手');
|
notify = new Alert('已载入飞贼助手');
|
||||||
})
|
})
|
||||||
|
|||||||
@ -1,13 +1,16 @@
|
|||||||
import toThousands from "../utils/toThousands";
|
import toThousands from "../utils/toThousands";
|
||||||
import Log from "../../class/Log";
|
import Log from "../../class/Log";
|
||||||
import Alert from "../../class/utils/Alert";
|
import Alert from "../../class/utils/Alert";
|
||||||
import WuhuConfig from "../../class/WuhuConfig";
|
import LocalConfigWrapper from "../../class/LocalConfigWrapper";
|
||||||
|
import { Container } from "../../container/Container";
|
||||||
|
|
||||||
// 价格监视handle
|
// 价格监视handle
|
||||||
export default function priceWatcherHandle(isPDA: boolean, PDA_APIKey: string) {
|
export default function priceWatcherHandle(isPDA: boolean, PDA_APIKey: string) {
|
||||||
|
let localConfigWrapper: LocalConfigWrapper = Container.factory(LocalConfigWrapper);
|
||||||
|
|
||||||
let priceTemp = {};
|
let priceTemp = {};
|
||||||
let intervalId = window.setInterval(() => {
|
let intervalId = window.setInterval(() => {
|
||||||
const price_conf = WuhuConfig.get('priceWatcher');
|
const price_conf = localConfigWrapper.config.priceWatcher;
|
||||||
const apikey = isPDA ? PDA_APIKey : localStorage.getItem('APIKey');
|
const apikey = isPDA ? PDA_APIKey : localStorage.getItem('APIKey');
|
||||||
if (!apikey || (price_conf['pt'] === -1 && price_conf['xan'] === -1)) {
|
if (!apikey || (price_conf['pt'] === -1 && price_conf['xan'] === -1)) {
|
||||||
Log.warn('价格监视关闭,无apikey或设置未打开');
|
Log.warn('价格监视关闭,无apikey或设置未打开');
|
||||||
|
|||||||
@ -2,9 +2,12 @@ import Alert from "../../class/utils/Alert";
|
|||||||
import InfoUtils from "../../class/utils/InfoUtils";
|
import InfoUtils from "../../class/utils/InfoUtils";
|
||||||
import Log from "../../class/Log";
|
import Log from "../../class/Log";
|
||||||
import Popup from "../../class/utils/Popup";
|
import Popup from "../../class/utils/Popup";
|
||||||
|
import { Container } from "../../container/Container";
|
||||||
|
|
||||||
// 守望者
|
// 守望者
|
||||||
export default function safeKeeper() {
|
export default function safeKeeper() {
|
||||||
|
let infoUtils = Container.factory(InfoUtils);
|
||||||
|
|
||||||
let url = `https://www.torn.com/loader.php?sid=attackData&mode=json&step=poll&user2ID=`;
|
let url = `https://www.torn.com/loader.php?sid=attackData&mode=json&step=poll&user2ID=`;
|
||||||
let popup = new Popup('<p>监测目标ID玩家的防御状态,找出隐身攻击者</p>', '守望者 (测试中)');
|
let popup = new Popup('<p>监测目标ID玩家的防御状态,找出隐身攻击者</p>', '守望者 (测试中)');
|
||||||
let p = document.createElement('p');
|
let p = document.createElement('p');
|
||||||
@ -118,5 +121,5 @@ export default function safeKeeper() {
|
|||||||
loop_id = null;
|
loop_id = null;
|
||||||
p.innerHTML = '状态:已关 ❎';
|
p.innerHTML = '状态:已关 ❎';
|
||||||
});
|
});
|
||||||
self_target.addEventListener('click', () => uid.value = (InfoUtils.getInstance().getPlayerInfo()['userID']) + '');
|
self_target.addEventListener('click', () => uid.value = (infoUtils.getPlayerInfo()['userID']) + '');
|
||||||
}
|
}
|
||||||
@ -1,248 +1,334 @@
|
|||||||
import titleTrans from "../translate/titleTrans";
|
import titleTrans from "../translate/titleTrans";
|
||||||
import contentTitleLinksTrans from "../translate/contentTitleLinksTrans";
|
import contentTitleLinksTrans from "../translate/contentTitleLinksTrans";
|
||||||
import Device from "../../enum/Device";
|
import Device from "../../enum/Device";
|
||||||
import WuhuBase from "../../class/WuhuBase";
|
|
||||||
import Alert from "../../class/utils/Alert";
|
import Alert from "../../class/utils/Alert";
|
||||||
import ActionButtonUtils from "../../class/utils/ActionButtonUtils";
|
import ActionButtonUtils from "../../class/utils/ActionButtonUtils";
|
||||||
import WuhuConfig from "../../class/WuhuConfig";
|
|
||||||
import CommonUtils from "../../class/utils/CommonUtils";
|
import CommonUtils from "../../class/utils/CommonUtils";
|
||||||
import TRAVEL_ALARM_CSS from "../../../static/css/travel_alarm.css";
|
import TRAVEL_ALARM_CSS from "../../../static/css/travel_alarm.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 ClassName from "../../container/ClassName";
|
||||||
|
import { Injectable } from "../../container/Injectable";
|
||||||
|
import LocalConfigWrapper from "../../class/LocalConfigWrapper";
|
||||||
|
|
||||||
export default async function travelHelper(): Promise<void> {
|
// async function travelHelper(): Promise<void> {
|
||||||
let { href, bodyAttrs, device } = WuhuBase.glob;
|
// let global = Container.factory(Global);
|
||||||
|
// let commonUtils = Container.factory(CommonUtils);
|
||||||
|
// }
|
||||||
|
|
||||||
if (href.includes('index.php')) {
|
// async function travelBack(): Promise<null> {
|
||||||
switch (CommonUtils.getInstance().getTravelStage()) {
|
// if (typeof window['getAction'] !== 'function') return;
|
||||||
// 飞行中
|
// let backHomeAction = function (): Promise<string> {
|
||||||
case TRAVEL_STATE.FLYING: {
|
// return new Promise(resolve => {
|
||||||
// 飞行闹钟
|
// window.getAction({
|
||||||
if (device === Device.PC && WuhuConfig.get('trvAlarm')) {
|
// type: "post",
|
||||||
// 获取目的地
|
// action: 'travelagency.php',
|
||||||
let dest_cn;
|
// data: {
|
||||||
let country = document.body.getAttribute('data-country');
|
// step: 'backHomeAction'
|
||||||
if (country === 'torn') {
|
// },
|
||||||
dest_cn = '回城';
|
// success: function (msg) {
|
||||||
} else {
|
// resolve(msg);
|
||||||
dest_cn = {
|
// }
|
||||||
'uk': "英国",
|
// });
|
||||||
'switzerland': "瑞士",
|
// });
|
||||||
'mexico': '墨西哥',
|
// };
|
||||||
'canada': '加拿大',
|
// let res = await backHomeAction();
|
||||||
'cayman': '开曼',
|
// new Alert(res);
|
||||||
'hawaii': '夏威夷',
|
// if (!res.includes('error')) {
|
||||||
'argentina': '阿根廷',
|
// new Alert('成功,即将刷新');
|
||||||
'japan': '日本',
|
// window.setTimeout(() => location.reload(), 3000);
|
||||||
'china': '中国',
|
// } else {
|
||||||
'uae': 'UAE',
|
// new Alert('出错了');
|
||||||
'south-africa': '南非',
|
// }
|
||||||
}[country] || country;
|
// }
|
||||||
}
|
|
||||||
|
|
||||||
// 剩余时间
|
/**
|
||||||
const remaining_arr = document.querySelector('#countrTravel').getAttribute('data-to');
|
* 飞行助手
|
||||||
|
* - 飞行闹钟
|
||||||
|
* - 一键回城
|
||||||
|
* - 解毒提醒
|
||||||
|
* - 落地转跳
|
||||||
|
* - 海外警告
|
||||||
|
*/
|
||||||
|
@ClassName('TravelHelper')
|
||||||
|
@Injectable()
|
||||||
|
export default class TravelHelper {
|
||||||
|
constructor(
|
||||||
|
private readonly global: Global,
|
||||||
|
private readonly commonUtils: CommonUtils,
|
||||||
|
private readonly actionButtonUtils: ActionButtonUtils,
|
||||||
|
private readonly localConfigWrapper: LocalConfigWrapper,
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
const wh_trv_alarm = localStorage.getItem('wh_trv_alarm')
|
init() {
|
||||||
? JSON.parse(localStorage.getItem('wh_trv_alarm'))
|
let { bodyAttrs, device } = this.global;
|
||||||
: { 'enable': true, 'alert_time': 30, 'node_pos': [240, 240] };
|
let href = window.location.href;
|
||||||
const save_trv_settings = () => localStorage.setItem('wh_trv_alarm', JSON.stringify(wh_trv_alarm));
|
|
||||||
|
|
||||||
const wh_trv_alarm_node = document.createElement('div');
|
if (href.includes('index.php')) {
|
||||||
wh_trv_alarm_node.id = 'wh-trv-alarm';
|
switch (this.commonUtils.getTravelStage()) {
|
||||||
wh_trv_alarm_node.style.left = `${ wh_trv_alarm.node_pos[0] }px`;
|
// 飞行中
|
||||||
wh_trv_alarm_node.style.top = `${ wh_trv_alarm.node_pos[1] }px`;
|
case TRAVEL_STATE.FLYING: {
|
||||||
wh_trv_alarm_node.innerHTML = TRAVEL_ALARM_HTML
|
// 飞行闹钟
|
||||||
.replace('{{}}', dest_cn === '回城' ? dest_cn : '飞往' + dest_cn)
|
if (device === Device.PC && this.localConfigWrapper.config.trvAlarm) {
|
||||||
.replace('{{}}', wh_trv_alarm.enable ? 'checked ' : '')
|
// 获取目的地
|
||||||
.replace('{{}}', wh_trv_alarm.alert_time || 30);
|
let dest_cn;
|
||||||
CommonUtils.addStyle(TRAVEL_ALARM_CSS);
|
let country = document.body.getAttribute('data-country');
|
||||||
document.body.append(wh_trv_alarm_node);
|
if (country === 'torn') {
|
||||||
// 报错dom
|
dest_cn = '回城';
|
||||||
const error_node = wh_trv_alarm_node.querySelector('#wh-trv-error') as HTMLElement;
|
|
||||||
// jquery拖动
|
|
||||||
// @ts-ignore
|
|
||||||
$(wh_trv_alarm_node).draggable({
|
|
||||||
containment: "body",
|
|
||||||
distance: 5,
|
|
||||||
handle: "#wh-trv-alarm-title",
|
|
||||||
stop: () => {
|
|
||||||
wh_trv_alarm.node_pos = [parseInt(wh_trv_alarm_node.style.left), parseInt(wh_trv_alarm_node.style.top)];
|
|
||||||
save_trv_settings();
|
|
||||||
},
|
|
||||||
scroll: false,
|
|
||||||
});
|
|
||||||
// 剩余时间dom
|
|
||||||
const remaining_node = wh_trv_alarm_node.querySelector('#wh-trv-alarm-remaining');
|
|
||||||
// 设定闹钟响的按钮
|
|
||||||
const set_node = wh_trv_alarm_node.querySelectorAll('#wh-trv-alarm-cont button')[0] as HTMLButtonElement;
|
|
||||||
// 落地前响铃时长
|
|
||||||
const cd_time = wh_trv_alarm_node.querySelector('input[type="number"]') as HTMLInputElement;
|
|
||||||
let count_down_notify: MyHTMLElement | { close: Function } = {
|
|
||||||
close: () => {
|
|
||||||
}
|
|
||||||
};
|
|
||||||
set_node.onclick = () => {
|
|
||||||
try {
|
|
||||||
wh_trv_alarm.alert_time = parseInt(cd_time.value);
|
|
||||||
} catch {
|
|
||||||
wh_trv_alarm.alert_time = 30;
|
|
||||||
}
|
|
||||||
save_trv_settings();
|
|
||||||
set_node.value = wh_trv_alarm.alert_time;
|
|
||||||
count_down_notify.close();
|
|
||||||
count_down_notify = new Alert('设置已更新');
|
|
||||||
};
|
|
||||||
// 停止响铃按钮
|
|
||||||
const stop_node = wh_trv_alarm_node.querySelectorAll('#wh-trv-alarm-cont button')[1] as HTMLButtonElement;
|
|
||||||
stop_node.onclick = () => {
|
|
||||||
user_stop_alert = true;
|
|
||||||
stop_node.innerText = '本次已关闭';
|
|
||||||
stop_node.disabled = true;
|
|
||||||
}
|
|
||||||
// 开启闹钟勾选
|
|
||||||
const enable_node = wh_trv_alarm_node.querySelector('#wh-trv-alarm-cont input[type="checkbox"]') as HTMLInputElement;
|
|
||||||
let on_off_notify: MyHTMLElement | { close: Function } = {
|
|
||||||
close: () => {
|
|
||||||
}
|
|
||||||
};
|
|
||||||
enable_node.onchange = ev => {
|
|
||||||
wh_trv_alarm.enable = (<HTMLInputElement>ev.target).checked;
|
|
||||||
save_trv_settings();
|
|
||||||
on_off_notify.close();
|
|
||||||
on_off_notify = new Alert(wh_trv_alarm.enable ? '闹钟已开启' : '闹钟已关闭');
|
|
||||||
};
|
|
||||||
// 剩余时间 秒
|
|
||||||
const remaining_sec = parseInt(remaining_arr);
|
|
||||||
// 落地时timestamp
|
|
||||||
const land_timestamp = Date.now() + remaining_sec * 1000;
|
|
||||||
// 音频dom
|
|
||||||
const audio = document.createElement('audio');
|
|
||||||
audio.src = 'https://www.torn.com/js/chat/sounds/Warble_1.mp3';
|
|
||||||
audio.play()
|
|
||||||
.then(() => audio.pause())
|
|
||||||
.catch(() => {
|
|
||||||
error_node.style.display = 'table';
|
|
||||||
const func = () => {
|
|
||||||
error_node.remove();
|
|
||||||
document.body.removeEventListener('click', func);
|
|
||||||
};
|
|
||||||
document.body.addEventListener('click', func);
|
|
||||||
});
|
|
||||||
// 是否正在响铃
|
|
||||||
let audio_play_flag = false;
|
|
||||||
// 用户是否停止当前响铃
|
|
||||||
let user_stop_alert = false;
|
|
||||||
// 响铃循环id
|
|
||||||
let audio_play_id = null;
|
|
||||||
// 响铃的方法
|
|
||||||
let audio_play_handle = () => {
|
|
||||||
if (user_stop_alert) {
|
|
||||||
clearInterval(audio_play_id);
|
|
||||||
audio_play_id = null;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!audio_play_flag || !wh_trv_alarm.enable) return;
|
|
||||||
audio.play().then();
|
|
||||||
};
|
|
||||||
// 飞机小动画字符
|
|
||||||
const flying_arr = [
|
|
||||||
'✈ ',
|
|
||||||
' ✈ ',
|
|
||||||
' ✈ ',
|
|
||||||
' ✈ ',
|
|
||||||
' ✈ ',
|
|
||||||
' ✈ ',
|
|
||||||
' ✈ ',
|
|
||||||
' ✈ ',
|
|
||||||
' ✈ ',
|
|
||||||
' ✈ ',
|
|
||||||
];
|
|
||||||
// 飞行的状态dom
|
|
||||||
const flying_status = wh_trv_alarm_node.querySelector('#wh-trv-status');
|
|
||||||
// 飞机的小动画dom
|
|
||||||
const flying_ani = flying_status.nextElementSibling;
|
|
||||||
// 飞机的计数
|
|
||||||
let flying_index = 0;
|
|
||||||
const id = window.setInterval(() => {
|
|
||||||
const remaining_time = (land_timestamp - Date.now()) / 1000 | 0;
|
|
||||||
remaining_node.innerText = `${ remaining_time / 3600 | 0 }时${ remaining_time % 3600 / 60 | 0 }分${ remaining_time % 60 }秒`;
|
|
||||||
|
|
||||||
if (remaining_time < wh_trv_alarm.alert_time) {
|
|
||||||
// flying_status.innerHTML = `即将落地...`;
|
|
||||||
if (wh_trv_alarm.enable) {
|
|
||||||
// 播放提示音
|
|
||||||
audio_play_flag = true;
|
|
||||||
if (audio_play_id === null && !user_stop_alert) audio_play_id = window.setInterval(audio_play_handle, 750);
|
|
||||||
stop_node.parentElement.classList.remove('wh-trv-alarm-stop-hide');
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// flying_status.innerHTML = `飞行中...`;
|
dest_cn = {
|
||||||
if (wh_trv_alarm.enable) {
|
'uk': "英国",
|
||||||
|
'switzerland': "瑞士",
|
||||||
|
'mexico': '墨西哥',
|
||||||
|
'canada': '加拿大',
|
||||||
|
'cayman': '开曼',
|
||||||
|
'hawaii': '夏威夷',
|
||||||
|
'argentina': '阿根廷',
|
||||||
|
'japan': '日本',
|
||||||
|
'china': '中国',
|
||||||
|
'uae': 'UAE',
|
||||||
|
'south-africa': '南非',
|
||||||
|
}[country] || country;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 剩余时间
|
||||||
|
const remaining_arr = document.querySelector('#countrTravel').getAttribute('data-to');
|
||||||
|
|
||||||
|
const wh_trv_alarm = localStorage.getItem('wh_trv_alarm')
|
||||||
|
? JSON.parse(localStorage.getItem('wh_trv_alarm'))
|
||||||
|
: { 'enable': true, 'alert_time': 30, 'node_pos': [240, 240] };
|
||||||
|
const save_trv_settings = () => localStorage.setItem('wh_trv_alarm', JSON.stringify(wh_trv_alarm));
|
||||||
|
|
||||||
|
const wh_trv_alarm_node = document.createElement('div');
|
||||||
|
wh_trv_alarm_node.id = 'wh-trv-alarm';
|
||||||
|
wh_trv_alarm_node.style.left = `${ wh_trv_alarm.node_pos[0] }px`;
|
||||||
|
wh_trv_alarm_node.style.top = `${ wh_trv_alarm.node_pos[1] }px`;
|
||||||
|
wh_trv_alarm_node.innerHTML = TRAVEL_ALARM_HTML
|
||||||
|
.replace('{{}}', dest_cn === '回城' ? dest_cn : '飞往' + dest_cn)
|
||||||
|
.replace('{{}}', wh_trv_alarm.enable ? 'checked ' : '')
|
||||||
|
.replace('{{}}', wh_trv_alarm.alert_time || 30);
|
||||||
|
CommonUtils.addStyle(TRAVEL_ALARM_CSS);
|
||||||
|
document.body.append(wh_trv_alarm_node);
|
||||||
|
// 报错dom
|
||||||
|
const error_node = wh_trv_alarm_node.querySelector('#wh-trv-error') as HTMLElement;
|
||||||
|
// jquery拖动
|
||||||
|
// @ts-ignore
|
||||||
|
$(wh_trv_alarm_node).draggable({
|
||||||
|
containment: "body",
|
||||||
|
distance: 5,
|
||||||
|
handle: "#wh-trv-alarm-title",
|
||||||
|
stop: () => {
|
||||||
|
wh_trv_alarm.node_pos = [parseInt(wh_trv_alarm_node.style.left), parseInt(wh_trv_alarm_node.style.top)];
|
||||||
|
save_trv_settings();
|
||||||
|
},
|
||||||
|
scroll: false,
|
||||||
|
});
|
||||||
|
// 剩余时间dom
|
||||||
|
const remaining_node = wh_trv_alarm_node.querySelector('#wh-trv-alarm-remaining');
|
||||||
|
// 设定闹钟响的按钮
|
||||||
|
const set_node = wh_trv_alarm_node.querySelectorAll('#wh-trv-alarm-cont button')[0] as HTMLButtonElement;
|
||||||
|
// 落地前响铃时长
|
||||||
|
const cd_time = wh_trv_alarm_node.querySelector('input[type="number"]') as HTMLInputElement;
|
||||||
|
let count_down_notify: MyHTMLElement | { close: Function } = {
|
||||||
|
close: () => {
|
||||||
|
}
|
||||||
|
};
|
||||||
|
set_node.onclick = () => {
|
||||||
|
try {
|
||||||
|
wh_trv_alarm.alert_time = parseInt(cd_time.value);
|
||||||
|
} catch {
|
||||||
|
wh_trv_alarm.alert_time = 30;
|
||||||
|
}
|
||||||
|
save_trv_settings();
|
||||||
|
set_node.value = wh_trv_alarm.alert_time;
|
||||||
|
count_down_notify.close();
|
||||||
|
count_down_notify = new Alert('设置已更新');
|
||||||
|
};
|
||||||
|
// 停止响铃按钮
|
||||||
|
const stop_node = wh_trv_alarm_node.querySelectorAll('#wh-trv-alarm-cont button')[1] as HTMLButtonElement;
|
||||||
|
stop_node.onclick = () => {
|
||||||
|
user_stop_alert = true;
|
||||||
|
stop_node.innerText = '本次已关闭';
|
||||||
|
stop_node.disabled = true;
|
||||||
|
}
|
||||||
|
// 开启闹钟勾选
|
||||||
|
const enable_node = wh_trv_alarm_node.querySelector('#wh-trv-alarm-cont input[type="checkbox"]') as HTMLInputElement;
|
||||||
|
let on_off_notify: MyHTMLElement | { close: Function } = {
|
||||||
|
close: () => {
|
||||||
|
}
|
||||||
|
};
|
||||||
|
enable_node.onchange = ev => {
|
||||||
|
wh_trv_alarm.enable = (<HTMLInputElement>ev.target).checked;
|
||||||
|
save_trv_settings();
|
||||||
|
on_off_notify.close();
|
||||||
|
on_off_notify = new Alert(wh_trv_alarm.enable ? '闹钟已开启' : '闹钟已关闭');
|
||||||
|
};
|
||||||
|
// 剩余时间 秒
|
||||||
|
const remaining_sec = parseInt(remaining_arr);
|
||||||
|
// 落地时timestamp
|
||||||
|
const land_timestamp = Date.now() + remaining_sec * 1000;
|
||||||
|
// 音频dom
|
||||||
|
const audio = document.createElement('audio');
|
||||||
|
audio.src = 'https://www.torn.com/js/chat/sounds/Warble_1.mp3';
|
||||||
|
audio.play()
|
||||||
|
.then(() => audio.pause())
|
||||||
|
.catch(() => {
|
||||||
|
error_node.style.display = 'table';
|
||||||
|
const func = () => {
|
||||||
|
error_node.remove();
|
||||||
|
document.body.removeEventListener('click', func);
|
||||||
|
};
|
||||||
|
document.body.addEventListener('click', func);
|
||||||
|
});
|
||||||
|
// 是否正在响铃
|
||||||
|
let audio_play_flag = false;
|
||||||
|
// 用户是否停止当前响铃
|
||||||
|
let user_stop_alert = false;
|
||||||
|
// 响铃循环id
|
||||||
|
let audio_play_id = null;
|
||||||
|
// 响铃的方法
|
||||||
|
let audio_play_handle = () => {
|
||||||
|
if (user_stop_alert) {
|
||||||
clearInterval(audio_play_id);
|
clearInterval(audio_play_id);
|
||||||
audio_play_id = null;
|
audio_play_id = null;
|
||||||
stop_node.parentElement.classList.add('wh-trv-alarm-stop-hide');
|
return;
|
||||||
}
|
}
|
||||||
}
|
if (!audio_play_flag || !wh_trv_alarm.enable) return;
|
||||||
flying_ani.innerHTML = `${ flying_arr[flying_index] }`;
|
audio.play().then();
|
||||||
flying_index = (flying_index + 1) % flying_arr.length;
|
};
|
||||||
}, 1000);
|
// 飞机小动画字符
|
||||||
}
|
const flying_arr = [
|
||||||
|
'✈ ',
|
||||||
|
' ✈ ',
|
||||||
|
' ✈ ',
|
||||||
|
' ✈ ',
|
||||||
|
' ✈ ',
|
||||||
|
' ✈ ',
|
||||||
|
' ✈ ',
|
||||||
|
' ✈ ',
|
||||||
|
' ✈ ',
|
||||||
|
' ✈ ',
|
||||||
|
];
|
||||||
|
// 飞行的状态dom
|
||||||
|
const flying_status = wh_trv_alarm_node.querySelector('#wh-trv-status');
|
||||||
|
// 飞机的小动画dom
|
||||||
|
const flying_ani = flying_status.nextElementSibling;
|
||||||
|
// 飞机的计数
|
||||||
|
let flying_index = 0;
|
||||||
|
const id = window.setInterval(() => {
|
||||||
|
const remaining_time = (land_timestamp - Date.now()) / 1000 | 0;
|
||||||
|
remaining_node.innerText = `${ remaining_time / 3600 | 0 }时${ remaining_time % 3600 / 60 | 0 }分${ remaining_time % 60 }秒`;
|
||||||
|
|
||||||
// 落地转跳 落地前事件
|
if (remaining_time < wh_trv_alarm.alert_time) {
|
||||||
if (WuhuConfig.get('landedRedirect') && document.querySelector('#tcLogo[title]') === null) {
|
// flying_status.innerHTML = `即将落地...`;
|
||||||
window.addEventListener('beforeunload', () => {
|
if (wh_trv_alarm.enable) {
|
||||||
let obj = { url: WuhuConfig.get('landedRedirect'), timestamp: Date.now() };
|
// 播放提示音
|
||||||
sessionStorage['wh-landed-redirect'] = JSON.stringify(obj);
|
audio_play_flag = true;
|
||||||
});
|
if (audio_play_id === null && !user_stop_alert) audio_play_id = window.setInterval(audio_play_handle, 750);
|
||||||
}
|
stop_node.parentElement.classList.remove('wh-trv-alarm-stop-hide');
|
||||||
break;
|
}
|
||||||
}
|
} else {
|
||||||
// 海外落地
|
// flying_status.innerHTML = `飞行中...`;
|
||||||
case TRAVEL_STATE.ABROAD: {
|
if (wh_trv_alarm.enable) {
|
||||||
// 一键回城
|
clearInterval(audio_play_id);
|
||||||
ActionButtonUtils.getInstance().add('直接回城', travelBack);
|
audio_play_id = null;
|
||||||
// 海外警告
|
stop_node.parentElement.classList.add('wh-trv-alarm-stop-hide');
|
||||||
if (WuhuConfig.get('abroadWarning')) {
|
}
|
||||||
let c = 1;
|
}
|
||||||
setInterval(() => new Alert(`警告:您已海外落地${ c++ * 30 }秒`, {
|
flying_ani.innerHTML = `${ flying_arr[flying_index] }`;
|
||||||
timeout: 30,
|
flying_index = (flying_index + 1) % flying_arr.length;
|
||||||
sysNotify: true
|
}, 1000);
|
||||||
}), 30000);
|
|
||||||
}
|
|
||||||
// 解毒提醒
|
|
||||||
if (bodyAttrs['data-country'] === 'switzerland') {
|
|
||||||
let block = new TornStyleBlock('解毒提醒');
|
|
||||||
block.setContent('<p><a href="/index.php?page=rehab">❤️ 点击前往解毒</a></p>');
|
|
||||||
document.querySelector('h4#skip-to-content').before(block.getBase());
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
// 主页界面
|
|
||||||
case TRAVEL_STATE.IN_TORN: {
|
|
||||||
// 落地转跳
|
|
||||||
if (sessionStorage['wh-landed-redirect']) {
|
|
||||||
let { url, timestamp } = JSON.parse(sessionStorage['wh-landed-redirect']);
|
|
||||||
if (Date.now() - timestamp < 30000) {
|
|
||||||
sessionStorage.removeItem('wh-landed-redirect');
|
|
||||||
location.href = url;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 落地转跳 落地前事件
|
||||||
|
if (this.localConfigWrapper.config.landedRedirect && document.querySelector('#tcLogo[title]') === null) {
|
||||||
|
window.addEventListener('beforeunload', () => {
|
||||||
|
let obj = { url: this.localConfigWrapper.config.landedRedirect, timestamp: Date.now() };
|
||||||
|
sessionStorage['wh-landed-redirect'] = JSON.stringify(obj);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// 海外落地
|
||||||
|
case TRAVEL_STATE.ABROAD: {
|
||||||
|
// 一键回城
|
||||||
|
this.actionButtonUtils.add('直接回城', () => this.doTravelBack());
|
||||||
|
// 海外警告
|
||||||
|
if (this.localConfigWrapper.config.abroadWarning) {
|
||||||
|
let c = 1;
|
||||||
|
setInterval(() => new Alert(`警告:您已海外落地${ c++ * 30 }秒`, {
|
||||||
|
timeout: 30,
|
||||||
|
sysNotify: true
|
||||||
|
}), 30000);
|
||||||
|
}
|
||||||
|
// 解毒提醒
|
||||||
|
if (bodyAttrs['data-country'] === 'switzerland') {
|
||||||
|
let block = new TornStyleBlock('解毒提醒');
|
||||||
|
block.setContent('<p><a href="/index.php?page=rehab">❤️ 点击前往解毒</a></p>');
|
||||||
|
document.querySelector('h4#skip-to-content').before(block.getBase());
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// 主页界面
|
||||||
|
case TRAVEL_STATE.IN_TORN: {
|
||||||
|
// 落地转跳
|
||||||
|
if (sessionStorage['wh-landed-redirect']) {
|
||||||
|
let { url, timestamp } = JSON.parse(sessionStorage['wh-landed-redirect']);
|
||||||
|
if (Date.now() - timestamp < 30000) {
|
||||||
|
sessionStorage.removeItem('wh-landed-redirect');
|
||||||
|
location.href = url;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
// 起飞页面
|
||||||
// 起飞页面
|
else if (href.contains(/travelagency\.php/)) {
|
||||||
else if (href.contains(/travelagency\.php/)) {
|
// 起飞提醒 TODO 去除jquery mutation
|
||||||
// 起飞提醒 TODO 去除jquery mutation
|
if (this.localConfigWrapper.config.energyAlert) {
|
||||||
if (WuhuConfig.get('energyAlert')) {
|
const contentWrapper = document.querySelector('.content-wrapper');
|
||||||
const contentWrapper = document.querySelector('.content-wrapper');
|
const OB = new MutationObserver(() => {
|
||||||
const OB = new MutationObserver(() => {
|
OB.disconnect();
|
||||||
OB.disconnect();
|
titleTrans();
|
||||||
titleTrans();
|
contentTitleLinksTrans();
|
||||||
contentTitleLinksTrans();
|
trans();
|
||||||
|
OB.observe(contentWrapper, {
|
||||||
|
characterData: true,
|
||||||
|
attributes: true,
|
||||||
|
subtree: true,
|
||||||
|
childList: true
|
||||||
|
});
|
||||||
|
});
|
||||||
|
const trans = () => {
|
||||||
|
// 当前能量e
|
||||||
|
const energyBarStr = $('#barEnergy p[class^="bar-value__"]').text().trim();
|
||||||
|
const [curE, maxE] = energyBarStr.split('/').length === 2
|
||||||
|
? [parseInt(energyBarStr.split('/')[0]), parseInt(energyBarStr.split('/')[1])]
|
||||||
|
: [NaN, NaN];
|
||||||
|
const incTime = maxE === 150 ? 10 : 15;
|
||||||
|
const fullEnergyTime = !(isNaN(curE) || isNaN(maxE)) ? (maxE - 5 - curE) / 5 * incTime
|
||||||
|
+ (incTime - new Date().getMinutes() % incTime) : NaN;
|
||||||
|
// 起飞前提示
|
||||||
|
$('.travel-confirm .travel-question .q-wrap span:nth-of-type(2)').each((i, e) => {
|
||||||
|
if (isNaN(fullEnergyTime)) return;
|
||||||
|
const spl = e.innerText.trim().split(' ');
|
||||||
|
const [hours, minutes] = spl.length === 5
|
||||||
|
? [parseInt(spl[0]), parseInt(spl[3])]
|
||||||
|
: [0, parseInt(spl[0])];
|
||||||
|
if (fullEnergyTime < (hours * 60 + minutes) * 2) {
|
||||||
|
if (!$(e).parent().hasClass('wh-translated')) {
|
||||||
|
$(e).parent()
|
||||||
|
.prepend(`<div style="color: red">警告:该次飞行往返时间大于体力回复时间,将会爆体!</div>`)
|
||||||
|
.addClass('wh-translated');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
trans();
|
trans();
|
||||||
OB.observe(contentWrapper, {
|
OB.observe(contentWrapper, {
|
||||||
characterData: true,
|
characterData: true,
|
||||||
@ -250,69 +336,41 @@ export default async function travelHelper(): Promise<void> {
|
|||||||
subtree: true,
|
subtree: true,
|
||||||
childList: true
|
childList: true
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
const trans = () => {
|
// 一键起飞
|
||||||
// 当前能量e
|
if (window.sessionStorage['wh-quick-fly']) {
|
||||||
const energyBarStr = $('#barEnergy p[class^="bar-value__"]').text().trim();
|
QuickFlyBtnHandler.doQuickFly();
|
||||||
const [curE, maxE] = energyBarStr.split('/').length === 2
|
}
|
||||||
? [parseInt(energyBarStr.split('/')[0]), parseInt(energyBarStr.split('/')[1])]
|
}
|
||||||
: [NaN, NaN];
|
}
|
||||||
const incTime = maxE === 150 ? 10 : 15;
|
|
||||||
const fullEnergyTime = !(isNaN(curE) || isNaN(maxE)) ? (maxE - 5 - curE) / 5 * incTime
|
/** TODO */
|
||||||
+ (incTime - new Date().getMinutes() % incTime) : NaN;
|
inTravelPage() {
|
||||||
// 起飞前提示
|
}
|
||||||
$('.travel-confirm .travel-question .q-wrap span:nth-of-type(2)').each((i, e) => {
|
|
||||||
if (isNaN(fullEnergyTime)) return;
|
async doTravelBack(): Promise<void> {
|
||||||
const spl = e.innerText.trim().split(' ');
|
if (typeof window['getAction'] !== 'function') return;
|
||||||
const [hours, minutes] = spl.length === 5
|
let backHomeAction = function (): Promise<string> {
|
||||||
? [parseInt(spl[0]), parseInt(spl[3])]
|
return new Promise(resolve => {
|
||||||
: [0, parseInt(spl[0])];
|
window.getAction({
|
||||||
if (fullEnergyTime < (hours * 60 + minutes) * 2) {
|
type: "post",
|
||||||
if (!$(e).parent().hasClass('wh-translated')) {
|
action: 'travelagency.php',
|
||||||
$(e).parent()
|
data: {
|
||||||
.prepend(`<div style="color: red">警告:该次飞行往返时间大于体力回复时间,将会爆体!</div>`)
|
step: 'backHomeAction'
|
||||||
.addClass('wh-translated');
|
},
|
||||||
}
|
success: function (msg) {
|
||||||
|
resolve(msg);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
|
||||||
trans();
|
|
||||||
OB.observe(contentWrapper, {
|
|
||||||
characterData: true,
|
|
||||||
attributes: true,
|
|
||||||
subtree: true,
|
|
||||||
childList: true
|
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
// 一键起飞
|
let res = await backHomeAction();
|
||||||
if (sessionStorage['wh-quick-fly']) {
|
new Alert(res);
|
||||||
QuickFlyBtnHandler.doQuickFly();
|
if (!res.includes('error')) {
|
||||||
|
new Alert('成功,即将刷新');
|
||||||
|
window.setTimeout(() => location.reload(), 3000);
|
||||||
|
} else {
|
||||||
|
new Alert('出错了');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function travelBack(): Promise<null> {
|
|
||||||
if (typeof window['getAction'] !== 'function') return;
|
|
||||||
let backHomeAction = function (): Promise<string> {
|
|
||||||
return new Promise(resolve => {
|
|
||||||
window.getAction({
|
|
||||||
type: "post",
|
|
||||||
action: 'travelagency.php',
|
|
||||||
data: {
|
|
||||||
step: 'backHomeAction'
|
|
||||||
},
|
|
||||||
success: function (msg) {
|
|
||||||
resolve(msg);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
|
||||||
let res = await backHomeAction();
|
|
||||||
new Alert(res);
|
|
||||||
if (!res.includes('error')) {
|
|
||||||
new Alert('成功,即将刷新');
|
|
||||||
window.setTimeout(() => location.reload(), 3000);
|
|
||||||
} else {
|
|
||||||
new Alert('出错了');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,5 +1,6 @@
|
|||||||
import { eventsDict, gymList, ocList } from "../../dictionary/translation";
|
import { eventsDict, gymList, ocList } from "../../dictionary/translation";
|
||||||
import log from "../utils/@deprecated/log";
|
|
||||||
|
let log = { info: (args) => null };
|
||||||
|
|
||||||
export default function eventsTrans(events: JQuery = $('span.mail-link')) {
|
export default function eventsTrans(events: JQuery = $('span.mail-link')) {
|
||||||
const index = window.location.href.indexOf('events.php#/step=received') >= 0 ? 1 : 0;
|
const index = window.location.href.indexOf('events.php#/step=received') >= 0 ? 1 : 0;
|
||||||
@ -553,9 +554,9 @@ export default function eventsTrans(events: JQuery = $('span.mail-link')) {
|
|||||||
const num = spl[3] === 'a' ? '1' : spl[3];
|
const num = spl[3] === 'a' ? '1' : spl[3];
|
||||||
const price = reasonSpl[0].split(' ').slice(-1)[0];
|
const price = reasonSpl[0].split(' ').slice(-1)[0];
|
||||||
const reason = reasonSpl[1] ? reasonSpl[1] : null;
|
const reason = reasonSpl[1] ? reasonSpl[1] : null;
|
||||||
const trans = `${ someone ? '某人' : ' ' }对你进行了 ${ num } 次赏金为 ${ price } 的悬赏${ reason ? ',原因:' + reason : '' }`;
|
const trans = `${ someone ?? '某人1' }对你进行了 ${ num } 次赏金为 ${ price } 的悬赏${ reason ? ',原因:' + reason : '' }`;
|
||||||
// 匿名悬赏
|
// 匿名悬赏
|
||||||
if (someone) {
|
if (!!someone) {
|
||||||
$(e).text(trans);
|
$(e).text(trans);
|
||||||
}
|
}
|
||||||
// 实名悬赏
|
// 实名悬赏
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import log from "../utils/@deprecated/log";
|
let log = { info: (args) => null };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* observe 包装
|
* observe 包装
|
||||||
|
|||||||
@ -34,11 +34,12 @@ import initOB from "./initOB";
|
|||||||
import titleTrans from "./titleTrans";
|
import titleTrans from "./titleTrans";
|
||||||
import contentTitleLinksTrans from "./contentTitleLinksTrans";
|
import contentTitleLinksTrans from "./contentTitleLinksTrans";
|
||||||
import showItemInfoTrans from "./showItemInfoTrans";
|
import showItemInfoTrans from "./showItemInfoTrans";
|
||||||
import log from "../utils/@deprecated/log";
|
|
||||||
import contentTitleLinksTransReact from "./contentTitleLinksTransReact";
|
import contentTitleLinksTransReact from "./contentTitleLinksTransReact";
|
||||||
import titleTransReact from "./titleTransReact";
|
import titleTransReact from "./titleTransReact";
|
||||||
import Log from "../../class/Log";
|
import Log from "../../class/Log";
|
||||||
|
|
||||||
|
let log = { info: (args) => null };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated
|
* @deprecated
|
||||||
* @param href
|
* @param href
|
||||||
@ -1112,7 +1113,7 @@ export default function translateMain(href: string): void {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ($('.wh-translated').length <= 0) {
|
if ($('.wh-translated').length <= 0) {
|
||||||
log.info(`未找到翻译: “${ action_desc.text().trim() }”`);
|
log.info(`未找到翻译: 「${ action_desc.text().trim() }」`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 添加敌人或朋友的界面
|
// 添加敌人或朋友的界面
|
||||||
|
|||||||
@ -1,98 +0,0 @@
|
|||||||
import audioPlay from "./audioPlay";
|
|
||||||
import MathUtils from "../../../class/utils/MathUtils";
|
|
||||||
import Alert from "../../../class/utils/Alert";
|
|
||||||
import InfoUtils from "../../../class/utils/InfoUtils";
|
|
||||||
import WuhuConfig from "../../../class/WuhuConfig";
|
|
||||||
import Log from "../../../class/Log";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
export default function BuyBeer() {
|
|
||||||
// 正在通知
|
|
||||||
let is_notified = false;
|
|
||||||
let time: number = WuhuConfig.get('_15AlarmTime') || 30;
|
|
||||||
let loop: BeerMonitorLoop = {};
|
|
||||||
// 循环id
|
|
||||||
let started = null;
|
|
||||||
loop.start = () => {
|
|
||||||
if (started) {
|
|
||||||
Log.info('啤酒助手已在运行');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
started = setInterval(async () => {
|
|
||||||
// 海外取消提醒
|
|
||||||
let { isTravelling, isAbroad } = await InfoUtils.getInstance().getUserState();
|
|
||||||
if (isTravelling || isAbroad) {
|
|
||||||
loop.stop();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
let dt = new Date();
|
|
||||||
// 已选当天不提醒
|
|
||||||
const now = [dt.getUTCFullYear(), dt.getUTCMonth(), dt.getUTCDate()];
|
|
||||||
const ignore_date = WuhuConfig.get('_15_alarm_ignore') || '{}';
|
|
||||||
if (JSON.stringify(now) === JSON.stringify(ignore_date)) return;
|
|
||||||
// 正常提醒
|
|
||||||
let m = 14 - (dt.getMinutes() % 15);
|
|
||||||
let s = 60 - dt.getSeconds();
|
|
||||||
if (m === 0 && s < time) {
|
|
||||||
// 如从通知点开,则本次通知跳过
|
|
||||||
if (location.href.includes('#clickfromnotify')) {
|
|
||||||
is_notified = true;
|
|
||||||
location.hash = '';
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// 本次已通知
|
|
||||||
if (is_notified) return;
|
|
||||||
is_notified = true;
|
|
||||||
// 发送通知
|
|
||||||
const notify = new Alert(notify_html, {
|
|
||||||
timeout: 30,
|
|
||||||
sysNotify: true,
|
|
||||||
});
|
|
||||||
notify.getElement().querySelector('.wh-notify-msg button').addEventListener('click', () => loop.skip_today);
|
|
||||||
notify.getElement().addEventListener('click', ev => {
|
|
||||||
if ((ev.target as HTMLElement).tagName.toLowerCase() === 'a') {
|
|
||||||
// notify.sys_notify.close();
|
|
||||||
notify.close();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
window.setTimeout(audioPlay, 800);
|
|
||||||
window.setTimeout(audioPlay, 800 * 2);
|
|
||||||
window.setTimeout(audioPlay, 800 * 3);
|
|
||||||
} else {
|
|
||||||
is_notified = false;
|
|
||||||
}
|
|
||||||
}, 1000);
|
|
||||||
};
|
|
||||||
loop.stop = () => {
|
|
||||||
if (started) {
|
|
||||||
clearInterval(started);
|
|
||||||
started = null;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
loop.set_time = (t) => time = t;
|
|
||||||
loop.status = () => started ? '已启动' : '未启动';
|
|
||||||
loop.is_running = () => !!started;
|
|
||||||
|
|
||||||
let mathUtils: MathUtils = MathUtils.getInstance();
|
|
||||||
let notify_html = `<span style="background-color:green;color:white;border-radius:3px;font-size:14px;line-height:21px;padding:2px 4px;">啤酒小助手</span><br/>提醒您:还有不到 50 秒 NPC 的商品就要刷新了,啤酒血包要抢的可以准备咯。<button id="wh-rd-btn-${ mathUtils.getRandomInt(0, 100) }">【今日不再提醒】</button><br/><a href="/shops.php?step=bitsnbobs#clickfromnotify" target="_blank">【啤酒店】</a> <a href="/shops.php?step=pharmacy#clickfromnotify" target="_blank">【血包店】</a>`
|
|
||||||
loop.skip_today = () => {
|
|
||||||
const date = new Date();
|
|
||||||
WuhuConfig.set('_15_alarm_ignore', [date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate()], false);
|
|
||||||
// 通知
|
|
||||||
const notify = new Alert(`明早8点前将不再提醒 <button id="wh-rd-btn-${ mathUtils.getRandomInt(0, 100) }">取消</button>`);
|
|
||||||
// 通知中的取消按钮
|
|
||||||
notify.getElement().querySelector('.wh-notify-msg button').addEventListener('click', () => WuhuConfig.set('_15_alarm_ignore', undefined));
|
|
||||||
};
|
|
||||||
return loop;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface BeerMonitorLoop {
|
|
||||||
start?: Function;
|
|
||||||
stop?: Function;
|
|
||||||
set_time?: Function;
|
|
||||||
status?: Function;
|
|
||||||
is_running?: Function;
|
|
||||||
skip_today?: Function;
|
|
||||||
}
|
|
||||||
@ -1,65 +0,0 @@
|
|||||||
import UserScriptEngine from "../../../enum/UserScriptEngine";
|
|
||||||
import getScriptEngine from "./getScriptEngine";
|
|
||||||
import Log from "../../../class/Log";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
export default function COFetch(url: URL | string, method: 'get' | 'post' = 'get', body: any = null): Promise<string> {
|
|
||||||
return new Promise<string>((resolve, reject) => {
|
|
||||||
const engine = getScriptEngine();
|
|
||||||
switch (engine) {
|
|
||||||
case UserScriptEngine.RAW: {
|
|
||||||
console.error(`[wh] 跨域请求错误:${ UserScriptEngine.RAW }环境下无法进行跨域请求`);
|
|
||||||
reject(`错误:${ UserScriptEngine.RAW }环境下无法进行跨域请求`);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case UserScriptEngine.PDA: {
|
|
||||||
const { PDA_httpGet, PDA_httpPost } = window;
|
|
||||||
// get
|
|
||||||
if (method === 'get') {
|
|
||||||
if (typeof PDA_httpGet !== 'function') {
|
|
||||||
Log.error('COFetch网络错误:PDA版本不支持');
|
|
||||||
reject('COFetch网络错误:PDA版本不支持');
|
|
||||||
}
|
|
||||||
PDA_httpGet(url)
|
|
||||||
.then(res => resolve(res.responseText))
|
|
||||||
.catch(e => {
|
|
||||||
Log.error('COFetch网络错误', e);
|
|
||||||
reject(`COFetch网络错误 ${ e }`);
|
|
||||||
})
|
|
||||||
}
|
|
||||||
// post
|
|
||||||
else {
|
|
||||||
if (typeof PDA_httpPost !== 'function') {
|
|
||||||
Log.error('COFetch网络错误:PDA版本不支持');
|
|
||||||
reject('COFetch网络错误:PDA版本不支持');
|
|
||||||
}
|
|
||||||
PDA_httpPost(url, { 'content-type': 'application/json' }, body)
|
|
||||||
.then(res => resolve(res.responseText))
|
|
||||||
.catch(e => {
|
|
||||||
Log.error('COFetch网络错误', e);
|
|
||||||
reject(`COFetch网络错误 ${ e }`);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case UserScriptEngine.GM: {
|
|
||||||
let { GM_xmlhttpRequest } = window;
|
|
||||||
if (typeof GM_xmlhttpRequest !== 'function') {
|
|
||||||
Log.error('COFetch网络错误:用户脚本扩展API错误');
|
|
||||||
reject('错误:用户脚本扩展API错误');
|
|
||||||
}
|
|
||||||
GM_xmlhttpRequest({
|
|
||||||
method: method,
|
|
||||||
url: url,
|
|
||||||
data: method === 'get' ? null : body,
|
|
||||||
headers: method === 'get' ? null : { 'content-type': 'application/json' },
|
|
||||||
onload: res => resolve(res.response),
|
|
||||||
onerror: res => reject(`连接错误 ${ JSON.stringify(res) }`),
|
|
||||||
ontimeout: res => reject(`连接超时 ${ JSON.stringify(res) }`),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
@ -1,56 +0,0 @@
|
|||||||
/**
|
|
||||||
* 解析 Markdown 内容
|
|
||||||
* @param {String} from
|
|
||||||
* @param {Number} max_line 最大行数,默认500
|
|
||||||
* @returns {HTMLDivElement}
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
export default function mdParse(from: string, max_line?: number): HTMLElement {
|
|
||||||
max_line = max_line || 500;
|
|
||||||
const base = document.createElement('div');
|
|
||||||
let lines = from.split('\n');
|
|
||||||
if (lines.length > max_line) {
|
|
||||||
lines = lines.slice(0, max_line);
|
|
||||||
lines.push("...");
|
|
||||||
}
|
|
||||||
|
|
||||||
let prev = '';
|
|
||||||
let child_cont;
|
|
||||||
lines.forEach(line => {
|
|
||||||
if (line.trim() === '') return;
|
|
||||||
let node;
|
|
||||||
let spl = line.split(' ');
|
|
||||||
let md_flag = spl[0];
|
|
||||||
|
|
||||||
switch (md_flag) {
|
|
||||||
// 标题
|
|
||||||
case '#':
|
|
||||||
case '##':
|
|
||||||
case '###':
|
|
||||||
if (prev === 'li') {
|
|
||||||
child_cont = null;
|
|
||||||
}
|
|
||||||
prev = 'h' + (md_flag.length + 1);
|
|
||||||
node = document.createElement(prev);
|
|
||||||
node.innerText = line.slice(md_flag.length + 1);
|
|
||||||
base.append(node);
|
|
||||||
return;
|
|
||||||
// 列表
|
|
||||||
case '-':
|
|
||||||
if (prev !== 'li') {
|
|
||||||
child_cont = document.createElement('ul');
|
|
||||||
if (!base.contains(child_cont)) base.append(child_cont);
|
|
||||||
}
|
|
||||||
prev = 'li';
|
|
||||||
node = document.createElement(prev);
|
|
||||||
node.innerText = line.slice(2);
|
|
||||||
child_cont.append(node);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
prev = 'p';
|
|
||||||
node = document.createElement(prev);
|
|
||||||
node.innerText = line.trim();
|
|
||||||
base.append(node);
|
|
||||||
})
|
|
||||||
return base;
|
|
||||||
}
|
|
||||||
@ -1,151 +0,0 @@
|
|||||||
import addStyle from "./addStyle";
|
|
||||||
import WuhuBase from "../../../class/WuhuBase";
|
|
||||||
import MathUtils from "../../../class/utils/MathUtils";
|
|
||||||
import WindowActiveState from "../../../class/action/WindowActiveState";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 通知方法
|
|
||||||
* @param {string} msg - 通知内容
|
|
||||||
* @param {Object} [options] - 通知选项
|
|
||||||
* @param {number} [options.timeout] - 通知超时时间
|
|
||||||
* @param {function} [options.callback] - 通知回调
|
|
||||||
* @param {boolean} [options.sysNotify] - 是否开启系统通知
|
|
||||||
* @param {string} [options.sysNotifyTag] - 系统通知标记
|
|
||||||
* @param {function} [options.sysNotifyClick] - 系统通知点击事件
|
|
||||||
* @return {HTMLElement}
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
export default function WHNotify(msg: string, options: WHNotifyOpt = {}): MyHTMLElement {
|
|
||||||
let { notifies } = WuhuBase.glob;
|
|
||||||
let mathUtils: MathUtils = MathUtils.getInstance();
|
|
||||||
|
|
||||||
let {
|
|
||||||
timeout = 3,
|
|
||||||
callback = function () {
|
|
||||||
},
|
|
||||||
sysNotify = false,
|
|
||||||
sysNotifyTag = '芜湖助手',
|
|
||||||
sysNotifyClick = () => window.focus()
|
|
||||||
} = options;
|
|
||||||
|
|
||||||
if (!WindowActiveState.getInstance().get() || (self !== top)) return null;
|
|
||||||
const date = new Date();
|
|
||||||
// 通知的唯一id
|
|
||||||
const uid = `${ date.getHours() }${ date.getSeconds() }${ date.getMilliseconds() }${ mathUtils.getRandomInt(1000, 9999) }`;
|
|
||||||
// 通知容器id
|
|
||||||
// 通知的容器
|
|
||||||
let notify_contain: MyHTMLElement = document.querySelector(`#wh-notify`);
|
|
||||||
// 添加通知到容器
|
|
||||||
const add_notify = () => {
|
|
||||||
// 每条通知
|
|
||||||
const new_node: MyHTMLElement = document.createElement('div');
|
|
||||||
new_node.id = `wh-notify-${ uid }`;
|
|
||||||
new_node.classList.add('wh-notify-item');
|
|
||||||
new_node.innerHTML = `<div class="wh-notify-bar"></div>
|
|
||||||
<div class="wh-notify-cont">
|
|
||||||
<div class="wh-notify-close"></div>
|
|
||||||
<div class="wh-notify-msg"><p>${ msg }</p></div>
|
|
||||||
</div>`;
|
|
||||||
notify_contain.append(new_node);
|
|
||||||
notify_contain['msgInnerText'] = new_node.querySelector('.wh-notify-msg').innerText;
|
|
||||||
// 进度条node
|
|
||||||
const progressBar: HTMLElement = new_node.querySelector('.wh-notify-bar');
|
|
||||||
// 是否hover
|
|
||||||
let mouse_enter = false;
|
|
||||||
new_node.addEventListener('mouseenter', () => mouse_enter = true, true);
|
|
||||||
new_node.addEventListener('mouseleave', () => mouse_enter = false);
|
|
||||||
// 通知进度条
|
|
||||||
let progressCount = 101;
|
|
||||||
// 删除通知
|
|
||||||
new_node.close = () => {
|
|
||||||
clearInterval(intervalID);
|
|
||||||
new_node.remove();
|
|
||||||
callback();
|
|
||||||
};
|
|
||||||
// 计时器
|
|
||||||
let intervalID = window.setInterval(() => {
|
|
||||||
if (mouse_enter) {
|
|
||||||
progressCount = 101;
|
|
||||||
progressBar.style.width = '100%';
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
progressCount--;
|
|
||||||
progressBar.style.width = `${ progressCount }%`;
|
|
||||||
if (progressCount === 0) new_node.remove();
|
|
||||||
}, timeout * 1000 / 100);
|
|
||||||
new_node.querySelector('.wh-notify-close').addEventListener('click', new_node.close);
|
|
||||||
return new_node;
|
|
||||||
};
|
|
||||||
// 不存在容器 创建
|
|
||||||
if (!notify_contain) {
|
|
||||||
notify_contain = document.createElement('div');
|
|
||||||
notify_contain.id = 'wh-notify';
|
|
||||||
addStyle(`
|
|
||||||
#wh-notify {
|
|
||||||
display: inline-block;
|
|
||||||
position: fixed;
|
|
||||||
top: 0;
|
|
||||||
left: calc(50% - 180px);
|
|
||||||
width: 360px;
|
|
||||||
z-index: 9999990;
|
|
||||||
color:#333;
|
|
||||||
}
|
|
||||||
#wh-notify a{
|
|
||||||
color:red;
|
|
||||||
text-decoration:none;
|
|
||||||
}
|
|
||||||
#wh-notify .wh-notify-item {
|
|
||||||
/*height: 50px;*/
|
|
||||||
background: rgb(239 249 255 / 90%);
|
|
||||||
border-radius: 2px;
|
|
||||||
margin: 0.5em 0 0 0;
|
|
||||||
box-shadow: 0 0 5px 0px #959595;
|
|
||||||
}
|
|
||||||
#wh-notify .wh-notify-item:hover {
|
|
||||||
background: rgb(239 249 255 / 98%);
|
|
||||||
}
|
|
||||||
#wh-notify .wh-notify-item .wh-notify-bar {
|
|
||||||
height:2px;
|
|
||||||
background:#2196f3;
|
|
||||||
}
|
|
||||||
#wh-notify .wh-notify-item .wh-notify-close {
|
|
||||||
float:right;
|
|
||||||
padding:0;
|
|
||||||
width:16px;height:16px;
|
|
||||||
background:url('data:image/svg+xml,%3Csvg%20viewBox%3D%220%200%201024%201024%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20d%3D%22M923%20571H130.7c-27.6%200-50-22.4-50-50s22.4-50%2050-50H923c27.6%200%2050%2022.4%2050%2050s-22.4%2050-50%2050z%22%20fill%3D%22%232196f3%22%3E%3C%2Fpath%3E%3C%2Fsvg%3E') no-repeat center;
|
|
||||||
background-size:100%;
|
|
||||||
margin: 6px 6px 0 0;
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
#wh-notify .wh-notify-item .wh-notify-msg {
|
|
||||||
padding:12px;
|
|
||||||
}
|
|
||||||
`);
|
|
||||||
document.body.append(notify_contain);
|
|
||||||
}
|
|
||||||
const notify_obj = add_notify();
|
|
||||||
// 浏览器通知
|
|
||||||
if (window.Notification && Notification.permission === 'granted' && sysNotify) {
|
|
||||||
const date_local_string = `[${ date.getHours() }:${ date.getMinutes() }:${ date.getSeconds() }]\r`;
|
|
||||||
notify_obj.sys_notify = new Notification('芜湖助手', {
|
|
||||||
body: date_local_string + notify_contain.msgInnerText,
|
|
||||||
requireInteraction: true,
|
|
||||||
renotify: true,
|
|
||||||
tag: sysNotifyTag + mathUtils.getRandomInt(0, 99),
|
|
||||||
});
|
|
||||||
notify_obj.sys_notify.addEventListener('close', () => sysNotifyClick());
|
|
||||||
notify_obj.sys_notify.onshow = () => setTimeout(() => notify_obj.sys_notify.close(), timeout * 1000);
|
|
||||||
notify_obj.sys_notify.id = notifies.count++;
|
|
||||||
notifies[notify_obj.sys_notify.id] = notify_obj.sys_notify;
|
|
||||||
notify_obj.sys_notify.addEventListener('close', () => notifies[notify_obj.sys_notify.id] = null);
|
|
||||||
}
|
|
||||||
return notify_obj;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface WHNotifyOpt {
|
|
||||||
timeout?: number;
|
|
||||||
callback?: Function;
|
|
||||||
sysNotify?: boolean;
|
|
||||||
sysNotifyTag?: string;
|
|
||||||
sysNotifyClick?: Function;
|
|
||||||
}
|
|
||||||
@ -1,22 +0,0 @@
|
|||||||
import Log from "../../../class/Log";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
export default function addActionBtn(txt: string, func: (ev: Event) => void, mainBtnNode: Element): void {
|
|
||||||
addActionBtn.proxy(txt, func, mainBtnNode);
|
|
||||||
}
|
|
||||||
|
|
||||||
addActionBtn.proxy = (txt: string, func: (ev: Event) => void, mainBtnNode: Element) => {
|
|
||||||
if (mainBtnNode.querySelector('#wh-trans-icon-btn').nextSibling !== null) return;
|
|
||||||
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);
|
|
||||||
mainBtnNode.querySelector('button').after(btn);
|
|
||||||
addActionBtn.proxy = () => {
|
|
||||||
Log.error('错误:附加按钮已存在')
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@ -1,17 +0,0 @@
|
|||||||
import log from "./log";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
export default function addStyle(css: string) {
|
|
||||||
let wh_gStyle = document.querySelector('style#wh-trans-gStyle');
|
|
||||||
if (wh_gStyle) {
|
|
||||||
wh_gStyle.innerHTML += css;
|
|
||||||
} else {
|
|
||||||
wh_gStyle = document.createElement("style");
|
|
||||||
wh_gStyle.id = 'wh-trans-gStyle';
|
|
||||||
wh_gStyle.innerHTML = css;
|
|
||||||
document.head.append(wh_gStyle);
|
|
||||||
}
|
|
||||||
log.info('CSS规则已添加', wh_gStyle);
|
|
||||||
}
|
|
||||||
@ -1,23 +0,0 @@
|
|||||||
/**
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
export default function ajaxFetch(opt) {
|
|
||||||
let { url, referrer, method, body = null } = opt;
|
|
||||||
let req_params: AjaxFetchOpt = {
|
|
||||||
headers: { 'X-Requested-With': 'XMLHttpRequest' },
|
|
||||||
referrer,
|
|
||||||
method,
|
|
||||||
};
|
|
||||||
if (method === 'POST') {
|
|
||||||
req_params.headers['Content-Type'] = 'application/x-www-form-urlencoded; charset=UTF-8';
|
|
||||||
req_params.body = body;
|
|
||||||
}
|
|
||||||
return window.fetch(url, req_params);
|
|
||||||
}
|
|
||||||
|
|
||||||
interface AjaxFetchOpt {
|
|
||||||
headers: { 'X-Requested-With'?: string, 'Content-Type'?: string };
|
|
||||||
referrer: string;
|
|
||||||
method: string;
|
|
||||||
body?: any;
|
|
||||||
}
|
|
||||||
@ -1,24 +0,0 @@
|
|||||||
// import CommonUtils from "../../../class/utils/CommonUtils";
|
|
||||||
// import WindowActiveState from "../../../class/action/WindowActiveState";
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * @deprecated
|
|
||||||
// */
|
|
||||||
// function autoFetchJSON(dest, time = 30) {
|
|
||||||
// let obj;
|
|
||||||
// const res = CommonUtils.COFetch(dest);
|
|
||||||
// setInterval(async () => {
|
|
||||||
// if (!WindowActiveState.getInstance().get()) return;
|
|
||||||
// const res = await CommonUtils.COFetch(dest);
|
|
||||||
// obj = JSON.parse(res);
|
|
||||||
// }, time * 1000);
|
|
||||||
// return {
|
|
||||||
// get: async function () {
|
|
||||||
// if (!obj) {
|
|
||||||
// const str = await res
|
|
||||||
// return obj = JSON.parse(str);
|
|
||||||
// }
|
|
||||||
// return obj;
|
|
||||||
// }
|
|
||||||
// };
|
|
||||||
// }
|
|
||||||
@ -1,11 +0,0 @@
|
|||||||
import UserScriptEngine from "../../../enum/UserScriptEngine";
|
|
||||||
import WuhuBase from "../../../class/WuhuBase";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
export default function getScriptEngine() {
|
|
||||||
let glob = WuhuBase.glob;
|
|
||||||
return glob.unsafeWindow ? UserScriptEngine.GM : glob.isPDA
|
|
||||||
? UserScriptEngine.PDA : UserScriptEngine.RAW;
|
|
||||||
}
|
|
||||||
@ -1,40 +0,0 @@
|
|||||||
import CommonUtils from "../../../class/utils/CommonUtils";
|
|
||||||
import Log from "../../../class/Log";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
export default async function getSidebarData() {
|
|
||||||
let ret = {};
|
|
||||||
let sidebar_id = null;
|
|
||||||
|
|
||||||
let sessionKeys = Object.keys(sessionStorage);
|
|
||||||
if (sessionKeys.length < 2) {
|
|
||||||
// dom获取
|
|
||||||
let sidebar_menu_list = document.querySelectorAll('#sidebar a span[class*="linkName___"]');
|
|
||||||
Log.info({ sidebar_menu_list })
|
|
||||||
if (sidebar_menu_list.length === 0) {
|
|
||||||
await CommonUtils.elementReady('#sidebar a span[class*="linkName___"]');
|
|
||||||
sidebar_menu_list = document.querySelectorAll('#sidebar a span[class*="linkName___"]');
|
|
||||||
}
|
|
||||||
sidebar_menu_list.forEach(node => ret[node.innerHTML.trim().toLowerCase().replaceAll(' ', '_')] = true);
|
|
||||||
} else {
|
|
||||||
// session storage获取
|
|
||||||
for (let key of sessionKeys) {
|
|
||||||
if (key.startsWith('sidebarData')) {
|
|
||||||
sidebar_id = JSON.parse(sessionStorage.getItem(key));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (sidebar_id !== null) {
|
|
||||||
for (let area of Object.keys(sidebar_id['areas'])) {
|
|
||||||
ret[area] = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Log.info({ ret, sidebar_id, sessionKeys })
|
|
||||||
if (Object.keys(ret).length === 0) {
|
|
||||||
Log.error('无法获取数据,建议刷新重试');
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
@ -1,9 +0,0 @@
|
|||||||
/**
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
export default function getUserState(): {} | any {
|
|
||||||
let obj = {};
|
|
||||||
let hdd = sessionStorage['headerData'];
|
|
||||||
if (hdd) obj = JSON.parse(hdd)['user']['state'];
|
|
||||||
return obj;
|
|
||||||
}
|
|
||||||
@ -1,11 +0,0 @@
|
|||||||
/**
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
export default function getWhSettingObj(): WHSettings {
|
|
||||||
return JSON.parse(localStorage.getItem('wh_trans_settings')) || {}
|
|
||||||
}
|
|
||||||
|
|
||||||
interface WHSettings {
|
|
||||||
// TODO 补全
|
|
||||||
[key: string]: any;
|
|
||||||
}
|
|
||||||
@ -1,36 +0,0 @@
|
|||||||
import getWhSettingObj from "./getWhSettingObj";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
function debug() {
|
|
||||||
try {
|
|
||||||
return getWhSettingObj()['isDev'] || false;
|
|
||||||
} catch (e) {
|
|
||||||
console.error(`[wh] dev状态错误 ${ e }`);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
const log = {
|
|
||||||
/**
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
error: (...o) => (debug()) && (console.error('[WH]', ...o)),
|
|
||||||
/**
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
info: (...o) => (debug()) && (console.log('[WH]', ...o)),
|
|
||||||
/**
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
debug,
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
export default log
|
|
||||||
@ -1,29 +0,0 @@
|
|||||||
import WuhuBase from "../../../class/WuhuBase";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated 使用new Popup()
|
|
||||||
*/
|
|
||||||
export default function popupMsg(innerHTML, title = '芜湖助手') {
|
|
||||||
let glob = WuhuBase.glob;
|
|
||||||
if (glob.popup_node) glob.popup_node.close();
|
|
||||||
const chatRoot = document.querySelector('#chatRoot');
|
|
||||||
chatRoot.classList.add('wh-hide');
|
|
||||||
const popup = document.createElement('div');
|
|
||||||
popup.id = 'wh-popup';
|
|
||||||
popup.innerHTML = `<div id="wh-popup-container">
|
|
||||||
<div id="wh-popup-title"><p>${ title }</p></div>
|
|
||||||
<div id="wh-popup-cont">${ innerHTML }</div>
|
|
||||||
</div>`;
|
|
||||||
document.body.append(popup);
|
|
||||||
const rt: MyHTMLElement = popup.querySelector('#wh-popup-cont');
|
|
||||||
rt.close = function () {
|
|
||||||
popup.remove();
|
|
||||||
chatRoot.classList.remove('wh-hide');
|
|
||||||
}
|
|
||||||
popup.addEventListener('click', e => {
|
|
||||||
e.stopImmediatePropagation();
|
|
||||||
if (e.target === popup) rt.close();
|
|
||||||
});
|
|
||||||
glob.popup_node = rt;
|
|
||||||
return rt;
|
|
||||||
}
|
|
||||||
@ -1,14 +0,0 @@
|
|||||||
import getWhSettingObj from "./getWhSettingObj";
|
|
||||||
import Alert from "../../../class/utils/Alert";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
export default function setWhSetting(key: string, value: any, notify: boolean = true) {
|
|
||||||
const obj = getWhSettingObj()
|
|
||||||
obj[key] = value
|
|
||||||
localStorage.setItem('wh_trans_settings', JSON.stringify(obj))
|
|
||||||
|
|
||||||
// 通知
|
|
||||||
if (notify) new Alert('已保存设置')
|
|
||||||
}
|
|
||||||
@ -1,15 +1,33 @@
|
|||||||
|
import Popup from "./class/utils/Popup";
|
||||||
|
|
||||||
|
// export default {
|
||||||
|
// // 监听到的fetch数据
|
||||||
|
// WH_NET_LOG: [],
|
||||||
|
// map: {},
|
||||||
|
// responseHandlers: [],
|
||||||
|
// version: '$$WUHU_DEV_VERSION$$',
|
||||||
|
// } as IGlobVars;
|
||||||
|
//
|
||||||
|
// interface IGlobVars {
|
||||||
|
// WH_NET_LOG: unknown[],
|
||||||
|
// map: { [key: string]: unknown },
|
||||||
|
// responseHandlers: ((url: string, responseBody: { json: unknown, text: string, isModified: boolean }, opt: { method: string, requestBody: unknown }) => void)[],
|
||||||
|
// version: string,
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
type ResponseHandlers = ((url: string, responseBody: { json: unknown, text: string, isModified: boolean }, opt: { method: string, requestBody: unknown }) => void)[];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通用全局参数
|
* 通用全局参数
|
||||||
*/
|
*/
|
||||||
export default {
|
class GlobVars {
|
||||||
// 监听到的fetch数据
|
// 监听到的fetch数据
|
||||||
WH_NET_LOG: [],
|
WH_NET_LOG: unknown[] = [];
|
||||||
map: {},
|
map: { [key: string]: unknown } = {};
|
||||||
responseHandlers: [],
|
responseHandlers: ResponseHandlers = [];
|
||||||
} as IGlobVars;
|
version = '$$WUHU_DEV_VERSION$$';
|
||||||
|
popup_node: MyHTMLElement | Popup = null;
|
||||||
interface IGlobVars {
|
|
||||||
WH_NET_LOG: unknown[],
|
|
||||||
map: { [key: string]: unknown },
|
|
||||||
responseHandlers: ((url: string, responseBody: { json: unknown, text: string, isModified: boolean }, opt: { method: string, requestBody: unknown }) => void)[],
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export default new GlobVars();
|
||||||
|
|||||||
@ -1,51 +1,13 @@
|
|||||||
import WuhuBase from "./class/WuhuBase";
|
|
||||||
import WuHuTornHelper from "./class/WuhuTornHelper";
|
|
||||||
import ZhongIcon from "./class/ZhongIcon";
|
|
||||||
import { Common } from "./class/Common";
|
|
||||||
import UrlPattern from "./class/UrlMatch";
|
|
||||||
import WuhuConfig from "./class/WuhuConfig";
|
|
||||||
import translateMain from "./func/translate/translateMain";
|
|
||||||
import CommonUtils from "./class/utils/CommonUtils";
|
|
||||||
import EntryPoint from "./class/provider/EntryPoint";
|
|
||||||
import { Container } from "./container/Container";
|
import { Container } from "./container/Container";
|
||||||
import Log from "./class/Log";
|
import App from "./App";
|
||||||
import LocalConfigWrapper from "./class/LocalConfigWrapper";
|
import Logger from "./class/Logger";
|
||||||
|
import EntryPoint from "./class/provider/EntryPoint";
|
||||||
|
import "reflect-metadata";
|
||||||
|
|
||||||
@EntryPoint
|
@EntryPoint
|
||||||
export default class Application {
|
class _ {
|
||||||
|
static main() {
|
||||||
public static main(): void {
|
Container.setLogger(new Logger());
|
||||||
Container.setLogger(Log);
|
Container.factory(App).run();
|
||||||
WuhuBase.conditionInterrupt();
|
|
||||||
|
|
||||||
// 初始化
|
|
||||||
Container.factory(WuHuTornHelper).init();
|
|
||||||
|
|
||||||
// 插件设置默认值
|
|
||||||
WuhuConfig.setDefaults();
|
|
||||||
|
|
||||||
// 插件图标和设置菜单
|
|
||||||
Container.factory(ZhongIcon).init();
|
|
||||||
|
|
||||||
let tmp = () => {
|
|
||||||
// 所有页面通用
|
|
||||||
try {
|
|
||||||
Container.factory(Common).resolve(Application.main);
|
|
||||||
} catch (e) {
|
|
||||||
}
|
|
||||||
|
|
||||||
// URL匹配
|
|
||||||
Container.factory(UrlPattern).resolve();
|
|
||||||
|
|
||||||
// 翻译
|
|
||||||
if (Container.factory(LocalConfigWrapper).config.transEnable)
|
|
||||||
translateMain(window.location.href);
|
|
||||||
};
|
|
||||||
// TODO 临时检测jquery
|
|
||||||
if (typeof $ === "function") {
|
|
||||||
tmp();
|
|
||||||
} else {
|
|
||||||
CommonUtils.getInstance().jQueryReady().then(() => tmp());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
import { MenuItemConfig } from "../class/ZhongIcon";
|
import { MenuItemConfig } from "../class/ZhongIcon";
|
||||||
|
import { InjectionKey } from "vue";
|
||||||
|
|
||||||
export default interface MenuItem extends MenuItemConfig {
|
export default interface MenuItem extends MenuItemConfig {
|
||||||
domType: MENU_ITEM_TYPE
|
domType: MENU_ITEM_TYPE
|
||||||
@ -10,3 +11,6 @@ export enum MENU_ITEM_TYPE {
|
|||||||
CHECKBOX = 'checkbox',
|
CHECKBOX = 'checkbox',
|
||||||
SELECT = 'select',
|
SELECT = 'select',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// export
|
||||||
|
export const menuItemList = Symbol() as InjectionKey<MenuItem[]>;
|
||||||
|
|||||||
@ -1,9 +1,8 @@
|
|||||||
import Log from "../class/Log";
|
import Log from "../class/Log";
|
||||||
import CompanyHelper from "../class/action/CompanyHelper";
|
|
||||||
import { MENU_ITEM_TYPE } from "../interface/MenuItem";
|
import { MENU_ITEM_TYPE } from "../interface/MenuItem";
|
||||||
import ClassName from "../container/ClassName";
|
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 { ButtonHandler } from "../class/provider/ButtonHandler";
|
||||||
import { Container } from "../container/Container";
|
import { Container } from "../container/Container";
|
||||||
@ -52,7 +51,6 @@ class Test {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async case3() {
|
private async case3() {
|
||||||
CompanyHelper.getInstance().detectNow();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private case4() {
|
private case4() {
|
||||||
@ -65,63 +63,3 @@ export default {
|
|||||||
domText: '🐞 测试2',
|
domText: '🐞 测试2',
|
||||||
clickFunc: () => Container.factory(Test).show(),
|
clickFunc: () => Container.factory(Test).show(),
|
||||||
}
|
}
|
||||||
|
|
||||||
// const Injectable = (): ClassDecorator => target => {
|
|
||||||
// };
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
class OtherServiceC {
|
|
||||||
c = 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
class OtherServiceB {
|
|
||||||
b = 2;
|
|
||||||
|
|
||||||
constructor(private otherServiceC: OtherServiceC) {
|
|
||||||
}
|
|
||||||
|
|
||||||
printC() {
|
|
||||||
Log.info(this.otherServiceC.c)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
class OtherService {
|
|
||||||
a = 1;
|
|
||||||
|
|
||||||
constructor(private otherServiceB: OtherServiceB) {
|
|
||||||
}
|
|
||||||
|
|
||||||
testB() {
|
|
||||||
Log.info(this.otherServiceB.b);
|
|
||||||
this.otherServiceB.printC();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// // @Injectable(INJECT_MODE.Multi)
|
|
||||||
// @Injectable()
|
|
||||||
// class Logger {
|
|
||||||
// constructor(private readonly targetClass: string) {
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// info(str = 'test') {
|
|
||||||
// Log.info(str)
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
@ClassName('TestService')
|
|
||||||
class TestService {
|
|
||||||
constructor(
|
|
||||||
public readonly otherService: OtherService,
|
|
||||||
) {
|
|
||||||
}
|
|
||||||
|
|
||||||
testMethod() {
|
|
||||||
Log.info(this.otherService.a);
|
|
||||||
this.otherService.testB();
|
|
||||||
// this.logger.info()
|
|
||||||
// Log.info(this.test);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@ -1,3 +1,15 @@
|
|||||||
|
<script lang="ts" setup>
|
||||||
|
import { inject } from 'vue';
|
||||||
|
import { LoggerKey, MenuItemListKey } from "../ts/class/IconHelper";
|
||||||
|
import globVars from "../ts/globVars";
|
||||||
|
|
||||||
|
const logger = inject(LoggerKey);
|
||||||
|
const menuItemList = inject(MenuItemListKey);
|
||||||
|
const version = globVars.version;
|
||||||
|
|
||||||
|
const itemHandle = (id) => logger.info(id);
|
||||||
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<button @click=""></button>
|
<button @click=""></button>
|
||||||
@ -13,7 +25,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<p>当前版本: {{ version }}
|
<p>当前版本: {{ version }}
|
||||||
<button id="wh-update-btn">更新</button>
|
<button @click="">更新</button>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div><p>最新版本: <span id="wh-latest-version"></span></p></div>
|
<div><p>最新版本: <span id="wh-latest-version"></span></p></div>
|
||||||
@ -23,25 +35,65 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import MenuItem from "../ts/interface/MenuItem"
|
// import "reflect-metadata";
|
||||||
import Global from "../ts/class/Global";
|
// import Global from "../ts/class/Global";
|
||||||
import Log from "../ts/class/Log";
|
// import { defineComponent, inject } from "vue";
|
||||||
import { defineComponent } from "vue";
|
// import Logger from "../ts/class/Logger";
|
||||||
|
// import MenuItem, { menuItemList } from "../ts/interface/MenuItem";
|
||||||
export default defineComponent({
|
// import { global, logger } from "../ts/class/IconHelper";
|
||||||
name: "Hello",
|
// import { Component, Inject, Vue } from "vue-facing-decorator";
|
||||||
data() {
|
//
|
||||||
return {
|
// // export default defineComponent({
|
||||||
version: Global.getInstance().version,
|
// // export default {
|
||||||
menuItemList: <MenuItem[]>[],
|
// // // inject: ['_logger', '_global', '_menuItemList'],
|
||||||
}
|
// // inject: {
|
||||||
},
|
// // // _logger: {
|
||||||
methods: {
|
// // // from: logger,
|
||||||
itemHandle(id: string) {
|
// // // default: {},
|
||||||
Log.info(id);
|
// // // },
|
||||||
}
|
// // // global: {
|
||||||
}
|
// // // from: global,
|
||||||
})
|
// // // },
|
||||||
|
// // _menuItemList: {
|
||||||
|
// // from: menuItemList,
|
||||||
|
// // }
|
||||||
|
// // },
|
||||||
|
// // name: "FloatMenu",
|
||||||
|
// // setup(props) {
|
||||||
|
// // },
|
||||||
|
// // data() {
|
||||||
|
// // return {
|
||||||
|
// // // @ts-ignore
|
||||||
|
// // // logger: this._logger,
|
||||||
|
// // // global: this._global as unknown as Global,
|
||||||
|
// // // menuItemList: this.menuItemList,
|
||||||
|
// // menuItemList: this._menuItemList,
|
||||||
|
// // // version: this.inject.global.version,
|
||||||
|
// // }
|
||||||
|
// // },
|
||||||
|
// // methods: {
|
||||||
|
// // itemHandle(id: string) {
|
||||||
|
// // // this.logger.info(id);
|
||||||
|
// // }
|
||||||
|
// // },
|
||||||
|
// // mounted() {
|
||||||
|
// // // @ts-ignore
|
||||||
|
// // console.warn('123123123', this.menuItemList)
|
||||||
|
// // console.warn('123123123', this._menuItemList)
|
||||||
|
// // }
|
||||||
|
// // }
|
||||||
|
// @Component({})
|
||||||
|
// export default class A extends Vue{
|
||||||
|
// @Inject
|
||||||
|
// readonly logger!:Logger;
|
||||||
|
// @Inject
|
||||||
|
// readonly menuItemList!:MenuItem[];
|
||||||
|
// @Inject
|
||||||
|
// readonly global!:Global;
|
||||||
|
//
|
||||||
|
// version = this.global.version;
|
||||||
|
// }
|
||||||
|
export default {};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user