79 lines
2.7 KiB
TypeScript
79 lines
2.7 KiB
TypeScript
import depoHelper from "../func/module/depoHelper";
|
|
import travelHelper from "../func/module/travelHelper";
|
|
import priceWatcherHandle from "../func/module/priceWatcherHandle";
|
|
import WuhuBase from "./WuhuBase";
|
|
import WuhuConfig from "./WuhuConfig";
|
|
import CompanyHelper from "./action/CompanyHelper";
|
|
import AttackHelper from "./action/AttackHelper";
|
|
import SidebarHelper from "./action/SidebarHelper";
|
|
import CommonUtils from "./utils/CommonUtils";
|
|
import Log from "./Log";
|
|
import FetchUtils from "./utils/FetchUtils";
|
|
|
|
export class Common extends WuhuBase {
|
|
className = 'Common';
|
|
|
|
public resolve(mainMethod) {
|
|
let glob = Common.glob;
|
|
// 价格监控
|
|
priceWatcherHandle(glob.isPDA, glob.PDA_APIKey);
|
|
|
|
// 啤酒提醒
|
|
if (WuhuConfig.get('_15Alarm')) glob.beer.start();
|
|
|
|
SidebarHelper.getInstance();
|
|
|
|
/**
|
|
* 解决一直转圈(加载中)的问题
|
|
* All('script[src*="google"]')
|
|
* All('#gtm_tag')
|
|
* All('script[src*="chat/gonline"]')
|
|
* All('head script[nonce]')
|
|
*/
|
|
if (document.readyState === 'interactive' && WuhuConfig.get('SolveGoogleScriptPendingIssue')) {
|
|
window.stop();
|
|
document.open();
|
|
document.addEventListener('readystatechange', function readyStateChangeHandler() {
|
|
Log.info('document.readyState', document.readyState);
|
|
if (document.readyState === 'complete') {
|
|
document.removeEventListener('readystatechange', readyStateChangeHandler);
|
|
mainMethod();
|
|
throw new Error('页面已重载');
|
|
}
|
|
});
|
|
FetchUtils.getInstance().fetchText(window.location.href).then(resp => {
|
|
let removed = resp;
|
|
[
|
|
/<script id="gtm_tag">.+?<\/script>/ms,
|
|
/<script async src="https:\/\/www\.google.+?<\/script>/ms,
|
|
/<script nonce=".+?gtag.+?<\/script>/ms,
|
|
/<script.+?google.+?\/script>/,
|
|
].forEach(remove => {
|
|
removed = removed.replace(remove, '');
|
|
});
|
|
Log.info({ removed });
|
|
document.write(removed);
|
|
document.close();
|
|
});
|
|
}
|
|
|
|
// 存钱相关
|
|
depoHelper();
|
|
|
|
// 飞行相关
|
|
travelHelper().then();
|
|
|
|
// 战斗相关
|
|
AttackHelper.getInstance();
|
|
|
|
// 公司助手
|
|
CompanyHelper.getInstance();
|
|
|
|
// 自定义CSS
|
|
if (WuhuConfig.get('CustomCss')) {
|
|
Log.info('应用自定义CSS');
|
|
CommonUtils.addStyle(WuhuConfig.get('CustomCss'));
|
|
}
|
|
}
|
|
}
|