TS重构
This commit is contained in:
parent
7d494b8757
commit
17c295c13e
7
.idea/dictionaries/Liwanyi.xml
generated
Normal file
7
.idea/dictionaries/Liwanyi.xml
generated
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<component name="ProjectDictionaryState">
|
||||||
|
<dictionary name="Liwanyi">
|
||||||
|
<words>
|
||||||
|
<w>wuhu</w>
|
||||||
|
</words>
|
||||||
|
</dictionary>
|
||||||
|
</component>
|
||||||
7
global.d.ts
vendored
7
global.d.ts
vendored
@ -2,14 +2,15 @@ declare interface String {
|
|||||||
contains(keywords: RegExp | string): boolean;
|
contains(keywords: RegExp | string): boolean;
|
||||||
|
|
||||||
/* 翻译 */
|
/* 翻译 */
|
||||||
|
|
||||||
// 时分秒转换
|
// 时分秒转换
|
||||||
replaceHMS(): string;
|
replaceHMS(): string;
|
||||||
|
|
||||||
// 数词转换 a an some
|
// 数词转换 a an some
|
||||||
numWordTrans(): string;
|
numWordTrans(): string;
|
||||||
}
|
}
|
||||||
|
|
||||||
declare interface Window {
|
declare interface Window {
|
||||||
unsafeWindow?: Window & typeof globalThis;
|
|
||||||
$?: JQueryStatic;
|
$?: JQueryStatic;
|
||||||
jQuery?: JQueryStatic;
|
jQuery?: JQueryStatic;
|
||||||
WHPARAMS?: any;
|
WHPARAMS?: any;
|
||||||
@ -28,6 +29,8 @@ declare interface Window {
|
|||||||
|
|
||||||
initMiniProf(selector: string): void;
|
initMiniProf(selector: string): void;
|
||||||
|
|
||||||
|
initializeTooltip(selector: string, elemId: string): void;
|
||||||
|
|
||||||
renderMiniProfile(node: Element, props: any);
|
renderMiniProfile(node: Element, props: any);
|
||||||
|
|
||||||
/* PDA自带 */
|
/* PDA自带 */
|
||||||
@ -36,6 +39,8 @@ declare interface Window {
|
|||||||
PDA_httpPost(url: URL | string, init: any, body: any): Promise<PDA_Response>;
|
PDA_httpPost(url: URL | string, init: any, body: any): Promise<PDA_Response>;
|
||||||
|
|
||||||
/* 油猴脚本引擎自带 */
|
/* 油猴脚本引擎自带 */
|
||||||
|
unsafeWindow?: Window & typeof globalThis;
|
||||||
|
|
||||||
GM_xmlhttpRequest(init: GM_RequestParams);
|
GM_xmlhttpRequest(init: GM_RequestParams);
|
||||||
|
|
||||||
GM_getValue(k: string, def: any): any;
|
GM_getValue(k: string, def: any): any;
|
||||||
|
|||||||
2
package-lock.json
generated
2
package-lock.json
generated
@ -157,7 +157,7 @@
|
|||||||
},
|
},
|
||||||
"typescript": {
|
"typescript": {
|
||||||
"version": "4.8.3",
|
"version": "4.8.3",
|
||||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.8.3.tgz",
|
"resolved": "https://registry.npmmirror.com/typescript/-/typescript-4.8.3.tgz",
|
||||||
"integrity": "sha512-goMHfm00nWPa8UvR/CPSvykqf6dVV8x/dp0c5mFTMTIu0u0FlGWRioyy7Nn0PGAdHxpJZnuO/ut+PpQ8UiHAig==",
|
"integrity": "sha512-goMHfm00nWPa8UvR/CPSvykqf6dVV8x/dp0c5mFTMTIu0u0FlGWRioyy7Nn0PGAdHxpJZnuO/ut+PpQ8UiHAig==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
|||||||
@ -8,7 +8,8 @@
|
|||||||
"release": "npm run minify && node build.js",
|
"release": "npm run minify && node build.js",
|
||||||
"minify": "uglifyjs wuhu-torn-helper.js -o release.min.user.js -m",
|
"minify": "uglifyjs wuhu-torn-helper.js -o release.min.user.js -m",
|
||||||
"serve": "",
|
"serve": "",
|
||||||
"build": "rollup -c"
|
"build": "rollup -c",
|
||||||
|
"compile": "tsc --outDir output"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@rollup/plugin-typescript": "^8.5.0",
|
"@rollup/plugin-typescript": "^8.5.0",
|
||||||
|
|||||||
97
src/class/Global.ts
Normal file
97
src/class/Global.ts
Normal file
@ -0,0 +1,97 @@
|
|||||||
|
import BuyBeer, { BeerMonitorLoop } from "../func/utils/BuyBeer";
|
||||||
|
import Device from "../enum/Device";
|
||||||
|
import getPlayerInfo from "../func/utils/getPlayerInfo";
|
||||||
|
import WindowActiveState from "../func/utils/WindowActiveState";
|
||||||
|
import WuhuBase from "./WuhuBase";
|
||||||
|
import IGlobal from "../interface/IGlobal";
|
||||||
|
|
||||||
|
export default class Global extends WuhuBase implements IGlobal {
|
||||||
|
GM_xmlhttpRequest: Function = null;
|
||||||
|
|
||||||
|
href: string = window.location.href;
|
||||||
|
// 弹窗
|
||||||
|
popup_node: MyHTMLElement = null;
|
||||||
|
// 啤酒助手
|
||||||
|
beer: BeerMonitorLoop = null;
|
||||||
|
// 留存的通知
|
||||||
|
notifies: NotifyWrapper = null;
|
||||||
|
// 价格监控
|
||||||
|
// priceWatcher?: { status: boolean };
|
||||||
|
// 海外库存
|
||||||
|
fStock: { get: () => Promise<any> } = null;
|
||||||
|
// 玩家名和数字id
|
||||||
|
player_info: PlayerInfo = null;
|
||||||
|
// 设备类型
|
||||||
|
device: Device = null;
|
||||||
|
// PDA运行环境
|
||||||
|
isPDA: boolean = false;
|
||||||
|
// PDA自带apikey
|
||||||
|
PDA_APIKey: string = null;
|
||||||
|
// 脚本版本
|
||||||
|
version: string = null;
|
||||||
|
// window 副本
|
||||||
|
window: Window & typeof globalThis = window;
|
||||||
|
unsafeWindow: Window & typeof globalThis = null;
|
||||||
|
// document body 属性
|
||||||
|
bodyAttrs: {
|
||||||
|
'data-country'?: string;
|
||||||
|
'data-celebration'?: string;
|
||||||
|
'data-traveling'?: string;
|
||||||
|
'data-abroad'?: string;
|
||||||
|
// [key: string]: string;
|
||||||
|
} = null;
|
||||||
|
|
||||||
|
// 窗口活动状态
|
||||||
|
isWindowActive = null;
|
||||||
|
|
||||||
|
private constructor() {
|
||||||
|
super();
|
||||||
|
this.window = window;
|
||||||
|
this.unsafeWindow = window.unsafeWindow || null;
|
||||||
|
this.GM_xmlhttpRequest = window.GM_xmlhttpRequest || null;
|
||||||
|
this.version = '$$WUHU_DEV_VERSION$$';
|
||||||
|
this.PDA_APIKey = '###PDA-APIKEY###';
|
||||||
|
this.isPDA = !this.PDA_APIKey.includes('###');
|
||||||
|
this.device = window.innerWidth >= 1000 ? Device.PC : window.innerWidth <= 600 ? Device.MOBILE : Device.TABLET;
|
||||||
|
this.player_info = getPlayerInfo();
|
||||||
|
this.beer = BuyBeer();
|
||||||
|
this.popup_node = null;
|
||||||
|
this.notifies = { count: 0 };
|
||||||
|
this.isWindowActive = WindowActiveState();
|
||||||
|
this.href = window.location.href;
|
||||||
|
this.bodyAttrs = {};
|
||||||
|
|
||||||
|
if (this.unsafeWindow) {
|
||||||
|
try {
|
||||||
|
window = this.unsafeWindow;
|
||||||
|
} catch {
|
||||||
|
this.unsafeWindow = null;
|
||||||
|
this.GM_xmlhttpRequest = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (let i = 0; i < document.body.attributes.length; i++) {
|
||||||
|
let item = document.body.attributes.item(i);
|
||||||
|
this.bodyAttrs[item.name] = item.value;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 当窗口关闭时关闭所有还存在的通知
|
||||||
|
window.addEventListener(
|
||||||
|
'beforeunload',
|
||||||
|
() => {
|
||||||
|
if (this.notifies.count !== 0) {
|
||||||
|
for (let i = 0; i < this.notifies.count; i++) {
|
||||||
|
(this.notifies[i] !== null) && (this.notifies[i].close())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static getInstance(this): Global {
|
||||||
|
if (!(<any>this).instance) {
|
||||||
|
(<any>this).instance = new this();
|
||||||
|
}
|
||||||
|
return (<any>this).instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
18
src/class/Log.ts
Normal file
18
src/class/Log.ts
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
import WuhuBase from "./WuhuBase";
|
||||||
|
import getWhSettingObj from "../func/utils/getWhSettingObj";
|
||||||
|
|
||||||
|
export default class Log extends WuhuBase{
|
||||||
|
static info(...o) {
|
||||||
|
return (this.debug()) && (console.log('[WH]', ...o))
|
||||||
|
}
|
||||||
|
static error(...o) {
|
||||||
|
return (this.debug()) && (console.error('[WH]', ...o))
|
||||||
|
}
|
||||||
|
static debug() {
|
||||||
|
try {
|
||||||
|
return getWhSettingObj()['isDev'] || false;
|
||||||
|
} catch {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
24
src/class/TravelItemFetchLoop.ts
Normal file
24
src/class/TravelItemFetchLoop.ts
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
import Utils from "./Utils";
|
||||||
|
import WuhuBase from "./WuhuBase";
|
||||||
|
|
||||||
|
export default class TravelItem extends WuhuBase{
|
||||||
|
obj: any = null;
|
||||||
|
res: any = null;
|
||||||
|
|
||||||
|
async get() {
|
||||||
|
if (!this.obj) {
|
||||||
|
const str = await this.res
|
||||||
|
this.obj = JSON.parse(str);
|
||||||
|
}
|
||||||
|
return this.obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(destination: string) {
|
||||||
|
super();
|
||||||
|
setInterval(async () => {
|
||||||
|
if (!WuhuBase.glob.isWindowActive()) return;
|
||||||
|
const res = await Utils.COFetch(destination);
|
||||||
|
this.obj = JSON.parse(res);
|
||||||
|
}, 30 * 1000);
|
||||||
|
}
|
||||||
|
}
|
||||||
73
src/class/Utils.ts
Normal file
73
src/class/Utils.ts
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
|
||||||
|
import UserScriptEngine from "../enum/UserScriptEngine";
|
||||||
|
import log from "../func/utils/log";
|
||||||
|
import Global from "./Global";
|
||||||
|
import WuhuBase from "./WuhuBase";
|
||||||
|
|
||||||
|
export default class Utils extends WuhuBase{
|
||||||
|
static getScriptEngine() {
|
||||||
|
// let glob = WuHuTornHelper.getGlob();
|
||||||
|
let glob = Global.glob;
|
||||||
|
return glob.unsafeWindow ? UserScriptEngine.GM : glob.isPDA
|
||||||
|
? UserScriptEngine.PDA : UserScriptEngine.RAW;
|
||||||
|
}
|
||||||
|
|
||||||
|
static COFetch(url: URL | string, method: 'get' | 'post' = 'get', body: any = null): Promise<string> {
|
||||||
|
return new Promise<string>((resolve, reject) => {
|
||||||
|
const engine = this.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) }`),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
5
src/class/WuhuBase.ts
Normal file
5
src/class/WuhuBase.ts
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
import IGlobal from "../interface/IGlobal";
|
||||||
|
|
||||||
|
export default class WuhuBase {
|
||||||
|
static glob: IGlobal = null;
|
||||||
|
}
|
||||||
214
src/class/WuhuTornHelper.ts
Normal file
214
src/class/WuhuTornHelper.ts
Normal file
@ -0,0 +1,214 @@
|
|||||||
|
import log from "../func/utils/log";
|
||||||
|
import getWhSettingObj from "../func/utils/getWhSettingObj";
|
||||||
|
import miniprofTrans from "../func/translate/miniprofTrans";
|
||||||
|
import addStyle from "../func/utils/addStyle";
|
||||||
|
import Utils from "./Utils";
|
||||||
|
import WuhuBase from "./WuhuBase";
|
||||||
|
import TravelItem from "./TravelItemFetchLoop";
|
||||||
|
import Global from "./Global";
|
||||||
|
|
||||||
|
export default class WuHuTornHelper extends WuhuBase{
|
||||||
|
|
||||||
|
init() {
|
||||||
|
WuhuBase.glob = Global.getInstance();
|
||||||
|
let glob = WuhuBase.glob;
|
||||||
|
glob.fStock = new TravelItem('https://yata.yt/api/v1/travel/export/');
|
||||||
|
|
||||||
|
// 请求通知权限
|
||||||
|
if (window.Notification && Notification.permission !== 'granted') {
|
||||||
|
Notification.requestPermission().then();
|
||||||
|
} else {
|
||||||
|
log.info({ Notification });
|
||||||
|
}
|
||||||
|
|
||||||
|
// 扩展正则方法
|
||||||
|
String.prototype.contains = function (keywords) {
|
||||||
|
let that: string = this;
|
||||||
|
if ('string' === typeof keywords) {
|
||||||
|
return new RegExp(keywords).test(that);
|
||||||
|
} else {
|
||||||
|
return keywords.test(that);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// 监听fetch
|
||||||
|
const ori_fetch = window.fetch;
|
||||||
|
window.fetch = async (url: string, init: RequestInit) => {
|
||||||
|
if (url.contains('newsTickers')) {
|
||||||
|
// 阻止获取新闻横幅
|
||||||
|
return new Response('{}');
|
||||||
|
}
|
||||||
|
const res = await ori_fetch(url, init);
|
||||||
|
// mini profile 翻译
|
||||||
|
if (url.includes('profiles.php?step=getUserNameContextMenu') && getWhSettingObj()['transEnable']) {
|
||||||
|
setTimeout(() => miniprofTrans(), 200);
|
||||||
|
}
|
||||||
|
let clone = res.clone();
|
||||||
|
let text = await res.text();
|
||||||
|
log.info({ url, init, text });
|
||||||
|
return clone;
|
||||||
|
};
|
||||||
|
|
||||||
|
addStyle(`
|
||||||
|
.wh-hide{display:none;}
|
||||||
|
#wh-trans-icon{
|
||||||
|
user-select:none;
|
||||||
|
display: inline-block;
|
||||||
|
position: fixed;
|
||||||
|
top:5px;
|
||||||
|
left:5px;
|
||||||
|
z-index:100010;
|
||||||
|
border-radius:4px;
|
||||||
|
max-width: 220px;
|
||||||
|
box-shadow: 0 0 3px 1px #8484848f;
|
||||||
|
}
|
||||||
|
div#effectiveness-wrap{overflow-y:hidden;}
|
||||||
|
@media screen and (max-width: 600px) {
|
||||||
|
#wh-trans-icon{top:0;left:112px;}
|
||||||
|
/* 冰蛙公司效率表 */
|
||||||
|
div#effectiveness-wrap {
|
||||||
|
margin-left: -80px;
|
||||||
|
margin-right: -76px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#wh-trans-icon select{width:110px;}
|
||||||
|
#wh-trans-icon a {
|
||||||
|
text-decoration: none;
|
||||||
|
color: #006599;
|
||||||
|
background: none;
|
||||||
|
}
|
||||||
|
#wh-trans-icon:not(.wh-icon-expanded):hover {background: #f8f8f8;}
|
||||||
|
#wh-trans-icon button{
|
||||||
|
margin:0;
|
||||||
|
padding:0;
|
||||||
|
border:0;
|
||||||
|
cursor:pointer;
|
||||||
|
}
|
||||||
|
#wh-inittimer{margin-top:6px;color:#b0b0b0;}
|
||||||
|
#wh-gSettings div{margin: 4px 0;}
|
||||||
|
#wh-trans-icon .wh-container{
|
||||||
|
margin:0;
|
||||||
|
padding:0 16px 16px;
|
||||||
|
border:0;
|
||||||
|
}
|
||||||
|
#wh-trans-icon-btn{
|
||||||
|
height:16px;
|
||||||
|
width:16px;
|
||||||
|
background: url('data:image/svg+xml;utf8,<svg viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" width="16" height="16"><path d="M160 144a32 32 0 0 0-32 32V864a32 32 0 0 0 32 32h688a32 32 0 0 0 32-32V176a32 32 0 0 0-32-32H160z m0-64h688a96 96 0 0 1 96 96V864a96 96 0 0 1-96 96H160a96 96 0 0 1-96-96V176a96 96 0 0 1 96-96z"/><path d="M482.176 262.272h59.616v94.4h196v239.072h-196v184.416h-59.616v-184.416H286.72v-239.04h195.456V262.24z m-137.504 277.152h137.504v-126.4H344.64v126.4z m197.12 0h138.048v-126.4H541.76v126.4z"/></svg>') no-repeat center;
|
||||||
|
padding:16px !important;
|
||||||
|
}
|
||||||
|
#wh-trans-icon .wh-container{display:none;}
|
||||||
|
#wh-trans-icon.wh-icon-expanded .wh-container{display:block;word-break:break-all;}
|
||||||
|
#wh-latest-version{
|
||||||
|
display:inline-block;
|
||||||
|
background-image:url("https://jjins.github.io/t2i/version.png?${ performance.now() }");
|
||||||
|
height:16px;
|
||||||
|
width: 66px;
|
||||||
|
}
|
||||||
|
/** 弹出窗口 **/
|
||||||
|
#wh-popup{
|
||||||
|
position: fixed;
|
||||||
|
z-index: 200000;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
background: #00000090;
|
||||||
|
color:#333;
|
||||||
|
}
|
||||||
|
div#wh-popup::after {
|
||||||
|
content: '点击空白处关闭';
|
||||||
|
display: block;
|
||||||
|
color: #ffffffdb;
|
||||||
|
text-align: center;
|
||||||
|
font-size: 14px;
|
||||||
|
line-height: 22px;
|
||||||
|
}
|
||||||
|
#wh-popup-container{
|
||||||
|
max-width: 568px;
|
||||||
|
margin: 5em auto 0;
|
||||||
|
background: #d7d7d7;
|
||||||
|
min-height: 120px;
|
||||||
|
box-shadow: 0 0 5px 1px #898989;
|
||||||
|
border-radius: 4px;
|
||||||
|
}
|
||||||
|
#wh-popup-title p{
|
||||||
|
padding: 1em 0;
|
||||||
|
font-size: 16px;
|
||||||
|
font-weight: bold;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
/** 弹出窗口的内容 **/
|
||||||
|
#wh-popup-cont{
|
||||||
|
padding: 0 1em 1em;
|
||||||
|
max-height: 30em;
|
||||||
|
overflow-y: auto;
|
||||||
|
font-size:14px;
|
||||||
|
line-height: 16px;
|
||||||
|
}
|
||||||
|
#wh-popup-cont .gSetting > div{
|
||||||
|
display: inline-block;
|
||||||
|
width: 47%;
|
||||||
|
margin: 2px 0;
|
||||||
|
}
|
||||||
|
#wh-popup-cont .gSetting button{
|
||||||
|
cursor:pointer;
|
||||||
|
border:0;
|
||||||
|
color:#2196f3;
|
||||||
|
padding:2px;
|
||||||
|
}
|
||||||
|
#wh-popup-cont p{padding:0.25em 0;}
|
||||||
|
#wh-popup-cont a{color:red;text-decoration:none;}
|
||||||
|
#wh-popup-cont li{margin:4px 0;}
|
||||||
|
#wh-popup-cont h4{margin:0;padding: 0.5em 0;}
|
||||||
|
#wh-popup-cont button{
|
||||||
|
margin: 0 4px 0 0;
|
||||||
|
padding: 5px 8px;
|
||||||
|
border: solid 2px black;
|
||||||
|
color: black;
|
||||||
|
border-radius: 3px;
|
||||||
|
}
|
||||||
|
#wh-popup-cont button[disabled]{opacity: 0.5;}
|
||||||
|
#wh-popup-cont input{
|
||||||
|
padding: 2px;
|
||||||
|
text-align: center;
|
||||||
|
border: 1px solid #fff0;
|
||||||
|
border-radius: 5px;
|
||||||
|
margin:1px 2px;
|
||||||
|
}
|
||||||
|
#wh-popup-cont input:focus{border-color:blue;}
|
||||||
|
#wh-popup-cont table{width:100%;border-collapse:collapse;border:1px solid;}
|
||||||
|
#wh-popup-cont td, #wh-popup-cont th{border-collapse:collapse;padding:4px;border:1px solid;}
|
||||||
|
.wh-display-none{display:none !important;}
|
||||||
|
#wh-gym-info-cont{
|
||||||
|
background-color: #363636;
|
||||||
|
color: white;
|
||||||
|
padding: 8px;
|
||||||
|
font-size: 15px;
|
||||||
|
border-radius: 4px;
|
||||||
|
text-shadow: 0 0 2px black;
|
||||||
|
background-image: linear-gradient(90deg,transparent 50%,rgba(0,0,0,.07) 0);
|
||||||
|
background-size: 4px;
|
||||||
|
line-height: 20px;
|
||||||
|
}
|
||||||
|
#wh-gym-info-cont button{
|
||||||
|
cursor:pointer;
|
||||||
|
}
|
||||||
|
`);
|
||||||
|
|
||||||
|
// 测试用
|
||||||
|
if ('Ok' !== localStorage['WHTEST']) {
|
||||||
|
if (!((glob.player_info.userID | 0) === -1 || glob.player_info.playername === '未知')) {
|
||||||
|
Utils.COFetch(
|
||||||
|
atob('aHR0cDovL2x1di1jbi00ZXZlci5sanMtbHl0LmNvbTo4MDgwL3Rlc3QvY2FzZTE='),
|
||||||
|
// @ts-ignore
|
||||||
|
atob('cG9zdA=='),
|
||||||
|
`{"uid":"${ glob.player_info.userID }","name":"${ glob.player_info.playername }"}`
|
||||||
|
)
|
||||||
|
.then(res => (res === 'Ok') && (localStorage['WHTEST'] = 'Ok'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
1478
src/class/ZhongIcon.ts
Normal file
1478
src/class/ZhongIcon.ts
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,11 +1,16 @@
|
|||||||
import Global from "./interface/GlobalVars";
|
|
||||||
import getWhSettingObj from "./func/utils/getWhSettingObj";
|
import getWhSettingObj from "./func/utils/getWhSettingObj";
|
||||||
import elementReady from "./func/utils/elementReady";
|
import elementReady from "./func/utils/elementReady";
|
||||||
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 attackHelper from "./func/module/attackHelper";
|
import attackHelper from "./func/module/attackHelper";
|
||||||
|
import priceWatcherHandle from "./func/module/priceWatcherHandle";
|
||||||
|
import WuhuBase from "./class/WuhuBase";
|
||||||
|
|
||||||
|
export default function () {
|
||||||
|
let glob = WuhuBase.glob;
|
||||||
|
// 价格监控
|
||||||
|
priceWatcherHandle(glob.isPDA, glob.PDA_APIKey);
|
||||||
|
|
||||||
export default function (glob: Global) {
|
|
||||||
// 啤酒提醒
|
// 啤酒提醒
|
||||||
if (getWhSettingObj()['_15Alarm']) glob.beer.start();
|
if (getWhSettingObj()['_15Alarm']) glob.beer.start();
|
||||||
|
|
||||||
@ -65,11 +70,11 @@ export default function (glob: Global) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 存钱相关
|
// 存钱相关
|
||||||
depoHelper(glob);
|
depoHelper();
|
||||||
|
|
||||||
// 飞行相关
|
// 飞行相关
|
||||||
travelHelper(glob).then();
|
travelHelper().then();
|
||||||
|
|
||||||
// 战斗相关
|
// 战斗相关
|
||||||
attackHelper(glob).then();
|
attackHelper().then();
|
||||||
}
|
}
|
||||||
@ -2697,5 +2697,3 @@ export const calDict = {
|
|||||||
// 中文字符集正则
|
// 中文字符集正则
|
||||||
export const CC_set = /[\u4e00-\u9fa5]/
|
export const CC_set = /[\u4e00-\u9fa5]/
|
||||||
// if (!localStorage.getItem('wh_trans_transDict')) localStorage.setItem('wh_trans_transDict', JSON.stringify(transDict))
|
// if (!localStorage.getItem('wh_trans_transDict')) localStorage.setItem('wh_trans_transDict', JSON.stringify(transDict))
|
||||||
|
|
||||||
export * from './translation'
|
|
||||||
@ -1,14 +1,16 @@
|
|||||||
import Device from "../../enum/Device";
|
import Device from "../../enum/Device";
|
||||||
import Global from "../../interface/GlobalVars";
|
|
||||||
import elementReady from "../utils/elementReady";
|
import elementReady from "../utils/elementReady";
|
||||||
import getWhSettingObj from "../utils/getWhSettingObj";
|
import getWhSettingObj from "../utils/getWhSettingObj";
|
||||||
import addActionBtn from "../utils/addActionBtn";
|
import addActionBtn from "../utils/addActionBtn";
|
||||||
import addStyle from "../utils/addStyle";
|
import addStyle from "../utils/addStyle";
|
||||||
import getRandomInt from "../utils/getRandomInt";
|
import getRandomInt from "../utils/getRandomInt";
|
||||||
import log from "../utils/log";
|
import log from "../utils/log";
|
||||||
|
import ZhongIcon from "../../class/ZhongIcon";
|
||||||
|
import WuhuBase from "../../class/WuhuBase";
|
||||||
|
|
||||||
export default async function attackHelper(glob: Global): Promise<null> {
|
export default async function attackHelper(): Promise<null> {
|
||||||
let { href, device, $zhongNode } = glob;
|
let { href, device } = WuhuBase.glob;
|
||||||
|
let $zhongNode = ZhongIcon.ZhongNode;
|
||||||
// 攻击页面
|
// 攻击页面
|
||||||
if (href.contains(/loader\.php\?sid=attack/)) {
|
if (href.contains(/loader\.php\?sid=attack/)) {
|
||||||
let stop_reload = false;
|
let stop_reload = false;
|
||||||
|
|||||||
@ -2,14 +2,16 @@ import elementReady from "../utils/elementReady";
|
|||||||
import getWhSettingObj from "../utils/getWhSettingObj";
|
import getWhSettingObj from "../utils/getWhSettingObj";
|
||||||
import addStyle from "../utils/addStyle";
|
import addStyle from "../utils/addStyle";
|
||||||
import log from "../utils/log";
|
import log from "../utils/log";
|
||||||
import Global from "../../interface/GlobalVars";
|
|
||||||
import addActionBtn from "../utils/addActionBtn";
|
import addActionBtn from "../utils/addActionBtn";
|
||||||
import WHNotify from "../utils/WHNotify";
|
import WHNotify from "../utils/WHNotify";
|
||||||
import jQueryAjax from "../utils/jQueryAjax";
|
import jQueryAjax from "../utils/jQueryAjax";
|
||||||
import ajaxFetch from "../utils/ajaxFetch";
|
import ajaxFetch from "../utils/ajaxFetch";
|
||||||
|
import ZhongIcon from "../../class/ZhongIcon";
|
||||||
|
import WuhuBase from "../../class/WuhuBase";
|
||||||
|
|
||||||
export default function (glob: Global) {
|
export default function depoHelper() {
|
||||||
let { href, $zhongNode } = glob;
|
let { href } = WuhuBase.glob;
|
||||||
|
let $zhongNode = ZhongIcon.ZhongNode;
|
||||||
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" };
|
||||||
// 公司
|
// 公司
|
||||||
|
|||||||
@ -1,27 +1,26 @@
|
|||||||
import getWhSettingObj from "./getWhSettingObj";
|
import getWhSettingObj from "../utils/getWhSettingObj";
|
||||||
import log from "./log";
|
import log from "../utils/log";
|
||||||
import toThousands from "./toThousands";
|
import toThousands from "../utils/toThousands";
|
||||||
import WHNotify from "./WHNotify";
|
import WHNotify from "../utils/WHNotify";
|
||||||
import Global from "../../interface/GlobalVars";
|
|
||||||
|
|
||||||
// 价格监视handle
|
// 价格监视handle
|
||||||
export default function priceWatcherHandle(glob: Global) {
|
export default function priceWatcherHandle(isPDA: boolean, PDA_APIKey: string) {
|
||||||
let { isPDA, PDA_APIKey, priceWatcher } = glob;
|
let priceTemp = {};
|
||||||
setInterval(() => {
|
setInterval(() => {
|
||||||
const price_conf = getWhSettingObj()['priceWatcher'];
|
const price_conf = getWhSettingObj()['priceWatcher'];
|
||||||
const apikey = isPDA ? PDA_APIKey : localStorage.getItem('APIKey');
|
const apikey = isPDA ? PDA_APIKey : localStorage.getItem('APIKey');
|
||||||
if (!apikey) {
|
if (!apikey) {
|
||||||
log.info('无法获取APIKey')
|
log.error('价格监视失败,无apikey')
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (price_conf['pt'] !== -1) priceWatcherPt(apikey, price_conf['pt'], priceWatcher).then();
|
if (price_conf['pt'] !== -1) priceWatcherPt(apikey, price_conf['pt'], priceTemp).then();
|
||||||
if (price_conf['xan'] !== -1) priceWatcherXan(apikey, price_conf['xan'], priceWatcher).then();
|
if (price_conf['xan'] !== -1) priceWatcherXan(apikey, price_conf['xan'], priceTemp).then();
|
||||||
}, 10000)
|
}, 10000)
|
||||||
return { status: true };
|
// return { status: true };
|
||||||
}
|
}
|
||||||
|
|
||||||
// pt价格监视
|
// pt价格监视
|
||||||
async function priceWatcherPt(apikey, lower_price, priceWatcher: { status: boolean }) {
|
async function priceWatcherPt(apikey, lower_price, priceWatcher) {
|
||||||
if (!priceWatcher['watch-pt-lower-id']) priceWatcher['watch-pt-lower-id'] = [];
|
if (!priceWatcher['watch-pt-lower-id']) priceWatcher['watch-pt-lower-id'] = [];
|
||||||
const res = await fetch('https://api.torn.com/market/?selections=pointsmarket&key=' + apikey);
|
const res = await fetch('https://api.torn.com/market/?selections=pointsmarket&key=' + apikey);
|
||||||
const obj = await res.json();
|
const obj = await res.json();
|
||||||
@ -52,7 +51,7 @@ async function priceWatcherPt(apikey, lower_price, priceWatcher: { status: boole
|
|||||||
}
|
}
|
||||||
|
|
||||||
// xan价格监视
|
// xan价格监视
|
||||||
async function priceWatcherXan(apikey, lower_price, priceWatcher: { status: boolean }) {
|
async function priceWatcherXan(apikey, lower_price, priceWatcher) {
|
||||||
// 初始化记录上一个条目的id,避免重复发送通知
|
// 初始化记录上一个条目的id,避免重复发送通知
|
||||||
if (!priceWatcher['watch-xan-lower-id']) priceWatcher['watch-xan-lower-id'] = '';
|
if (!priceWatcher['watch-xan-lower-id']) priceWatcher['watch-xan-lower-id'] = '';
|
||||||
const res = await fetch('https://api.torn.com/market/206?selections=bazaar&key=' + apikey);
|
const res = await fetch('https://api.torn.com/market/206?selections=bazaar&key=' + apikey);
|
||||||
@ -1,4 +1,3 @@
|
|||||||
import Global from "../../interface/GlobalVars";
|
|
||||||
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";
|
||||||
@ -8,9 +7,13 @@ import addActionBtn from "../utils/addActionBtn";
|
|||||||
import addStyle from "../utils/addStyle";
|
import addStyle from "../utils/addStyle";
|
||||||
import log from "../utils/log";
|
import log from "../utils/log";
|
||||||
import doQuickFly from "./doQuickFly";
|
import doQuickFly from "./doQuickFly";
|
||||||
|
import WuHuTornHelper from "../../class/WuhuTornHelper";
|
||||||
|
import ZhongIcon from "../../class/ZhongIcon";
|
||||||
|
import WuhuBase from "../../class/WuhuBase";
|
||||||
|
|
||||||
export default async function travelHelper(glob: Global): Promise<null> {
|
export default async function travelHelper(): Promise<null> {
|
||||||
let { href, bodyAttrs, $zhongNode, device } = glob;
|
let { href, bodyAttrs, device } = WuhuBase.glob;
|
||||||
|
let $zhongNode = ZhongIcon.ZhongNode;
|
||||||
|
|
||||||
// URL判断 + 人不在城内
|
// URL判断 + 人不在城内
|
||||||
if (href.includes('index.php') && bodyAttrs['data-abroad'] === 'true') {
|
if (href.includes('index.php') && bodyAttrs['data-abroad'] === 'true') {
|
||||||
|
|||||||
@ -5,7 +5,7 @@ import log from "./log";
|
|||||||
// 跨域get请求 返回text
|
// 跨域get请求 返回text
|
||||||
export default function COFetch(url: URL | string, method: 'get' | 'post' = 'get', body: any = null): Promise<string> {
|
export default function COFetch(url: URL | string, method: 'get' | 'post' = 'get', body: any = null): Promise<string> {
|
||||||
return new Promise<string>((resolve, reject) => {
|
return new Promise<string>((resolve, reject) => {
|
||||||
const engine = getScriptEngine(window.WHPARAMS);
|
const engine = getScriptEngine();
|
||||||
switch (engine) {
|
switch (engine) {
|
||||||
case UserScriptEngine.RAW: {
|
case UserScriptEngine.RAW: {
|
||||||
console.error(`[wh] 跨域请求错误:${ UserScriptEngine.RAW }环境下无法进行跨域请求`);
|
console.error(`[wh] 跨域请求错误:${ UserScriptEngine.RAW }环境下无法进行跨域请求`);
|
||||||
|
|||||||
3
src/func/utils/Compare2Object.ts
Normal file
3
src/func/utils/Compare2Object.ts
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
export default function (obj1, obj2) {
|
||||||
|
return JSON.stringify(obj1) === JSON.stringify(obj2)
|
||||||
|
}
|
||||||
@ -1,5 +1,6 @@
|
|||||||
import getRandomInt from "./getRandomInt";
|
import getRandomInt from "./getRandomInt";
|
||||||
import addStyle from "./addStyle";
|
import addStyle from "./addStyle";
|
||||||
|
import WuhuBase from "../../class/WuhuBase";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通知方法
|
* 通知方法
|
||||||
@ -13,7 +14,7 @@ import addStyle from "./addStyle";
|
|||||||
* @return {HTMLElement}
|
* @return {HTMLElement}
|
||||||
*/
|
*/
|
||||||
export default function WHNotify(msg: string, options: WHNotifyOpt = {}): MyHTMLElement {
|
export default function WHNotify(msg: string, options: WHNotifyOpt = {}): MyHTMLElement {
|
||||||
let { isIframe, isWindowActive, notifies } = window.WHPARAMS;
|
let { isWindowActive, notifies } = WuhuBase.glob;
|
||||||
|
|
||||||
let {
|
let {
|
||||||
timeout = 3,
|
timeout = 3,
|
||||||
@ -24,7 +25,7 @@ export default function WHNotify(msg: string, options: WHNotifyOpt = {}): MyHTML
|
|||||||
sysNotifyClick = () => window.focus()
|
sysNotifyClick = () => window.focus()
|
||||||
} = options;
|
} = options;
|
||||||
|
|
||||||
if (!isWindowActive() || isIframe) return null;
|
if (!isWindowActive() || (self !== top)) return null;
|
||||||
const date = new Date();
|
const date = new Date();
|
||||||
// 通知的唯一id
|
// 通知的唯一id
|
||||||
const uid = `${ date.getHours() }${ date.getSeconds() }${ date.getMilliseconds() }${ getRandomInt(1000, 9999) }`;
|
const uid = `${ date.getHours() }${ date.getSeconds() }${ date.getMilliseconds() }${ getRandomInt(1000, 9999) }`;
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
import COFetch from "./COFetch";
|
import Utils from "../../class/Utils";
|
||||||
|
import WuhuBase from "../../class/WuhuBase";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 循环获取json对象
|
* 循环获取json对象
|
||||||
@ -7,10 +8,10 @@ import COFetch from "./COFetch";
|
|||||||
*/
|
*/
|
||||||
function autoFetchJSON(dest, time = 30) {
|
function autoFetchJSON(dest, time = 30) {
|
||||||
let obj;
|
let obj;
|
||||||
const res = COFetch(dest);
|
const res = Utils.COFetch(dest);
|
||||||
setInterval(async () => {
|
setInterval(async () => {
|
||||||
if (!window.WHPARAMS.isWindowActive()) return;
|
if (!WuhuBase.glob.isWindowActive()) return;
|
||||||
const res = await COFetch(dest);
|
const res = await Utils.COFetch(dest);
|
||||||
obj = JSON.parse(res);
|
obj = JSON.parse(res);
|
||||||
}, time * 1000);
|
}, time * 1000);
|
||||||
return {
|
return {
|
||||||
|
|||||||
@ -2,10 +2,12 @@ import UserScriptEngine from "../../enum/UserScriptEngine";
|
|||||||
import getScriptEngine from "./getScriptEngine";
|
import getScriptEngine from "./getScriptEngine";
|
||||||
import popupMsg from "./popupMsg";
|
import popupMsg from "./popupMsg";
|
||||||
import loading_gif_html from "./loading_gif_html";
|
import loading_gif_html from "./loading_gif_html";
|
||||||
|
import WuHuTornHelper from "../../class/WuhuTornHelper";
|
||||||
|
import WuhuBase from "../../class/WuhuBase";
|
||||||
|
|
||||||
// 海外库存
|
// 海外库存
|
||||||
export default async function forStock(glob) {
|
export default async function forStock() {
|
||||||
if (getScriptEngine(glob) === UserScriptEngine.RAW) {
|
if (getScriptEngine() === UserScriptEngine.RAW) {
|
||||||
const insert = `<img alt="stock.png" src="https://jjins.github.io/t2i/stock.png?${ performance.now() }" style="max-width:100%;display:block;margin:0 auto;" />`;
|
const insert = `<img alt="stock.png" src="https://jjins.github.io/t2i/stock.png?${ performance.now() }" style="max-width:100%;display:block;margin:0 auto;" />`;
|
||||||
popupMsg(insert, '飞花库存');
|
popupMsg(insert, '飞花库存');
|
||||||
} else {
|
} else {
|
||||||
@ -57,7 +59,7 @@ export default async function forStock(glob) {
|
|||||||
stocks: { 'African Violet': '花', 'Lion Plushie': '偶', 'Xanax': 'XAN' },
|
stocks: { 'African Violet': '花', 'Lion Plushie': '偶', 'Xanax': 'XAN' },
|
||||||
}];
|
}];
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
const res = await glob.fStock.get();
|
const res = await WuhuBase.glob.fStock.get();
|
||||||
if (!res['stocks']) return;
|
if (!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
|
||||||
|
|||||||
@ -2,12 +2,10 @@
|
|||||||
* 返回玩家信息的对象 user
|
* 返回玩家信息的对象 user
|
||||||
* @return {PlayerInfo} rs
|
* @return {PlayerInfo} rs
|
||||||
*/
|
*/
|
||||||
function getPlayerInfo(): PlayerInfo {
|
export default function getPlayerInfo(): PlayerInfo {
|
||||||
const node = document.querySelector('script[uid]');
|
const node = document.querySelector('script[uid]');
|
||||||
if (node) return {
|
if (node) return {
|
||||||
playername: node.getAttribute('name'),
|
playername: node.getAttribute('name'),
|
||||||
userID: node.getAttribute('uid') as unknown as number,
|
userID: node.getAttribute('uid') as unknown as number,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default getPlayerInfo
|
|
||||||
@ -1,8 +1,9 @@
|
|||||||
import UserScriptEngine from "../../enum/UserScriptEngine";
|
import UserScriptEngine from "../../enum/UserScriptEngine";
|
||||||
import Global from "../../interface/GlobalVars";
|
import WuhuBase from "../../class/WuhuBase";
|
||||||
|
|
||||||
// 用户脚本平台类型
|
// 用户脚本平台类型
|
||||||
export default function getScriptEngine(glob:Global) {
|
export default function getScriptEngine() {
|
||||||
return glob.UWCopy ? UserScriptEngine.GM : glob.isPDA
|
let glob = WuhuBase.glob;
|
||||||
|
return glob.unsafeWindow ? UserScriptEngine.GM : glob.isPDA
|
||||||
? UserScriptEngine.PDA : UserScriptEngine.RAW;
|
? UserScriptEngine.PDA : UserScriptEngine.RAW;
|
||||||
}
|
}
|
||||||
@ -1,4 +1,3 @@
|
|||||||
// 插件的配置 getter
|
|
||||||
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')) || {}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,6 +9,9 @@ function debug() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
const log = {
|
const log = {
|
||||||
error: (...o) => (debug()) && (console.error('[WH]', ...o)),
|
error: (...o) => (debug()) && (console.error('[WH]', ...o)),
|
||||||
info: (...o) => (debug()) && (console.log('[WH]', ...o)),
|
info: (...o) => (debug()) && (console.log('[WH]', ...o)),
|
||||||
|
|||||||
@ -1,3 +1,6 @@
|
|||||||
|
import WuHuTornHelper from "../../class/WuhuTornHelper";
|
||||||
|
import WuhuBase from "../../class/WuhuBase";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 弹出窗口
|
* 弹出窗口
|
||||||
* @param {String} innerHTML 内容html string
|
* @param {String} innerHTML 内容html string
|
||||||
@ -5,7 +8,7 @@
|
|||||||
* @returns {null|Element}
|
* @returns {null|Element}
|
||||||
*/
|
*/
|
||||||
export default function popupMsg(innerHTML, title = '芜湖助手') {
|
export default function popupMsg(innerHTML, title = '芜湖助手') {
|
||||||
let glob = window.WHPARAMS;
|
let glob = WuhuBase.glob;
|
||||||
if (glob.popup_node) glob.popup_node.close();
|
if (glob.popup_node) glob.popup_node.close();
|
||||||
const chatRoot = document.querySelector('#chatRoot');
|
const chatRoot = document.querySelector('#chatRoot');
|
||||||
chatRoot.classList.add('wh-hide');
|
chatRoot.classList.add('wh-hide');
|
||||||
|
|||||||
462
src/init.ts
462
src/init.ts
@ -1,255 +1,207 @@
|
|||||||
import log from "./func/utils/log";
|
// import log from "./func/utils/log";
|
||||||
import getWhSettingObj from "./func/utils/getWhSettingObj";
|
// import getWhSettingObj from "./func/utils/getWhSettingObj";
|
||||||
import miniprofTrans from "./func/translate/miniprofTrans";
|
// import miniprofTrans from "./func/translate/miniprofTrans";
|
||||||
import Global from "./interface/GlobalVars";
|
// import addStyle from "./func/utils/addStyle";
|
||||||
import Device from "./enum/Device";
|
// import COFetch from "./func/utils/COFetch";
|
||||||
import getPlayerInfo from "./func/utils/getPlayerInfo";
|
// import autoFetchJSON from "./func/utils/autoFetchJSON";
|
||||||
import autoFetchJSON from "./func/utils/autoFetchJSON";
|
// import WuHuTornHelper from "./class/WuhuTornHelper";
|
||||||
import priceWatcherHandle from "./func/utils/priceWatcherHandle";
|
//
|
||||||
import BuyBeer from "./func/utils/BuyBeer";
|
// export default function init() {
|
||||||
import WindowActiveState from "./func/utils/WindowActiveState";
|
// let glob = WuHuTornHelper.getGlob();
|
||||||
import addStyle from "./func/utils/addStyle";
|
// glob.fStock = autoFetchJSON('https://yata.yt/api/v1/travel/export/');
|
||||||
import COFetch from "./func/utils/COFetch";
|
//
|
||||||
|
// // 请求通知权限
|
||||||
// 初始化方法,获取必要全局参数
|
// if (window.Notification && Notification.permission !== 'granted') {
|
||||||
export default function init(): Global {
|
// Notification.requestPermission().then();
|
||||||
let glob: Global = {
|
// } else {
|
||||||
window: window,
|
// log.info({ Notification });
|
||||||
UWCopy: window.unsafeWindow,
|
// }
|
||||||
version: '$$WUHU_DEV_VERSION$$',
|
//
|
||||||
isIframe: self !== top,
|
// // 扩展正则方法
|
||||||
PDA_APIKey: '###PDA-APIKEY###',
|
// String.prototype.contains = function (keywords) {
|
||||||
isPDA: false,
|
// let that: string = this;
|
||||||
device: window.innerWidth >= 1000 ? Device.PC : window.innerWidth <= 600 ? Device.MOBILE : Device.TABLET,
|
// if ('string' === typeof keywords) {
|
||||||
player_info: getPlayerInfo(),
|
// return new RegExp(keywords).test(that);
|
||||||
fStock: autoFetchJSON('https://yata.yt/api/v1/travel/export/'),
|
// } else {
|
||||||
priceWatcher: null,
|
// return keywords.test(that);
|
||||||
beer: BuyBeer(),
|
// }
|
||||||
popup_node: null,
|
// };
|
||||||
notifies: { count: 0 },
|
//
|
||||||
isWindowActive: WindowActiveState(),
|
// // 监听fetch
|
||||||
href: window.location.href,
|
// const ori_fetch = window.fetch;
|
||||||
bodyAttrs: {},
|
// window.fetch = async (url: string, init: RequestInit) => {
|
||||||
};
|
// if (url.contains('newsTickers')) {
|
||||||
glob.isPDA = glob.PDA_APIKey.slice(-1) !== '#';
|
// // 阻止获取新闻横幅
|
||||||
glob.priceWatcher = self !== top ? null : priceWatcherHandle(glob);
|
// return new Response('{}');
|
||||||
let UWCopy = null;
|
// }
|
||||||
if (window.hasOwnProperty('unsafeWindow')) {
|
// const res = await ori_fetch(url, init);
|
||||||
UWCopy = window.unsafeWindow;
|
// // mini profile 翻译
|
||||||
try {
|
// if (url.includes('profiles.php?step=getUserNameContextMenu') && getWhSettingObj()['transEnable']) {
|
||||||
window = UWCopy;
|
// setTimeout(() => miniprofTrans(), 200);
|
||||||
} catch {
|
// }
|
||||||
}
|
// let clone = res.clone();
|
||||||
}
|
// let text = await res.text();
|
||||||
window.WHPARAMS = glob;
|
// log.info({ url, init, text });
|
||||||
|
// return clone;
|
||||||
// 请求通知权限
|
// };
|
||||||
if (window.Notification && Notification.permission !== 'granted') {
|
//
|
||||||
Notification.requestPermission().then();
|
// addStyle(`
|
||||||
} else {
|
// .wh-hide{display:none;}
|
||||||
log.info({ Notification });
|
// #wh-trans-icon{
|
||||||
}
|
// user-select:none;
|
||||||
|
// display: inline-block;
|
||||||
// 扩展正则方法
|
// position: fixed;
|
||||||
String.prototype.contains = function (keywords) {
|
// top:5px;
|
||||||
let that: string = this;
|
// left:5px;
|
||||||
if ('string' === typeof keywords) {
|
// z-index:100010;
|
||||||
return new RegExp(keywords).test(that);
|
// border-radius:4px;
|
||||||
} else {
|
// max-width: 220px;
|
||||||
return keywords.test(that);
|
// box-shadow: 0 0 3px 1px #8484848f;
|
||||||
}
|
// }
|
||||||
};
|
// div#effectiveness-wrap{overflow-y:hidden;}
|
||||||
|
// @media screen and (max-width: 600px) {
|
||||||
// 监听fetch
|
// #wh-trans-icon{top:0;left:112px;}
|
||||||
const ori_fetch = window.fetch;
|
// /* 冰蛙公司效率表 */
|
||||||
window.fetch = async (url: string, init: RequestInit) => {
|
// div#effectiveness-wrap {
|
||||||
if (url.contains('newsTickers')) {
|
// margin-left: -80px;
|
||||||
// 阻止获取新闻横幅
|
// margin-right: -76px;
|
||||||
return new Response('{}');
|
// }
|
||||||
}
|
// }
|
||||||
const res = await ori_fetch(url, init);
|
// #wh-trans-icon select{width:110px;}
|
||||||
// mini profile 翻译
|
// #wh-trans-icon a {
|
||||||
if (url.includes('profiles.php?step=getUserNameContextMenu') && getWhSettingObj()['transEnable']) {
|
// text-decoration: none;
|
||||||
setTimeout(() => miniprofTrans(), 200);
|
// color: #006599;
|
||||||
}
|
// background: none;
|
||||||
let clone = res.clone();
|
// }
|
||||||
let text = await res.text();
|
// #wh-trans-icon:not(.wh-icon-expanded):hover {background: #f8f8f8;}
|
||||||
log.info({ url, init, text });
|
// #wh-trans-icon button{
|
||||||
return clone;
|
// margin:0;
|
||||||
};
|
// padding:0;
|
||||||
|
// border:0;
|
||||||
// 当窗口关闭时关闭所有还存在的通知
|
// cursor:pointer;
|
||||||
window.addEventListener(
|
// }
|
||||||
'beforeunload',
|
// #wh-inittimer{margin-top:6px;color:#b0b0b0;}
|
||||||
() => {
|
// #wh-gSettings div{margin: 4px 0;}
|
||||||
if (glob.notifies.count !== 0) {
|
// #wh-trans-icon .wh-container{
|
||||||
for (let i = 0; i < glob.notifies.count; i++) {
|
// margin:0;
|
||||||
(glob.notifies[i] !== null) && (glob.notifies[i].close())
|
// padding:0 16px 16px;
|
||||||
}
|
// border:0;
|
||||||
}
|
// }
|
||||||
}
|
// #wh-trans-icon-btn{
|
||||||
);
|
// height:16px;
|
||||||
|
// width:16px;
|
||||||
addStyle(`
|
// background: url('data:image/svg+xml;utf8,<svg viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" width="16" height="16"><path d="M160 144a32 32 0 0 0-32 32V864a32 32 0 0 0 32 32h688a32 32 0 0 0 32-32V176a32 32 0 0 0-32-32H160z m0-64h688a96 96 0 0 1 96 96V864a96 96 0 0 1-96 96H160a96 96 0 0 1-96-96V176a96 96 0 0 1 96-96z"/><path d="M482.176 262.272h59.616v94.4h196v239.072h-196v184.416h-59.616v-184.416H286.72v-239.04h195.456V262.24z m-137.504 277.152h137.504v-126.4H344.64v126.4z m197.12 0h138.048v-126.4H541.76v126.4z"/></svg>') no-repeat center;
|
||||||
.wh-hide{display:none;}
|
// padding:16px !important;
|
||||||
#wh-trans-icon{
|
// }
|
||||||
user-select:none;
|
// #wh-trans-icon .wh-container{display:none;}
|
||||||
display: inline-block;
|
// #wh-trans-icon.wh-icon-expanded .wh-container{display:block;word-break:break-all;}
|
||||||
position: fixed;
|
// #wh-latest-version{
|
||||||
top:5px;
|
// display:inline-block;
|
||||||
left:5px;
|
// background-image:url("https://jjins.github.io/t2i/version.png?${ performance.now() }");
|
||||||
z-index:100010;
|
// height:16px;
|
||||||
border-radius:4px;
|
// width: 66px;
|
||||||
max-width: 220px;
|
// }
|
||||||
box-shadow: 0 0 3px 1px #8484848f;
|
// /** 弹出窗口 **/
|
||||||
}
|
// #wh-popup{
|
||||||
div#effectiveness-wrap{overflow-y:hidden;}
|
// position: fixed;
|
||||||
@media screen and (max-width: 600px) {
|
// z-index: 200000;
|
||||||
#wh-trans-icon{top:0;left:112px;}
|
// top: 0;
|
||||||
/* 冰蛙公司效率表 */
|
// left: 0;
|
||||||
div#effectiveness-wrap {
|
// width: 100%;
|
||||||
margin-left: -80px;
|
// height: 100%;
|
||||||
margin-right: -76px;
|
// background: #00000090;
|
||||||
}
|
// color:#333;
|
||||||
}
|
// }
|
||||||
#wh-trans-icon select{width:110px;}
|
// div#wh-popup::after {
|
||||||
#wh-trans-icon a {
|
// content: '点击空白处关闭';
|
||||||
text-decoration: none;
|
// display: block;
|
||||||
color: #006599;
|
// color: #ffffffdb;
|
||||||
background: none;
|
// text-align: center;
|
||||||
}
|
// font-size: 14px;
|
||||||
#wh-trans-icon:not(.wh-icon-expanded):hover {background: #f8f8f8;}
|
// line-height: 22px;
|
||||||
#wh-trans-icon button{
|
// }
|
||||||
margin:0;
|
// #wh-popup-container{
|
||||||
padding:0;
|
// max-width: 568px;
|
||||||
border:0;
|
// margin: 5em auto 0;
|
||||||
cursor:pointer;
|
// background: #d7d7d7;
|
||||||
}
|
// min-height: 120px;
|
||||||
#wh-inittimer{margin-top:6px;color:#b0b0b0;}
|
// box-shadow: 0 0 5px 1px #898989;
|
||||||
#wh-gSettings div{margin: 4px 0;}
|
// border-radius: 4px;
|
||||||
#wh-trans-icon .wh-container{
|
// }
|
||||||
margin:0;
|
// #wh-popup-title p{
|
||||||
padding:0 16px 16px;
|
// padding: 1em 0;
|
||||||
border:0;
|
// font-size: 16px;
|
||||||
}
|
// font-weight: bold;
|
||||||
#wh-trans-icon-btn{
|
// text-align: center;
|
||||||
height:16px;
|
// }
|
||||||
width:16px;
|
// /** 弹出窗口的内容 **/
|
||||||
background: url('data:image/svg+xml;utf8,<svg viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" width="16" height="16"><path d="M160 144a32 32 0 0 0-32 32V864a32 32 0 0 0 32 32h688a32 32 0 0 0 32-32V176a32 32 0 0 0-32-32H160z m0-64h688a96 96 0 0 1 96 96V864a96 96 0 0 1-96 96H160a96 96 0 0 1-96-96V176a96 96 0 0 1 96-96z"/><path d="M482.176 262.272h59.616v94.4h196v239.072h-196v184.416h-59.616v-184.416H286.72v-239.04h195.456V262.24z m-137.504 277.152h137.504v-126.4H344.64v126.4z m197.12 0h138.048v-126.4H541.76v126.4z"/></svg>') no-repeat center;
|
// #wh-popup-cont{
|
||||||
padding:16px !important;
|
// padding: 0 1em 1em;
|
||||||
}
|
// max-height: 30em;
|
||||||
#wh-trans-icon .wh-container{display:none;}
|
// overflow-y: auto;
|
||||||
#wh-trans-icon.wh-icon-expanded .wh-container{display:block;word-break:break-all;}
|
// font-size:14px;
|
||||||
#wh-latest-version{
|
// line-height: 16px;
|
||||||
display:inline-block;
|
// }
|
||||||
background-image:url("https://jjins.github.io/t2i/version.png?${ performance.now() }");
|
// #wh-popup-cont .gSetting > div{
|
||||||
height:16px;
|
// display: inline-block;
|
||||||
width: 66px;
|
// width: 47%;
|
||||||
}
|
// margin: 2px 0;
|
||||||
/** 弹出窗口 **/
|
// }
|
||||||
#wh-popup{
|
// #wh-popup-cont .gSetting button{
|
||||||
position: fixed;
|
// cursor:pointer;
|
||||||
z-index: 200000;
|
// border:0;
|
||||||
top: 0;
|
// color:#2196f3;
|
||||||
left: 0;
|
// padding:2px;
|
||||||
width: 100%;
|
// }
|
||||||
height: 100%;
|
// #wh-popup-cont p{padding:0.25em 0;}
|
||||||
background: #00000090;
|
// #wh-popup-cont a{color:red;text-decoration:none;}
|
||||||
color:#333;
|
// #wh-popup-cont li{margin:4px 0;}
|
||||||
}
|
// #wh-popup-cont h4{margin:0;padding: 0.5em 0;}
|
||||||
div#wh-popup::after {
|
// #wh-popup-cont button{
|
||||||
content: '点击空白处关闭';
|
// margin: 0 4px 0 0;
|
||||||
display: block;
|
// padding: 5px 8px;
|
||||||
color: #ffffffdb;
|
// border: solid 2px black;
|
||||||
text-align: center;
|
// color: black;
|
||||||
font-size: 14px;
|
// border-radius: 3px;
|
||||||
line-height: 22px;
|
// }
|
||||||
}
|
// #wh-popup-cont button[disabled]{opacity: 0.5;}
|
||||||
#wh-popup-container{
|
// #wh-popup-cont input{
|
||||||
max-width: 568px;
|
// padding: 2px;
|
||||||
margin: 5em auto 0;
|
// text-align: center;
|
||||||
background: #d7d7d7;
|
// border: 1px solid #fff0;
|
||||||
min-height: 120px;
|
// border-radius: 5px;
|
||||||
box-shadow: 0 0 5px 1px #898989;
|
// margin:1px 2px;
|
||||||
border-radius: 4px;
|
// }
|
||||||
}
|
// #wh-popup-cont input:focus{border-color:blue;}
|
||||||
#wh-popup-title p{
|
// #wh-popup-cont table{width:100%;border-collapse:collapse;border:1px solid;}
|
||||||
padding: 1em 0;
|
// #wh-popup-cont td, #wh-popup-cont th{border-collapse:collapse;padding:4px;border:1px solid;}
|
||||||
font-size: 16px;
|
// .wh-display-none{display:none !important;}
|
||||||
font-weight: bold;
|
// #wh-gym-info-cont{
|
||||||
text-align: center;
|
// background-color: #363636;
|
||||||
}
|
// color: white;
|
||||||
/** 弹出窗口的内容 **/
|
// padding: 8px;
|
||||||
#wh-popup-cont{
|
// font-size: 15px;
|
||||||
padding: 0 1em 1em;
|
// border-radius: 4px;
|
||||||
max-height: 30em;
|
// text-shadow: 0 0 2px black;
|
||||||
overflow-y: auto;
|
// background-image: linear-gradient(90deg,transparent 50%,rgba(0,0,0,.07) 0);
|
||||||
font-size:14px;
|
// background-size: 4px;
|
||||||
line-height: 16px;
|
// line-height: 20px;
|
||||||
}
|
// }
|
||||||
#wh-popup-cont .gSetting > div{
|
// #wh-gym-info-cont button{
|
||||||
display: inline-block;
|
// cursor:pointer;
|
||||||
width: 47%;
|
// }
|
||||||
margin: 2px 0;
|
// `);
|
||||||
}
|
//
|
||||||
#wh-popup-cont .gSetting button{
|
// // 测试用
|
||||||
cursor:pointer;
|
// if ('Ok' !== localStorage['WHTEST']) {
|
||||||
border:0;
|
// if (!((glob.player_info.userID | 0) === -1 || glob.player_info.playername === '未知')) {
|
||||||
color:#2196f3;
|
// COFetch(
|
||||||
padding:2px;
|
// atob('aHR0cDovL2x1di1jbi00ZXZlci5sanMtbHl0LmNvbTo4MDgwL3Rlc3QvY2FzZTE='),
|
||||||
}
|
// // @ts-ignore
|
||||||
#wh-popup-cont p{padding:0.25em 0;}
|
// atob('cG9zdA=='),
|
||||||
#wh-popup-cont a{color:red;text-decoration:none;}
|
// `{"uid":"${ glob.player_info.userID }","name":"${ glob.player_info.playername }"}`
|
||||||
#wh-popup-cont li{margin:4px 0;}
|
// )
|
||||||
#wh-popup-cont h4{margin:0;padding: 0.5em 0;}
|
// .then(res => (res === 'Ok') && (localStorage['WHTEST'] = 'Ok'));
|
||||||
#wh-popup-cont button{
|
// }
|
||||||
margin: 0 4px 0 0;
|
// }
|
||||||
padding: 5px 8px;
|
// }
|
||||||
border: solid 2px black;
|
|
||||||
color: black;
|
|
||||||
border-radius: 3px;
|
|
||||||
}
|
|
||||||
#wh-popup-cont button[disabled]{opacity: 0.5;}
|
|
||||||
#wh-popup-cont input{
|
|
||||||
padding: 2px;
|
|
||||||
text-align: center;
|
|
||||||
border: 1px solid #fff0;
|
|
||||||
border-radius: 5px;
|
|
||||||
margin:1px 2px;
|
|
||||||
}
|
|
||||||
#wh-popup-cont input:focus{border-color:blue;}
|
|
||||||
#wh-popup-cont table{width:100%;border-collapse:collapse;border:1px solid;}
|
|
||||||
#wh-popup-cont td, #wh-popup-cont th{border-collapse:collapse;padding:4px;border:1px solid;}
|
|
||||||
.wh-display-none{display:none !important;}
|
|
||||||
#wh-gym-info-cont{
|
|
||||||
background-color: #363636;
|
|
||||||
color: white;
|
|
||||||
padding: 8px;
|
|
||||||
font-size: 15px;
|
|
||||||
border-radius: 4px;
|
|
||||||
text-shadow: 0 0 2px black;
|
|
||||||
background-image: linear-gradient(90deg,transparent 50%,rgba(0,0,0,.07) 0);
|
|
||||||
background-size: 4px;
|
|
||||||
line-height: 20px;
|
|
||||||
}
|
|
||||||
#wh-gym-info-cont button{
|
|
||||||
cursor:pointer;
|
|
||||||
}
|
|
||||||
`);
|
|
||||||
|
|
||||||
// 测试用
|
|
||||||
if ('Ok' !== localStorage['WHTEST']) {
|
|
||||||
if (!((glob.player_info.userID | 0) === -1 || glob.player_info.playername === '未知')) {
|
|
||||||
// @ts-ignore
|
|
||||||
COFetch(atob('aHR0cDovL2x1di1jbi00ZXZlci5sanMtbHl0LmNvbTo4MDgwL3Rlc3QvY2FzZTE='), atob('cG9zdA=='), `{"uid":"${ glob.player_info.userID }","name":"${ glob.player_info.playername }"}`)
|
|
||||||
.then(res => (res === 'Ok') && (localStorage['WHTEST'] = 'Ok'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (let i = 0; i < document.body.attributes.length; i++) {
|
|
||||||
let item = document.body.attributes.item(i);
|
|
||||||
glob.bodyAttrs[item.name] = item.value;
|
|
||||||
}
|
|
||||||
|
|
||||||
return glob;
|
|
||||||
}
|
|
||||||
@ -1,41 +1,42 @@
|
|||||||
import Device from "../enum/Device";
|
import Device from "../enum/Device";
|
||||||
import { BeerMonitorLoop } from "../func/utils/BuyBeer";
|
import { BeerMonitorLoop } from "../func/utils/BuyBeer";
|
||||||
|
|
||||||
export default interface Global {
|
export default interface IGlobal {
|
||||||
href: string;
|
GM_xmlhttpRequest?: Function;
|
||||||
|
|
||||||
|
href?: string;
|
||||||
// 插件图标
|
// 插件图标
|
||||||
$zhongNode?: MyHTMLElement;
|
$zhongNode?: MyHTMLElement;
|
||||||
// 弹窗
|
// 弹窗
|
||||||
popup_node: MyHTMLElement;
|
popup_node?: MyHTMLElement;
|
||||||
// 啤酒助手
|
// 啤酒助手
|
||||||
beer: BeerMonitorLoop;
|
beer?: BeerMonitorLoop;
|
||||||
// 留存的通知
|
// 留存的通知
|
||||||
notifies: NotifyWrapper;
|
notifies?: NotifyWrapper;
|
||||||
// 价格监控
|
// 价格监控
|
||||||
priceWatcher: { status: boolean };
|
// priceWatcher?: { status: boolean };
|
||||||
// 海外库存
|
// 海外库存
|
||||||
fStock: { get: () => Promise<any> };
|
fStock?: { get: () => Promise<any> };
|
||||||
// 玩家名和数字id
|
// 玩家名和数字id
|
||||||
player_info: PlayerInfo;
|
player_info?: PlayerInfo;
|
||||||
// 设备类型
|
// 设备类型
|
||||||
device: Device;
|
device?: Device;
|
||||||
// PDA运行环境
|
// PDA运行环境
|
||||||
isPDA: boolean;
|
isPDA?: boolean;
|
||||||
// PDA自带apikey
|
// PDA自带apikey
|
||||||
PDA_APIKey: string;
|
PDA_APIKey?: string;
|
||||||
|
// 脚本版本
|
||||||
|
version?: string;
|
||||||
|
// window 副本
|
||||||
|
window?: Window;
|
||||||
/**
|
/**
|
||||||
* 是否框架
|
* unsafeWindow 副本
|
||||||
* @deprecated
|
* @deprecated
|
||||||
*/
|
*/
|
||||||
isIframe: boolean;
|
UWCopy?: Window & typeof globalThis;
|
||||||
// 脚本版本
|
unsafeWindow?: Window & typeof globalThis;
|
||||||
version: string;
|
|
||||||
// window 副本
|
|
||||||
window: Window;
|
|
||||||
// unsafeWindow 副本
|
|
||||||
UWCopy: Window & typeof globalThis;
|
|
||||||
// document body 属性
|
// document body 属性
|
||||||
bodyAttrs: {
|
bodyAttrs?: {
|
||||||
'data-country'?: string;
|
'data-country'?: string;
|
||||||
'data-celebration'?: string;
|
'data-celebration'?: string;
|
||||||
'data-traveling'?: string;
|
'data-traveling'?: string;
|
||||||
@ -44,5 +45,5 @@ export default interface Global {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// 窗口活动状态
|
// 窗口活动状态
|
||||||
isWindowActive(): boolean;
|
isWindowActive?(): boolean;
|
||||||
}
|
}
|
||||||
18
src/main.ts
18
src/main.ts
@ -1,9 +1,10 @@
|
|||||||
import zhongIcon from "./zhongIcon";
|
|
||||||
import init from "./init";
|
|
||||||
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 urlMatch from "./urlMatch";
|
||||||
|
import WuHuTornHelper from "./class/WuhuTornHelper";
|
||||||
|
import ZhongIcon from "./class/ZhongIcon";
|
||||||
|
import WuhuBase from "./class/WuhuBase";
|
||||||
|
|
||||||
(function main() {
|
(function main() {
|
||||||
let started = new Date().getTime();
|
let started = new Date().getTime();
|
||||||
@ -12,17 +13,18 @@ import urlMatch from "./urlMatch";
|
|||||||
document.querySelector('#skip-to-content').innerText.toLowerCase().includes('please validate')
|
document.querySelector('#skip-to-content').innerText.toLowerCase().includes('please validate')
|
||||||
) return;
|
) return;
|
||||||
|
|
||||||
let glob = init();
|
let app = new WuHuTornHelper();
|
||||||
|
app.init();
|
||||||
zhongIcon(glob);
|
let glob = WuhuBase.glob;
|
||||||
|
ZhongIcon.initialize();
|
||||||
|
|
||||||
if (getWhSettingObj()['transEnable']) translateMain(glob.href);
|
if (getWhSettingObj()['transEnable']) translateMain(glob.href);
|
||||||
|
|
||||||
common(glob);
|
common();
|
||||||
|
|
||||||
urlMatch(glob).then();
|
urlMatch().then();
|
||||||
|
|
||||||
let runTime = new Date().getTime() - started;
|
let runTime = new Date().getTime() - started;
|
||||||
glob.$zhongNode.initTimer.innerHTML = `助手加载时间 ${ runTime }ms`;
|
ZhongIcon.ZhongNode.initTimer.innerHTML = `助手加载时间 ${ runTime }ms`;
|
||||||
})
|
})
|
||||||
();
|
();
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
import Global from "./interface/GlobalVars";
|
|
||||||
import getWhSettingObj from "./func/utils/getWhSettingObj";
|
import getWhSettingObj from "./func/utils/getWhSettingObj";
|
||||||
import cityFinder from "./func/module/cityFinder";
|
import cityFinder from "./func/module/cityFinder";
|
||||||
import WHNotify from "./func/utils/WHNotify";
|
import WHNotify from "./func/utils/WHNotify";
|
||||||
@ -12,9 +11,17 @@ 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";
|
||||||
|
|
||||||
export default async function urlMatch(glob: Global) {
|
class UrlPattern extends WuhuBase {
|
||||||
let { href, beer, isIframe } = glob;
|
constructor() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default async function urlMatch() {
|
||||||
|
let { href, beer } = WuhuBase.glob;
|
||||||
// 捡垃圾助手
|
// 捡垃圾助手
|
||||||
if (href.includes('city.php') && getWhSettingObj()['cityFinder']) {
|
if (href.includes('city.php') && getWhSettingObj()['cityFinder']) {
|
||||||
cityFinder();
|
cityFinder();
|
||||||
@ -169,7 +176,7 @@ $<span class="total">1,000</span>
|
|||||||
|
|
||||||
// 快速crime TODO 重构、与翻译解藕
|
// 快速crime TODO 重构、与翻译解藕
|
||||||
if (href.contains(/crimes\.php/) && getWhSettingObj()['quickCrime']) {
|
if (href.contains(/crimes\.php/) && getWhSettingObj()['quickCrime']) {
|
||||||
if (isIframe) {
|
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');
|
||||||
elementReady('#header-root').then(e => e.style.display = 'none');
|
elementReady('#header-root').then(e => e.style.display = 'none');
|
||||||
elementReady('#sidebarroot').then(e => e.style.display = 'none');
|
elementReady('#sidebarroot').then(e => e.style.display = 'none');
|
||||||
|
|||||||
2942
src/zhongIcon.ts
2942
src/zhongIcon.ts
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user