TS重构
This commit is contained in:
parent
17c295c13e
commit
c1ba5c04ec
@ -1,9 +1,9 @@
|
|||||||
import BuyBeer, { BeerMonitorLoop } from "../func/utils/BuyBeer";
|
import BuyBeer, { BeerMonitorLoop } from "../func/utils/BuyBeer";
|
||||||
import Device from "../enum/Device";
|
import Device from "../enum/Device";
|
||||||
import getPlayerInfo from "../func/utils/getPlayerInfo";
|
|
||||||
import WindowActiveState from "../func/utils/WindowActiveState";
|
import WindowActiveState from "../func/utils/WindowActiveState";
|
||||||
import WuhuBase from "./WuhuBase";
|
import WuhuBase from "./WuhuBase";
|
||||||
import IGlobal from "../interface/IGlobal";
|
import IGlobal from "../interface/IGlobal";
|
||||||
|
import Utils from "./Utils";
|
||||||
|
|
||||||
export default class Global extends WuhuBase implements IGlobal {
|
export default class Global extends WuhuBase implements IGlobal {
|
||||||
GM_xmlhttpRequest: Function = null;
|
GM_xmlhttpRequest: Function = null;
|
||||||
@ -53,7 +53,7 @@ export default class Global extends WuhuBase implements IGlobal {
|
|||||||
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 = getPlayerInfo();
|
this.player_info = Utils.getPlayerInfo();
|
||||||
this.beer = BuyBeer();
|
this.beer = BuyBeer();
|
||||||
this.popup_node = null;
|
this.popup_node = null;
|
||||||
this.notifies = { count: 0 };
|
this.notifies = { count: 0 };
|
||||||
|
|||||||
@ -1,13 +1,13 @@
|
|||||||
|
|
||||||
import UserScriptEngine from "../enum/UserScriptEngine";
|
import UserScriptEngine from "../enum/UserScriptEngine";
|
||||||
import log from "../func/utils/log";
|
|
||||||
import Global from "./Global";
|
|
||||||
import WuhuBase from "./WuhuBase";
|
import WuhuBase from "./WuhuBase";
|
||||||
|
import Log from "./Log";
|
||||||
|
import Device from "../enum/Device";
|
||||||
|
import ISidebarData from "../interface/ISidebarData";
|
||||||
|
import IWHSettings from "../interface/IWHSettings";
|
||||||
|
|
||||||
export default class Utils extends WuhuBase {
|
export default class Utils extends WuhuBase {
|
||||||
static getScriptEngine() {
|
static getScriptEngine() {
|
||||||
// let glob = WuHuTornHelper.getGlob();
|
let glob = WuhuBase.glob;
|
||||||
let glob = Global.glob;
|
|
||||||
return glob.unsafeWindow ? UserScriptEngine.GM : glob.isPDA
|
return glob.unsafeWindow ? UserScriptEngine.GM : glob.isPDA
|
||||||
? UserScriptEngine.PDA : UserScriptEngine.RAW;
|
? UserScriptEngine.PDA : UserScriptEngine.RAW;
|
||||||
}
|
}
|
||||||
@ -26,26 +26,26 @@ export default class Utils extends WuhuBase{
|
|||||||
// get
|
// get
|
||||||
if (method === 'get') {
|
if (method === 'get') {
|
||||||
if (typeof PDA_httpGet !== 'function') {
|
if (typeof PDA_httpGet !== 'function') {
|
||||||
log.error('COFetch网络错误:PDA版本不支持');
|
Log.error('COFetch网络错误:PDA版本不支持');
|
||||||
reject('COFetch网络错误:PDA版本不支持');
|
reject('COFetch网络错误:PDA版本不支持');
|
||||||
}
|
}
|
||||||
PDA_httpGet(url)
|
PDA_httpGet(url)
|
||||||
.then(res => resolve(res.responseText))
|
.then(res => resolve(res.responseText))
|
||||||
.catch(e => {
|
.catch(e => {
|
||||||
log.error('COFetch网络错误', e);
|
Log.error('COFetch网络错误', e);
|
||||||
reject(`COFetch网络错误 ${ e }`);
|
reject(`COFetch网络错误 ${ e }`);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
// post
|
// post
|
||||||
else {
|
else {
|
||||||
if (typeof PDA_httpPost !== 'function') {
|
if (typeof PDA_httpPost !== 'function') {
|
||||||
log.error('COFetch网络错误:PDA版本不支持');
|
Log.error('COFetch网络错误:PDA版本不支持');
|
||||||
reject('COFetch网络错误:PDA版本不支持');
|
reject('COFetch网络错误:PDA版本不支持');
|
||||||
}
|
}
|
||||||
PDA_httpPost(url, { 'content-type': 'application/json' }, body)
|
PDA_httpPost(url, { 'content-type': 'application/json' }, body)
|
||||||
.then(res => resolve(res.responseText))
|
.then(res => resolve(res.responseText))
|
||||||
.catch(e => {
|
.catch(e => {
|
||||||
log.error('COFetch网络错误', e);
|
Log.error('COFetch网络错误', e);
|
||||||
reject(`COFetch网络错误 ${ e }`);
|
reject(`COFetch网络错误 ${ e }`);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -54,7 +54,7 @@ export default class Utils extends WuhuBase{
|
|||||||
case UserScriptEngine.GM: {
|
case UserScriptEngine.GM: {
|
||||||
let { GM_xmlhttpRequest } = window;
|
let { GM_xmlhttpRequest } = window;
|
||||||
if (typeof GM_xmlhttpRequest !== 'function') {
|
if (typeof GM_xmlhttpRequest !== 'function') {
|
||||||
log.error('COFetch网络错误:用户脚本扩展API错误');
|
Log.error('COFetch网络错误:用户脚本扩展API错误');
|
||||||
reject('错误:用户脚本扩展API错误');
|
reject('错误:用户脚本扩展API错误');
|
||||||
}
|
}
|
||||||
GM_xmlhttpRequest({
|
GM_xmlhttpRequest({
|
||||||
@ -70,4 +70,83 @@ export default class Utils extends WuhuBase{
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回玩家信息的对象 { playername: string, userID: number }
|
||||||
|
* @return {PlayerInfo} rs
|
||||||
|
*/
|
||||||
|
static getPlayerInfo(): PlayerInfo {
|
||||||
|
const node = document.querySelector('script[uid]');
|
||||||
|
if (node) return {
|
||||||
|
playername: node.getAttribute('name'),
|
||||||
|
userID: node.getAttribute('uid') as unknown as number,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 用户设备类型 对应PC MOBILE TABLET
|
||||||
|
static getDeviceType(): Device {
|
||||||
|
return window.innerWidth >= 1000
|
||||||
|
? Device.PC : window.innerWidth <= 600 ? Device.MOBILE : Device.TABLET;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 得到一个两数之间的随机整数
|
||||||
|
static getRandomInt(min: number, max: number): number {
|
||||||
|
min = Math.ceil(min);
|
||||||
|
max = Math.floor(max);
|
||||||
|
//不含最大值,含最小值
|
||||||
|
return Math.floor(Math.random() * (max - min)) + min;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 等待毫秒数
|
||||||
|
* @param {Number} ms 毫秒
|
||||||
|
* @returns {Promise<void>}
|
||||||
|
*/
|
||||||
|
static sleep(ms) {
|
||||||
|
let time = Math.max(ms, 10);
|
||||||
|
return new Promise(resolve => setTimeout(() => resolve(null), time));
|
||||||
|
}
|
||||||
|
|
||||||
|
static getSessionData(): Promise<ISidebarData> {
|
||||||
|
let field: string = 'sidebarData' + this.getPlayerInfo().userID;
|
||||||
|
let ret: ISidebarData = {};
|
||||||
|
return new Promise(async resolve => {
|
||||||
|
let c = 0;
|
||||||
|
while (!sessionStorage.getItem(field) && c < 50) {
|
||||||
|
c++;
|
||||||
|
await this.sleep(10);
|
||||||
|
}
|
||||||
|
ret = JSON.parse(sessionStorage.getItem(field));
|
||||||
|
ret.headerData = JSON.parse(sessionStorage.getItem('headerData'));
|
||||||
|
resolve(ret);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
static async getSidebarData() {
|
||||||
|
return (await this.getSessionData()).areas;
|
||||||
|
}
|
||||||
|
|
||||||
|
static async getUserState() {
|
||||||
|
return (await this.getSessionData()).headerData.user.state;
|
||||||
|
}
|
||||||
|
|
||||||
|
static getWhSettingObj(): IWHSettings {
|
||||||
|
return JSON.parse(localStorage.getItem('wh_trans_settings')) || {}
|
||||||
|
}
|
||||||
|
|
||||||
|
static getYaoCD(): string {
|
||||||
|
if (document.querySelector("#icon49-sidebar")) { // 0-10min
|
||||||
|
return '<10分'
|
||||||
|
} else if (document.querySelector("#icon50-sidebar")) { // 10min-1h
|
||||||
|
return '<1时'
|
||||||
|
} else if (document.querySelector("#icon51-sidebar")) { // 1h-2h
|
||||||
|
return '1~2时'
|
||||||
|
} else if (document.querySelector("#icon52-sidebar")) { // 2h-5h
|
||||||
|
return '2~5时'
|
||||||
|
} else if (document.querySelector("#icon53-sidebar")) { // 5h+
|
||||||
|
return '>5时'
|
||||||
|
} else {
|
||||||
|
return '无效'
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
0
src/class/provider/Provider.ts
Normal file
0
src/class/provider/Provider.ts
Normal file
@ -6,7 +6,8 @@ import attackHelper from "./func/module/attackHelper";
|
|||||||
import priceWatcherHandle from "./func/module/priceWatcherHandle";
|
import priceWatcherHandle from "./func/module/priceWatcherHandle";
|
||||||
import WuhuBase from "./class/WuhuBase";
|
import WuhuBase from "./class/WuhuBase";
|
||||||
|
|
||||||
export default function () {
|
export class Common extends WuhuBase {
|
||||||
|
static resolve() {
|
||||||
let glob = WuhuBase.glob;
|
let glob = WuhuBase.glob;
|
||||||
// 价格监控
|
// 价格监控
|
||||||
priceWatcherHandle(glob.isPDA, glob.PDA_APIKey);
|
priceWatcherHandle(glob.isPDA, glob.PDA_APIKey);
|
||||||
@ -78,3 +79,4 @@ export default function () {
|
|||||||
// 战斗相关
|
// 战斗相关
|
||||||
attackHelper().then();
|
attackHelper().then();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
@ -1,7 +1,7 @@
|
|||||||
import getPlayerInfo from "../utils/getPlayerInfo";
|
|
||||||
import popupMsg from "../utils/popupMsg";
|
import popupMsg from "../utils/popupMsg";
|
||||||
import WHNotify from "../utils/WHNotify";
|
import WHNotify from "../utils/WHNotify";
|
||||||
import log from "../utils/log";
|
import log from "../utils/log";
|
||||||
|
import Utils from "../../class/Utils";
|
||||||
|
|
||||||
// 守望者
|
// 守望者
|
||||||
export default function safeKeeper() {
|
export default function safeKeeper() {
|
||||||
@ -116,5 +116,5 @@ export default function safeKeeper() {
|
|||||||
loop_id = null;
|
loop_id = null;
|
||||||
p.innerHTML = '状态:已关 ❎';
|
p.innerHTML = '状态:已关 ❎';
|
||||||
});
|
});
|
||||||
self_target.addEventListener('click', () => uid.value = (getPlayerInfo()['userID']) + '');
|
self_target.addEventListener('click', () => uid.value = (Utils.getPlayerInfo()['userID']) + '');
|
||||||
}
|
}
|
||||||
@ -4,7 +4,7 @@ import WHNotify from "./WHNotify";
|
|||||||
import getRandomInt from "./getRandomInt";
|
import getRandomInt from "./getRandomInt";
|
||||||
import setWhSetting from "./setWhSetting";
|
import setWhSetting from "./setWhSetting";
|
||||||
import audioPlay from "./audioPlay";
|
import audioPlay from "./audioPlay";
|
||||||
import getUserState from "./getUserState";
|
import Utils from "../../class/Utils";
|
||||||
|
|
||||||
// 啤酒
|
// 啤酒
|
||||||
export default function BuyBeer() {
|
export default function BuyBeer() {
|
||||||
@ -19,9 +19,9 @@ export default function BuyBeer() {
|
|||||||
log.info('啤酒助手已在运行');
|
log.info('啤酒助手已在运行');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
started = setInterval(() => {
|
started = setInterval(async () => {
|
||||||
// 海外取消提醒
|
// 海外取消提醒
|
||||||
let { isTravelling, isAbroad } = getUserState();
|
let { isTravelling, isAbroad } = await Utils.getUserState();
|
||||||
if (isTravelling || isAbroad) {
|
if (isTravelling || isAbroad) {
|
||||||
loop.stop();
|
loop.stop();
|
||||||
return;
|
return;
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
import Device from "../../enum/Device";
|
import Device from "../../enum/Device";
|
||||||
|
|
||||||
// 用户设备类型 对应PC MOBILE TABLET
|
/**
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
export default function getDeviceType() {
|
export default function getDeviceType() {
|
||||||
return window.innerWidth >= 1000
|
return window.innerWidth >= 1000
|
||||||
? Device.PC : window.innerWidth <= 600 ? Device.MOBILE : Device.TABLET;
|
? Device.PC : window.innerWidth <= 600 ? Device.MOBILE : Device.TABLET;
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* 返回玩家信息的对象 user
|
* 返回玩家信息的对象 user
|
||||||
|
* @deprecated
|
||||||
* @return {PlayerInfo} rs
|
* @return {PlayerInfo} rs
|
||||||
*/
|
*/
|
||||||
export default function getPlayerInfo(): PlayerInfo {
|
export default function getPlayerInfo(): PlayerInfo {
|
||||||
|
|||||||
@ -1,4 +1,8 @@
|
|||||||
// 得到一个两数之间的随机整数
|
/**
|
||||||
|
* @deprecated
|
||||||
|
* @param min
|
||||||
|
* @param max
|
||||||
|
*/
|
||||||
export default function getRandomInt(min: number, max: number): number {
|
export default function getRandomInt(min: number, max: number): number {
|
||||||
min = Math.ceil(min);
|
min = Math.ceil(min);
|
||||||
max = Math.floor(max);
|
max = Math.floor(max);
|
||||||
|
|||||||
@ -1,7 +1,9 @@
|
|||||||
import UserScriptEngine from "../../enum/UserScriptEngine";
|
import UserScriptEngine from "../../enum/UserScriptEngine";
|
||||||
import WuhuBase from "../../class/WuhuBase";
|
import WuhuBase from "../../class/WuhuBase";
|
||||||
|
|
||||||
// 用户脚本平台类型
|
/**
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
export default function getScriptEngine() {
|
export default function getScriptEngine() {
|
||||||
let glob = WuhuBase.glob;
|
let glob = WuhuBase.glob;
|
||||||
return glob.unsafeWindow ? UserScriptEngine.GM : glob.isPDA
|
return glob.unsafeWindow ? UserScriptEngine.GM : glob.isPDA
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import log from "./log";
|
|||||||
/**
|
/**
|
||||||
* 边栏信息
|
* 边栏信息
|
||||||
* @deprecated
|
* @deprecated
|
||||||
* @returns {any}
|
* @returns {unknown}
|
||||||
*/
|
*/
|
||||||
export default async function getSidebarData() {
|
export default async function getSidebarData() {
|
||||||
let ret = {};
|
let ret = {};
|
||||||
|
|||||||
@ -1,4 +1,6 @@
|
|||||||
// 玩家状态
|
/**
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
export default function getUserState(): {} | any {
|
export default function getUserState(): {} | any {
|
||||||
let obj = {};
|
let obj = {};
|
||||||
let hdd = sessionStorage['headerData'];
|
let hdd = sessionStorage['headerData'];
|
||||||
|
|||||||
@ -1,8 +1,11 @@
|
|||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
export default function getWhSettingObj(): WHSettings {
|
export default function getWhSettingObj(): WHSettings {
|
||||||
return JSON.parse(localStorage.getItem('wh_trans_settings')) || {}
|
return JSON.parse(localStorage.getItem('wh_trans_settings')) || {}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface WHSettings {
|
interface WHSettings {
|
||||||
// TODO 补全
|
// TODO 补全
|
||||||
[key: string]: any;
|
[key: string]: any;
|
||||||
}
|
}
|
||||||
@ -1,4 +1,6 @@
|
|||||||
// 药cd
|
/**
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
export default function getYaoCD(): string {
|
export default function getYaoCD(): string {
|
||||||
if (document.querySelector("#icon49-sidebar")) { // 0-10min
|
if (document.querySelector("#icon49-sidebar")) { // 0-10min
|
||||||
return '<10分'
|
return '<10分'
|
||||||
|
|||||||
@ -1,8 +0,0 @@
|
|||||||
/**
|
|
||||||
* 等待毫秒数
|
|
||||||
* @param {Number} ms 毫秒
|
|
||||||
* @returns {Promise<unknown>}
|
|
||||||
*/
|
|
||||||
export default function sleep(ms) {
|
|
||||||
return new Promise(resolve => setTimeout(() => resolve(null), ms));
|
|
||||||
}
|
|
||||||
108
src/interface/ISidebarData.ts
Normal file
108
src/interface/ISidebarData.ts
Normal file
@ -0,0 +1,108 @@
|
|||||||
|
export default interface ISidebarData {
|
||||||
|
// TODO 补全
|
||||||
|
statusIcons?: unknown;
|
||||||
|
user?: {
|
||||||
|
userID: number,
|
||||||
|
name: string,
|
||||||
|
link: string,
|
||||||
|
money: {
|
||||||
|
value: number,
|
||||||
|
},
|
||||||
|
donator: boolean,
|
||||||
|
level: {
|
||||||
|
value: number,
|
||||||
|
upgradePossibility: boolean,
|
||||||
|
link: string,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
bars?: {
|
||||||
|
energy: Bar,
|
||||||
|
nerve: Bar,
|
||||||
|
happy: Bar,
|
||||||
|
life: Bar,
|
||||||
|
chain: Bar,
|
||||||
|
};
|
||||||
|
areas?: {
|
||||||
|
[area: string]: Area
|
||||||
|
}
|
||||||
|
headerData?: HeaderData;
|
||||||
|
|
||||||
|
[key: string]: unknown;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Area {
|
||||||
|
"name": string,
|
||||||
|
"shortName": string,
|
||||||
|
"link": string,
|
||||||
|
"icon": string,
|
||||||
|
"styleStatus": string,
|
||||||
|
"linkOrder": number,
|
||||||
|
"highlightStatus": unknown,
|
||||||
|
"status": unknown,
|
||||||
|
"favorite": boolean,
|
||||||
|
"added": unknown,
|
||||||
|
"amount": unknown
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Bar {
|
||||||
|
"name": string,
|
||||||
|
"timeToUpdate": number,
|
||||||
|
"amount": number,
|
||||||
|
"max": number,
|
||||||
|
"step": number,
|
||||||
|
"coolDown"?: number,
|
||||||
|
"endCoolDownTimestamp"?: number,
|
||||||
|
"timestampToUpdate": number,
|
||||||
|
"bonuses"?: number,
|
||||||
|
"link"?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
interface HeaderData {
|
||||||
|
"user": {
|
||||||
|
"state": {
|
||||||
|
"status": "ok"|string,
|
||||||
|
"isLoggedIn": boolean,
|
||||||
|
"isDonator": boolean,
|
||||||
|
"isTravelling": boolean,
|
||||||
|
"isAbroad": boolean
|
||||||
|
},
|
||||||
|
"data": {
|
||||||
|
"hospitalStamp": number,
|
||||||
|
"jailStamp": number,
|
||||||
|
"logoutHash": string,
|
||||||
|
"userID": number,
|
||||||
|
"avatar": {
|
||||||
|
"isDefault": false,
|
||||||
|
"link": string
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"serverState": {
|
||||||
|
"serverName": string,
|
||||||
|
"currentTime": number
|
||||||
|
},
|
||||||
|
"settings": {
|
||||||
|
"emptyHeader": boolean,
|
||||||
|
"emptyLinks": boolean,
|
||||||
|
"hideActivityLog": boolean,
|
||||||
|
"hideAdvancedSearch": boolean,
|
||||||
|
"hideSettingsDropdown": boolean,
|
||||||
|
"hasAccessToDarkMode": boolean
|
||||||
|
},
|
||||||
|
"logo": {
|
||||||
|
"name": string,
|
||||||
|
"title": string,
|
||||||
|
"country": string,
|
||||||
|
"darkModeLogo": string,
|
||||||
|
"additionalData": unknown[]
|
||||||
|
},
|
||||||
|
"links": Link[],
|
||||||
|
"headlines": unknown
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Link {
|
||||||
|
"name": string,
|
||||||
|
"link": string,
|
||||||
|
"icon": string,
|
||||||
|
"inNewTab": boolean
|
||||||
|
}
|
||||||
4
src/interface/IWHSettings.ts
Normal file
4
src/interface/IWHSettings.ts
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
export default interface IWHSettings {
|
||||||
|
// TODO 补全
|
||||||
|
[key: string]: any;
|
||||||
|
}
|
||||||
@ -1,10 +1,10 @@
|
|||||||
import getWhSettingObj from "./func/utils/getWhSettingObj";
|
import getWhSettingObj from "./func/utils/getWhSettingObj";
|
||||||
import translateMain from "./func/translate/translateMain";
|
import translateMain from "./func/translate/translateMain";
|
||||||
import common from "./common";
|
import { Common } from "./common";
|
||||||
import urlMatch from "./urlMatch";
|
|
||||||
import WuHuTornHelper from "./class/WuhuTornHelper";
|
import WuHuTornHelper from "./class/WuhuTornHelper";
|
||||||
import ZhongIcon from "./class/ZhongIcon";
|
import ZhongIcon from "./class/ZhongIcon";
|
||||||
import WuhuBase from "./class/WuhuBase";
|
import WuhuBase from "./class/WuhuBase";
|
||||||
|
import UrlPattern from "./urlMatch";
|
||||||
|
|
||||||
(function main() {
|
(function main() {
|
||||||
let started = new Date().getTime();
|
let started = new Date().getTime();
|
||||||
@ -20,9 +20,9 @@ import WuhuBase from "./class/WuhuBase";
|
|||||||
|
|
||||||
if (getWhSettingObj()['transEnable']) translateMain(glob.href);
|
if (getWhSettingObj()['transEnable']) translateMain(glob.href);
|
||||||
|
|
||||||
common();
|
Common.resolve();
|
||||||
|
|
||||||
urlMatch().then();
|
UrlPattern.resolve();
|
||||||
|
|
||||||
let runTime = new Date().getTime() - started;
|
let runTime = new Date().getTime() - started;
|
||||||
ZhongIcon.ZhongNode.initTimer.innerHTML = `助手加载时间 ${ runTime }ms`;
|
ZhongIcon.ZhongNode.initTimer.innerHTML = `助手加载时间 ${ runTime }ms`;
|
||||||
|
|||||||
@ -3,24 +3,22 @@ import cityFinder from "./func/module/cityFinder";
|
|||||||
import WHNotify from "./func/utils/WHNotify";
|
import WHNotify from "./func/utils/WHNotify";
|
||||||
import elementReady from "./func/utils/elementReady";
|
import elementReady from "./func/utils/elementReady";
|
||||||
import setWhSetting from "./func/utils/setWhSetting";
|
import setWhSetting from "./func/utils/setWhSetting";
|
||||||
import log from "./func/utils/log";
|
|
||||||
import { missionDict } from "./dictionary/translation";
|
import { missionDict } from "./dictionary/translation";
|
||||||
import getTaskHint from "./func/translate/getTaskHint";
|
import getTaskHint from "./func/translate/getTaskHint";
|
||||||
import getPlayerInfo from "./func/utils/getPlayerInfo";
|
|
||||||
import Device from "./enum/Device";
|
import Device from "./enum/Device";
|
||||||
import getSidebarData from "./func/utils/getSidebarData";
|
import getSidebarData from "./func/utils/getSidebarData";
|
||||||
import getDeviceType from "./func/utils/getDeviceType";
|
import getDeviceType from "./func/utils/getDeviceType";
|
||||||
import addStyle from "./func/utils/addStyle";
|
import addStyle from "./func/utils/addStyle";
|
||||||
import WuHuTornHelper from "./class/WuhuTornHelper";
|
|
||||||
import WuhuBase from "./class/WuhuBase";
|
import WuhuBase from "./class/WuhuBase";
|
||||||
|
import Utils from "./class/Utils";
|
||||||
|
import Log from "./class/Log";
|
||||||
|
|
||||||
class UrlPattern extends WuhuBase {
|
export default class UrlPattern extends WuhuBase {
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
export default async function urlMatch() {
|
static resolve() {
|
||||||
let { href, beer } = WuhuBase.glob;
|
let { href, beer } = WuhuBase.glob;
|
||||||
// 捡垃圾助手
|
// 捡垃圾助手
|
||||||
if (href.includes('city.php') && getWhSettingObj()['cityFinder']) {
|
if (href.includes('city.php') && getWhSettingObj()['cityFinder']) {
|
||||||
@ -164,7 +162,7 @@ $<span class="total">1,000</span>
|
|||||||
});
|
});
|
||||||
// 监听啤酒购买
|
// 监听啤酒购买
|
||||||
$(document).ajaxComplete((_, xhr, settings) => {
|
$(document).ajaxComplete((_, xhr, settings) => {
|
||||||
log.info({ xhr, settings });
|
Log.info({ xhr, settings });
|
||||||
let { data } = settings, { responseText } = xhr;
|
let { data } = settings, { responseText } = xhr;
|
||||||
let response = JSON.parse(responseText);
|
let response = JSON.parse(responseText);
|
||||||
if (data.includes('step=buyShopItem') && data.includes('ID=180') && response['success']) {
|
if (data.includes('step=buyShopItem') && data.includes('ID=180') && response['success']) {
|
||||||
@ -622,7 +620,12 @@ margin: 0 0 3px;
|
|||||||
if (xmasTownNotify) {
|
if (xmasTownNotify) {
|
||||||
const chestTypeDict = { '1': '金', '2': '银', '3': '铜', };
|
const chestTypeDict = { '1': '金', '2': '银', '3': '铜', };
|
||||||
const chestTypeColorDict = { '1': 'gold', '2': 'silver', '3': 'sandybrown', };
|
const chestTypeColorDict = { '1': 'gold', '2': 'silver', '3': 'sandybrown', };
|
||||||
const lootTypeDict = { 'chests': '钥匙箱', 'gifts': '礼物', 'combinationChest': '密码箱', 'keys': '钥匙', };
|
const lootTypeDict = {
|
||||||
|
'chests': '钥匙箱',
|
||||||
|
'gifts': '礼物',
|
||||||
|
'combinationChest': '密码箱',
|
||||||
|
'keys': '钥匙',
|
||||||
|
};
|
||||||
const keyTypeDict = { 'b': '铜', 's': '银', 'g': '金', };
|
const keyTypeDict = { 'b': '铜', 's': '银', 'g': '金', };
|
||||||
let dropHist = localStorage.getItem('wh-loot-store')
|
let dropHist = localStorage.getItem('wh-loot-store')
|
||||||
? JSON.parse(localStorage.getItem('wh-loot-store'))
|
? JSON.parse(localStorage.getItem('wh-loot-store'))
|
||||||
@ -921,12 +924,12 @@ margin: 0 0 3px;
|
|||||||
};
|
};
|
||||||
addEventListener('hashchange', rw_raider);
|
addEventListener('hashchange', rw_raider);
|
||||||
|
|
||||||
await rw_raider();
|
rw_raider().then();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 特定代码块
|
// 特定代码块
|
||||||
if (getPlayerInfo()['userID'] === 2687093 && getDeviceType() === Device.PC) {
|
if (Utils.getPlayerInfo()['userID'] === 2687093 && getDeviceType() === Device.PC) {
|
||||||
await getSidebarData();
|
getSidebarData().then(() => {
|
||||||
let item = document.getElementById('nav-items');
|
let item = document.getElementById('nav-items');
|
||||||
if (item) {
|
if (item) {
|
||||||
let copy = item.cloneNode(true);
|
let copy = item.cloneNode(true);
|
||||||
@ -940,5 +943,7 @@ margin: 0 0 3px;
|
|||||||
span.style.color = 'white';
|
span.style.color = 'white';
|
||||||
item.after(copy);
|
item.after(copy);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user