更新
This commit is contained in:
parent
f37641a955
commit
bb770d8e2e
7
global.d.ts
vendored
7
global.d.ts
vendored
@ -17,10 +17,13 @@ declare interface Window {
|
|||||||
ReactDOM?: any;
|
ReactDOM?: any;
|
||||||
hasWHQuickFlyOpt?: boolean;
|
hasWHQuickFlyOpt?: boolean;
|
||||||
// 插件运行标识
|
// 插件运行标识
|
||||||
WHTRANS?: boolean;
|
WHTRANS?: number;
|
||||||
Vue?: Function;
|
Vue?: Function;
|
||||||
/* 油猴脚本引擎自带 */
|
/* 油猴脚本引擎自带 */
|
||||||
unsafeWindow?: Window & typeof globalThis;
|
unsafeWindow?: Window & typeof globalThis;
|
||||||
|
// google不跟踪标识
|
||||||
|
_gaUserPrefs?: unknown;
|
||||||
|
dataLayer?: unknown;
|
||||||
|
|
||||||
eval(exc: string): void;
|
eval(exc: string): void;
|
||||||
|
|
||||||
@ -47,7 +50,7 @@ declare interface Window {
|
|||||||
GM_setValue(k: string, v: any): void;
|
GM_setValue(k: string, v: any): void;
|
||||||
|
|
||||||
// TODO 临时测试用
|
// TODO 临时测试用
|
||||||
[key: string]: unknown;
|
// [key: string]: unknown;
|
||||||
}
|
}
|
||||||
|
|
||||||
declare interface GM_RequestParams {
|
declare interface GM_RequestParams {
|
||||||
|
|||||||
@ -10,22 +10,21 @@ import Global from "./Global";
|
|||||||
export default class Application {
|
export default class Application {
|
||||||
|
|
||||||
public static main() {
|
public static main() {
|
||||||
let started = performance.now();
|
|
||||||
|
|
||||||
WuhuBase.PDAExecute();
|
|
||||||
WuhuBase.conditionInterrupt();
|
WuhuBase.conditionInterrupt();
|
||||||
|
|
||||||
|
// 初始化
|
||||||
WuHuTornHelper.getInstance();
|
WuHuTornHelper.getInstance();
|
||||||
|
|
||||||
|
// 插件图标和设置菜单
|
||||||
ZhongIcon.getInstance();
|
ZhongIcon.getInstance();
|
||||||
|
|
||||||
|
// 所有页面通用
|
||||||
Common.getInstance().resolve();
|
Common.getInstance().resolve();
|
||||||
|
|
||||||
|
// URL匹配
|
||||||
UrlPattern.getInstance().resolve();
|
UrlPattern.getInstance().resolve();
|
||||||
|
|
||||||
|
// 翻译
|
||||||
if (WuhuConfig.get('transEnable')) translateMain(Global.getInstance().href);
|
if (WuhuConfig.get('transEnable')) translateMain(Global.getInstance().href);
|
||||||
|
|
||||||
let runTime: number = (performance.now() - started) | 0;
|
|
||||||
ZhongIcon.ZhongNode.initTimer.innerHTML = `助手加载时间 ${ runTime }ms`;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -7,6 +7,7 @@ import WuhuConfig from "./WuhuConfig";
|
|||||||
import CommonUtils from "./utils/CommonUtils";
|
import CommonUtils from "./utils/CommonUtils";
|
||||||
|
|
||||||
export class Common extends WuhuBase {
|
export class Common extends WuhuBase {
|
||||||
|
className = 'Common';
|
||||||
resolve() {
|
resolve() {
|
||||||
let glob = Common.glob;
|
let glob = Common.glob;
|
||||||
// 价格监控
|
// 价格监控
|
||||||
|
|||||||
@ -9,6 +9,7 @@ import BuyBeerHelper from "./action/BuyBeerHelper";
|
|||||||
* 存储脚本用到的参数,单例存在
|
* 存储脚本用到的参数,单例存在
|
||||||
*/
|
*/
|
||||||
export default class Global extends WuhuBase implements IGlobal {
|
export default class Global extends WuhuBase implements IGlobal {
|
||||||
|
className = 'Global';
|
||||||
GM_xmlhttpRequest: Function = null;
|
GM_xmlhttpRequest: Function = null;
|
||||||
|
|
||||||
href: string = window.location.href;
|
href: string = window.location.href;
|
||||||
@ -39,13 +40,12 @@ export default class Global extends WuhuBase implements IGlobal {
|
|||||||
'data-celebration'?: string;
|
'data-celebration'?: string;
|
||||||
'data-traveling'?: string;
|
'data-traveling'?: string;
|
||||||
'data-abroad'?: string;
|
'data-abroad'?: string;
|
||||||
// [key: string]: string;
|
|
||||||
} = null;
|
} = null;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
Log.info('WH脚本参数初始化');
|
Log.info('WH脚本参数初始化');
|
||||||
super();
|
super();
|
||||||
this.window = window;
|
// this.window = window;
|
||||||
this.unsafeWindow = window.unsafeWindow || null;
|
this.unsafeWindow = window.unsafeWindow || null;
|
||||||
this.GM_xmlhttpRequest = window.GM_xmlhttpRequest || null;
|
this.GM_xmlhttpRequest = window.GM_xmlhttpRequest || null;
|
||||||
this.version = '$$WUHU_DEV_VERSION$$';
|
this.version = '$$WUHU_DEV_VERSION$$';
|
||||||
@ -60,13 +60,11 @@ export default class Global extends WuhuBase implements IGlobal {
|
|||||||
this.bodyAttrs = {};
|
this.bodyAttrs = {};
|
||||||
|
|
||||||
if (this.unsafeWindow) {
|
if (this.unsafeWindow) {
|
||||||
try {
|
Log.info('存在unsafeWindow, 引入部分torn公共方法');
|
||||||
window = this.unsafeWindow || this.window;
|
window.addRFC = this.unsafeWindow.addRFC;
|
||||||
Log.info('替换window上下文');
|
window.getAction = this.unsafeWindow.getAction;
|
||||||
} catch {
|
window.initializeTooltip = this.unsafeWindow.initializeTooltip;
|
||||||
this.unsafeWindow = null;
|
window.renderMiniProfile = this.unsafeWindow.renderMiniProfile;
|
||||||
this.GM_xmlhttpRequest = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let i = 0; i < document.body.attributes.length; i++) {
|
for (let i = 0; i < document.body.attributes.length; i++) {
|
||||||
|
|||||||
@ -13,7 +13,7 @@ export default class Log {
|
|||||||
static error(...o): void {
|
static error(...o): void {
|
||||||
let time = this.getTime();
|
let time = this.getTime();
|
||||||
let flag = '[WH] ERR';
|
let flag = '[WH] ERR';
|
||||||
(this.debug()) && (console.error(flag, time, ...o));
|
console.error(flag, time, ...o);
|
||||||
this.saveLogs(flag, time, ...o);
|
this.saveLogs(flag, time, ...o);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,13 +1,11 @@
|
|||||||
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 Device from "../enum/Device";
|
|
||||||
import WuhuBase from "./WuhuBase";
|
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";
|
||||||
import Alert from "./utils/Alert";
|
import Alert from "./utils/Alert";
|
||||||
import InfoUtils from "./utils/InfoUtils";
|
|
||||||
import SHOP_BEER_STATIC_ITEM_HTML from "../static/html/buyBeer/shop_beer_static_item.html";
|
import SHOP_BEER_STATIC_ITEM_HTML from "../static/html/buyBeer/shop_beer_static_item.html";
|
||||||
import ADD_BEER_HEAD_HTML from "../static/html/buyBeer/add_beer_head.html";
|
import ADD_BEER_HEAD_HTML from "../static/html/buyBeer/add_beer_head.html";
|
||||||
import QUICK_CRIMES_HTML from "../static/html/quick_crimes.html";
|
import QUICK_CRIMES_HTML from "../static/html/quick_crimes.html";
|
||||||
@ -21,6 +19,7 @@ import BuyBeerHelper from "./action/BuyBeerHelper";
|
|||||||
import XZMZ from "./action/XZMZ";
|
import XZMZ from "./action/XZMZ";
|
||||||
|
|
||||||
export default class UrlPattern extends WuhuBase {
|
export default class UrlPattern extends WuhuBase {
|
||||||
|
className = 'UrlPattern';
|
||||||
public resolve(): void {
|
public resolve(): void {
|
||||||
let href = window.location.href;
|
let href = window.location.href;
|
||||||
// 捡垃圾助手
|
// 捡垃圾助手
|
||||||
@ -226,21 +225,21 @@ export default class UrlPattern extends WuhuBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 特定
|
// 特定
|
||||||
if (InfoUtils.getInstance().getPlayerInfo().userID === 2687093 && CommonUtils.getDeviceType() === Device.PC) {
|
// if (InfoUtils.getInstance().getPlayerInfo().userID === 2687093 && CommonUtils.getDeviceType() === Device.PC) {
|
||||||
InfoUtils.getInstance().getSidebarData().then(data => {
|
// InfoUtils.getInstance().getSidebarData().then(data => {
|
||||||
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);
|
||||||
(<HTMLElement>copy.firstChild).style.backgroundColor = '#678c00';
|
// (<HTMLElement>copy.firstChild).style.backgroundColor = '#678c00';
|
||||||
let a = copy.firstChild.firstChild as HTMLAnchorElement;
|
// let a = copy.firstChild.firstChild as HTMLAnchorElement;
|
||||||
a.href = '/item.php?temp=1';
|
// a.href = '/item.php?temp=1';
|
||||||
let span = a.lastChild as HTMLElement;
|
// let span = a.lastChild as HTMLElement;
|
||||||
span.innerHTML = '物品';
|
// span.innerHTML = '物品';
|
||||||
span.style.color = 'white';
|
// span.style.color = 'white';
|
||||||
item.after(copy);
|
// item.after(copy);
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
|
|
||||||
// 彩票助手
|
// 彩票助手
|
||||||
if (href.includes('loader.php?sid=lottery')) LotteryHelper.getInstance().init();
|
if (href.includes('loader.php?sid=lottery')) LotteryHelper.getInstance().init();
|
||||||
|
|||||||
@ -1,17 +1,10 @@
|
|||||||
import IGlobal from "../interface/IGlobal";
|
import IGlobal from "../interface/IGlobal";
|
||||||
import IWHSettings from "../interface/IWHSettings";
|
import IWHSettings from "../interface/IWHSettings";
|
||||||
import Log from "./Log";
|
|
||||||
import Provider from "./provider/Provider";
|
import Provider from "./provider/Provider";
|
||||||
|
|
||||||
export default class WuhuBase extends Provider {
|
export default class WuhuBase extends Provider {
|
||||||
static glob: IGlobal = null;
|
static glob: IGlobal = null;
|
||||||
protected static className = 'WuhuBase';
|
className = 'WuhuBase';
|
||||||
|
|
||||||
constructor() {
|
|
||||||
super();
|
|
||||||
// Log.info({ 'constructor': this.constructor, this: this, test: this.getClassName() });
|
|
||||||
Log.info('创建对象:', this);
|
|
||||||
}
|
|
||||||
|
|
||||||
static getLocal(): IWHSettings {
|
static getLocal(): IWHSettings {
|
||||||
return JSON.parse(localStorage.getItem('wh_trans_settings')) || {};
|
return JSON.parse(localStorage.getItem('wh_trans_settings')) || {};
|
||||||
@ -28,8 +21,8 @@ export default class WuhuBase extends Provider {
|
|||||||
if (condition) throw '芜湖';
|
if (condition) throw '芜湖';
|
||||||
}
|
}
|
||||||
|
|
||||||
static PDAExecute() {
|
public getClassName() {
|
||||||
if (window.WHTRANS) throw '已运行,退出';
|
return this.className;
|
||||||
window.WHTRANS = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -3,6 +3,7 @@ import Alert from "./utils/Alert";
|
|||||||
import Log from "./Log";
|
import Log from "./Log";
|
||||||
|
|
||||||
export default class WuhuConfig extends WuhuBase {
|
export default class WuhuConfig extends WuhuBase {
|
||||||
|
className = 'WuhuConfig';
|
||||||
static get(key: string | string[]) {
|
static get(key: string | string[]) {
|
||||||
let localPool = this.getLocal();
|
let localPool = this.getLocal();
|
||||||
if (typeof key === 'string') return localPool[key];
|
if (typeof key === 'string') return localPool[key];
|
||||||
|
|||||||
@ -8,6 +8,7 @@ import WuhuConfig from "./WuhuConfig";
|
|||||||
import COMMON_CSS from "../static/css/common.css";
|
import COMMON_CSS from "../static/css/common.css";
|
||||||
|
|
||||||
export default class WuHuTornHelper extends WuhuBase {
|
export default class WuHuTornHelper extends WuhuBase {
|
||||||
|
className = 'WuHuTornHelper';
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
@ -23,7 +24,7 @@ export default class WuHuTornHelper extends WuhuBase {
|
|||||||
window.Notification.requestPermission().then();
|
window.Notification.requestPermission().then();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Log.error('当前浏览器不支持系统通知');
|
Log.error('该浏览器不支持系统通知');
|
||||||
}
|
}
|
||||||
|
|
||||||
// 扩展正则方法
|
// 扩展正则方法
|
||||||
@ -38,9 +39,9 @@ export default class WuHuTornHelper extends WuhuBase {
|
|||||||
|
|
||||||
// 监听fetch
|
// 监听fetch
|
||||||
const ori_fetch = window.fetch;
|
const ori_fetch = window.fetch;
|
||||||
window.fetch = async (url: string, init: RequestInit) => {
|
window.fetch = (url: string, init: RequestInit) => {
|
||||||
let startTime = performance.now();
|
let startTime = performance.now();
|
||||||
Log.info('FETCH调用:[' + url + ']');
|
Log.info('FETCH调用:[' + url + '], init:', init);
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
if (url.contains('newsTickers')) {
|
if (url.contains('newsTickers')) {
|
||||||
Log.info('阻止获取新闻横幅');
|
Log.info('阻止获取新闻横幅');
|
||||||
@ -55,16 +56,12 @@ export default class WuHuTornHelper extends WuhuBase {
|
|||||||
ori_fetch(url, init).then(res => {
|
ori_fetch(url, init).then(res => {
|
||||||
// mini profile 翻译
|
// mini profile 翻译
|
||||||
if (url.includes('profiles.php?step=getUserNameContextMenu') && WuhuConfig.get('transEnable')) {
|
if (url.includes('profiles.php?step=getUserNameContextMenu') && WuhuConfig.get('transEnable')) {
|
||||||
setTimeout(() => miniprofTrans(), 200);
|
window.setTimeout(() => miniprofTrans(), 200);
|
||||||
}
|
}
|
||||||
let clone = res.clone();
|
let clone = res.clone();
|
||||||
res.text().then(text => Log.info('FETCH响应,耗时' + ((performance.now() - startTime) | 0) + 'ms', {
|
res.text().then(text => Log.info('FETCH响应,耗时' + ((performance.now() - startTime) | 0) + 'ms', { response: text }));
|
||||||
url,
|
|
||||||
init,
|
|
||||||
text
|
|
||||||
}));
|
|
||||||
resolve(clone);
|
resolve(clone);
|
||||||
})
|
});
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -31,6 +31,7 @@ import Global from "./Global";
|
|||||||
import BuyBeerHelper from "./action/BuyBeerHelper";
|
import BuyBeerHelper from "./action/BuyBeerHelper";
|
||||||
|
|
||||||
export default class ZhongIcon extends WuhuBase {
|
export default class ZhongIcon extends WuhuBase {
|
||||||
|
className = 'ZhongIcon';
|
||||||
public static ZhongNode: MyHTMLElement = null;
|
public static ZhongNode: MyHTMLElement = null;
|
||||||
private menuItemList: MenuItemConfig[] = null;
|
private menuItemList: MenuItemConfig[] = null;
|
||||||
private settingItemList: MenuItemConfig[] = null;
|
private settingItemList: MenuItemConfig[] = null;
|
||||||
@ -46,7 +47,7 @@ export default class ZhongIcon extends WuhuBase {
|
|||||||
Log.info('设置图标结束, ZhongIcon初始化结束');
|
Log.info('设置图标结束, ZhongIcon初始化结束');
|
||||||
}
|
}
|
||||||
|
|
||||||
private elemGenerator(setting: MenuItemConfig, root_node: Node) {
|
private elemGenerator(setting: MenuItemConfig, root_node: Element): HTMLElement {
|
||||||
let { tip, domType } = setting;
|
let { tip, domType } = setting;
|
||||||
let new_node = null;
|
let new_node = null;
|
||||||
switch (domType) {
|
switch (domType) {
|
||||||
@ -120,7 +121,7 @@ export default class ZhongIcon extends WuhuBase {
|
|||||||
let zhong_node: MyHTMLElement = document.querySelector('div#wh-trans-icon');
|
let zhong_node: MyHTMLElement = document.querySelector('div#wh-trans-icon');
|
||||||
let settings = this.menuItemList;
|
let settings = this.menuItemList;
|
||||||
let { version } = WuhuBase.glob;
|
let { version } = WuhuBase.glob;
|
||||||
if ((self !== top) || !!zhong_node) return zhong_node;
|
if ((self !== top) || !!zhong_node) return null;
|
||||||
zhong_node = document.createElement('div');
|
zhong_node = document.createElement('div');
|
||||||
zhong_node.id = 'wh-trans-icon';
|
zhong_node.id = 'wh-trans-icon';
|
||||||
zhong_node.classList.add('cont-gray');
|
zhong_node.classList.add('cont-gray');
|
||||||
@ -135,7 +136,6 @@ export default class ZhongIcon extends WuhuBase {
|
|||||||
(<MyHTMLElement>zhong_node.querySelector('#wh-trans-icon-btn')).onclick = () => {
|
(<MyHTMLElement>zhong_node.querySelector('#wh-trans-icon-btn')).onclick = () => {
|
||||||
zhong_node.classList.toggle('wh-icon-expanded');
|
zhong_node.classList.toggle('wh-icon-expanded');
|
||||||
const click_func = e => {
|
const click_func = e => {
|
||||||
// e.stopImmediatePropagation();
|
|
||||||
Log.info(e.target);
|
Log.info(e.target);
|
||||||
if (e.target === zhong_node.querySelector('#wh-trans-icon-btn')) return;
|
if (e.target === zhong_node.querySelector('#wh-trans-icon-btn')) return;
|
||||||
if (!zhong_node.contains(e.target)) {
|
if (!zhong_node.contains(e.target)) {
|
||||||
@ -203,7 +203,6 @@ export default class ZhongIcon extends WuhuBase {
|
|||||||
// 加载torn mini profile
|
// 加载torn mini profile
|
||||||
initMiniProf('#wh-trans-icon');
|
initMiniProf('#wh-trans-icon');
|
||||||
ZhongIcon.ZhongNode = zhong_node;
|
ZhongIcon.ZhongNode = zhong_node;
|
||||||
// return zhong_node;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 菜单
|
// 菜单
|
||||||
@ -1198,15 +1197,15 @@ export default class ZhongIcon extends WuhuBase {
|
|||||||
domType: 'button', domId: 'wh-otherBtn', domText: '更多设定',
|
domType: 'button', domId: 'wh-otherBtn', domText: '更多设定',
|
||||||
clickFunc: () => {
|
clickFunc: () => {
|
||||||
let pop = new Popup('', '更多设定');
|
let pop = new Popup('', '更多设定');
|
||||||
let insertHtml = '<p><button class="torn-btn">清空设置数据</button></p><p><button class="torn-btn">请求通知权限</button></p><p><button class="torn-btn">测试跨域请求</button></p>';
|
let insertHtml = '<p><button class="torn-btn">清空设置</button></p><p><button class="torn-btn">通知权限</button></p><p><button class="torn-btn">外部数据权限</button></p>';
|
||||||
pop.getElement().insertAdjacentHTML('beforeend', insertHtml);
|
pop.getElement().insertAdjacentHTML('beforeend', insertHtml);
|
||||||
let [btn1, btn2, btn3] = Array.from(pop.getElement().querySelectorAll('button'));
|
let [btn1, btn2, btn3] = Array.from(pop.getElement().querySelectorAll('button'));
|
||||||
btn1.addEventListener('click', () => {
|
btn1.addEventListener('click', () => {
|
||||||
localStorage.setItem('wh_trv_alarm', '');
|
localStorage.removeItem('wh_trv_alarm');
|
||||||
localStorage.setItem('wh_trans_settings', '');
|
localStorage.removeItem('wh_trans_settings');
|
||||||
localStorage.setItem('whuuid', '');
|
localStorage.removeItem('whuuid');
|
||||||
localStorage.setItem('wh-gs-storage', '');
|
localStorage.removeItem('wh-gs-storage');
|
||||||
localStorage.setItem('WHTEST', '');
|
localStorage.removeItem('WHTEST');
|
||||||
new Alert('已清空,刷新页面');
|
new Alert('已清空,刷新页面');
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
});
|
});
|
||||||
|
|||||||
@ -8,6 +8,7 @@ import NOTIFY_HTML from "../../static/html/buyBeer/notify.html";
|
|||||||
import CommonUtils from "../utils/CommonUtils";
|
import CommonUtils from "../utils/CommonUtils";
|
||||||
|
|
||||||
export default class BuyBeerHelper extends WuhuBase implements BeerMonitorLoop {
|
export default class BuyBeerHelper extends WuhuBase implements BeerMonitorLoop {
|
||||||
|
className = 'BuyBeerHelper';
|
||||||
|
|
||||||
private isNotifying = false;
|
private isNotifying = false;
|
||||||
private loopId: number = null;
|
private loopId: number = null;
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import CommonUtils from "../utils/CommonUtils";
|
|||||||
import TornStyleBlock from "../utils/TornStyleBlock";
|
import TornStyleBlock from "../utils/TornStyleBlock";
|
||||||
|
|
||||||
export default class LotteryHelper extends WuhuBase {
|
export default class LotteryHelper extends WuhuBase {
|
||||||
|
className = 'LotteryHelper';
|
||||||
private loopFlag = true;
|
private loopFlag = true;
|
||||||
|
|
||||||
private radioDaily: HTMLInputElement = null;
|
private radioDaily: HTMLInputElement = null;
|
||||||
|
|||||||
@ -5,6 +5,7 @@ import Alert from "../utils/Alert";
|
|||||||
import TornStyleSwitch from "../utils/TornStyleSwitch";
|
import TornStyleSwitch from "../utils/TornStyleSwitch";
|
||||||
|
|
||||||
export default class PTHelper extends WuhuBase {
|
export default class PTHelper extends WuhuBase {
|
||||||
|
className = 'PTHelper';
|
||||||
private readonly observer;
|
private readonly observer;
|
||||||
private readonly usersPointSell;
|
private readonly usersPointSell;
|
||||||
|
|
||||||
|
|||||||
@ -4,6 +4,7 @@ import WuhuConfig from "../WuhuConfig";
|
|||||||
import TornStyleSwitch from "../utils/TornStyleSwitch";
|
import TornStyleSwitch from "../utils/TornStyleSwitch";
|
||||||
|
|
||||||
export default class StackHelper extends WuhuBase {
|
export default class StackHelper extends WuhuBase {
|
||||||
|
className = 'StackHelper';
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
let block = new TornStyleBlock('叠E保护').insert2Dom();
|
let block = new TornStyleBlock('叠E保护').insert2Dom();
|
||||||
|
|||||||
@ -8,6 +8,7 @@ import * as FILTER from "../../static/json/for_stock_item_filter.json";
|
|||||||
import WindowActiveState from "./WindowActiveState";
|
import WindowActiveState from "./WindowActiveState";
|
||||||
|
|
||||||
export default class TravelItem extends WuhuBase {
|
export default class TravelItem extends WuhuBase {
|
||||||
|
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;
|
||||||
|
|
||||||
|
|||||||
@ -2,6 +2,7 @@ import uuidv4 from "../../func/utils/uuidv4";
|
|||||||
import WuhuBase from "../WuhuBase";
|
import WuhuBase from "../WuhuBase";
|
||||||
|
|
||||||
export default class WindowActiveState extends WuhuBase {
|
export default class WindowActiveState extends WuhuBase {
|
||||||
|
className = 'WindowActiveState';
|
||||||
isFocus = false;
|
isFocus = false;
|
||||||
uuid = uuidv4();
|
uuid = uuidv4();
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,12 @@ import CommonUtils from "../utils/CommonUtils";
|
|||||||
import XUNZHAOMUZHUANG_CSS from "../../static/css/xunzhaomuzhuang.css";
|
import XUNZHAOMUZHUANG_CSS from "../../static/css/xunzhaomuzhuang.css";
|
||||||
import TornStyleBlock from "../utils/TornStyleBlock";
|
import TornStyleBlock from "../utils/TornStyleBlock";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 寻找木桩
|
||||||
|
* /item.php?temp=4#xunzhaomuzhuang
|
||||||
|
*/
|
||||||
export default class XZMZ extends WuhuBase {
|
export default class XZMZ extends WuhuBase {
|
||||||
|
className = 'XZMZ';
|
||||||
private readonly mainRoleContainer: HTMLElement;
|
private readonly mainRoleContainer: HTMLElement;
|
||||||
private readonly IDList: number[];
|
private readonly IDList: number[];
|
||||||
private readonly btn: HTMLButtonElement;
|
private readonly btn: HTMLButtonElement;
|
||||||
@ -44,8 +49,9 @@ export default class XZMZ extends WuhuBase {
|
|||||||
CommonUtils.ajaxFetch({
|
CommonUtils.ajaxFetch({
|
||||||
url: window.addRFC('https://www.torn.com/profiles.php?step=getProfileData&XID=' + id),
|
url: window.addRFC('https://www.torn.com/profiles.php?step=getProfileData&XID=' + id),
|
||||||
method: 'GET'
|
method: 'GET'
|
||||||
})
|
}).then((res) =>
|
||||||
.then((res) => res.json())
|
res.json()
|
||||||
|
)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
this.counter--;
|
this.counter--;
|
||||||
if (res.userStatus.status.type === 'ok') {
|
if (res.userStatus.status.type === 'ok') {
|
||||||
@ -79,7 +85,7 @@ export default class XZMZ extends WuhuBase {
|
|||||||
$node += '<td style="border: 1px solid darkgray;padding:5px;text-align:center;">' + data.player_id + '</td>'
|
$node += '<td style="border: 1px solid darkgray;padding:5px;text-align:center;">' + data.player_id + '</td>'
|
||||||
$node += `<td style="border: 1px solid darkgray;padding:5px;text-align:center;"><a href="/profiles.php?XID=${ data.player_id }">${ data.name }</a></td>`;
|
$node += `<td style="border: 1px solid darkgray;padding:5px;text-align:center;"><a href="/profiles.php?XID=${ data.player_id }">${ data.name }</a></td>`;
|
||||||
$node += '<td style="border: 1px solid darkgray;padding:5px;text-align:center;">' + data.level + '</td>'
|
$node += '<td style="border: 1px solid darkgray;padding:5px;text-align:center;">' + data.level + '</td>'
|
||||||
$node += '<td style="border: 1px solid darkgray;padding:5px;text-align:center;"><a href="https://www.torn.com/loader.php?sid=attack&user2ID=' + data.player_id + '" target="_blank">攻击</a></td>'
|
$node += '<td style="border: 1px solid darkgray;padding:5px;text-align:center;"><a href="https://www.torn.com/loader.php?sid=attack&user2ID=' + data.player_id + '" target="_blank" class="torn-btn">攻击</a></td>'
|
||||||
$parentNode.insertAdjacentHTML('beforeend', $node)
|
$parentNode.insertAdjacentHTML('beforeend', $node)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,7 +1,10 @@
|
|||||||
|
import Log from "../Log";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 基类、单例
|
* 基类、单例
|
||||||
*/
|
*/
|
||||||
export default class Provider {
|
export default class Provider {
|
||||||
|
protected readonly className: string = 'Provider';
|
||||||
private static instance;
|
private static instance;
|
||||||
|
|
||||||
private static readonly pool = {};
|
private static readonly pool = {};
|
||||||
@ -13,7 +16,9 @@ export default class Provider {
|
|||||||
// return this.instance ||= new this();
|
// return this.instance ||= new this();
|
||||||
if (!this.instance) {
|
if (!this.instance) {
|
||||||
this.instance = new this();
|
this.instance = new this();
|
||||||
Provider.pool[this.name] = this.instance;
|
let thatName = this.instance.getClassName() || this.name;
|
||||||
|
Log.info('新建实例,', thatName, this.instance);
|
||||||
|
Provider.pool[thatName] = this.instance;
|
||||||
}
|
}
|
||||||
return this.instance;
|
return this.instance;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,12 +1,22 @@
|
|||||||
import Log from "../Log";
|
import Log from "../Log";
|
||||||
|
import ZhongIcon from "../ZhongIcon";
|
||||||
|
|
||||||
export default class Starter {
|
export default class Starter {
|
||||||
public static run(T): void {
|
public static run(T): void {
|
||||||
|
|
||||||
|
if (window.WHTRANS) throw '退出, 已运行次数' + window.WHTRANS;
|
||||||
|
window.WHTRANS = window.WHTRANS === undefined ? 1 : window.WHTRANS++;
|
||||||
|
|
||||||
|
let started = performance.now();
|
||||||
try {
|
try {
|
||||||
T.main();
|
T.main();
|
||||||
} catch (error) {
|
} catch (e) {
|
||||||
Log.error(error);
|
Log.error('加载出错');
|
||||||
Log.error('[Starter] trace: ', JSON.stringify({ error }));
|
Log.error('[Starter]', e.message || JSON.stringify(e));
|
||||||
}
|
}
|
||||||
|
let runTime: number = (performance.now() - started) | 0;
|
||||||
|
Log.info(`加载时间${ runTime }ms`);
|
||||||
|
if (ZhongIcon.ZhongNode && ZhongIcon.ZhongNode.initTimer)
|
||||||
|
ZhongIcon.ZhongNode.initTimer.innerHTML = `加载时间 ${ runTime }ms`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3,6 +3,7 @@ import Log from "../Log";
|
|||||||
import ZhongIcon from "../ZhongIcon";
|
import ZhongIcon from "../ZhongIcon";
|
||||||
|
|
||||||
export default class ActionButtonUtils extends WuhuBase {
|
export default class ActionButtonUtils extends WuhuBase {
|
||||||
|
className = 'ActionButtonUtils';
|
||||||
private hasAdded: boolean = false;
|
private hasAdded: boolean = false;
|
||||||
|
|
||||||
public add(txt: string, func: (ev: Event) => void = () => null): void {
|
public add(txt: string, func: (ev: Event) => void = () => null): void {
|
||||||
|
|||||||
@ -7,6 +7,7 @@ import NOTIFY_HTML from "../../static/html/notify.html";
|
|||||||
import WindowActiveState from "../action/WindowActiveState";
|
import WindowActiveState from "../action/WindowActiveState";
|
||||||
|
|
||||||
export default class Alert extends WuhuBase {
|
export default class Alert extends WuhuBase {
|
||||||
|
className = 'Alert';
|
||||||
private static container: HTMLElement = null;
|
private static container: HTMLElement = null;
|
||||||
|
|
||||||
private notify: MyHTMLElement = null;
|
private notify: MyHTMLElement = null;
|
||||||
|
|||||||
@ -7,9 +7,11 @@ import Alert from "./Alert";
|
|||||||
import LOADING_IMG_HTML from "../../static/html/loading_img.html";
|
import LOADING_IMG_HTML from "../../static/html/loading_img.html";
|
||||||
|
|
||||||
export default class CommonUtils extends WuhuBase {
|
export default class CommonUtils extends WuhuBase {
|
||||||
|
className = 'CommonUtils';
|
||||||
|
|
||||||
static getScriptEngine() {
|
static getScriptEngine() {
|
||||||
let glob = CommonUtils.glob;
|
let glob = CommonUtils.glob;
|
||||||
return glob.unsafeWindow ? UserScriptEngine.GM : glob.isPDA
|
return glob.GM_xmlhttpRequest ? UserScriptEngine.GM : glob.isPDA
|
||||||
? UserScriptEngine.PDA : UserScriptEngine.RAW;
|
? UserScriptEngine.PDA : UserScriptEngine.RAW;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
import WuhuBase from "../WuhuBase";
|
import WuhuBase from "../WuhuBase";
|
||||||
|
|
||||||
export default class FetchUtils extends WuhuBase {
|
export default class FetchUtils extends WuhuBase {
|
||||||
|
className = 'FetchUtils';
|
||||||
/**
|
/**
|
||||||
* 包装jquery ajax 异步返回string
|
* 包装jquery ajax 异步返回string
|
||||||
* @param url
|
* @param url
|
||||||
|
|||||||
@ -5,6 +5,7 @@ import Log from "../Log";
|
|||||||
import CommonUtils from "./CommonUtils";
|
import CommonUtils from "./CommonUtils";
|
||||||
|
|
||||||
export default class InfoUtils extends WuhuBase {
|
export default class InfoUtils extends WuhuBase {
|
||||||
|
className = 'InfoUtils';
|
||||||
/**
|
/**
|
||||||
* 返回玩家信息的对象 { playername: string, userID: number }
|
* 返回玩家信息的对象 { playername: string, userID: number }
|
||||||
* @return {PlayerInfo} rs
|
* @return {PlayerInfo} rs
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
import WuhuBase from "../WuhuBase";
|
import WuhuBase from "../WuhuBase";
|
||||||
|
|
||||||
export default class MDUtils extends WuhuBase {
|
export default class MDUtils extends WuhuBase {
|
||||||
|
className = 'MDUtils';
|
||||||
/**
|
/**
|
||||||
* 解析 Markdown 内容
|
* 解析 Markdown 内容
|
||||||
* @param {String} from
|
* @param {String} from
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
import WuhuBase from "../WuhuBase";
|
import WuhuBase from "../WuhuBase";
|
||||||
|
|
||||||
export default class MathUtils extends WuhuBase {
|
export default class MathUtils extends WuhuBase {
|
||||||
|
className = 'MathUtils';
|
||||||
// 得到一个两数之间的随机整数
|
// 得到一个两数之间的随机整数
|
||||||
public getRandomInt(min: number, max: number): number {
|
public getRandomInt(min: number, max: number): number {
|
||||||
min = Math.ceil(min);
|
min = Math.ceil(min);
|
||||||
|
|||||||
@ -3,6 +3,7 @@ import Log from "../Log";
|
|||||||
import WuhuBase from "../WuhuBase";
|
import WuhuBase from "../WuhuBase";
|
||||||
|
|
||||||
export default class NotificationUtils extends WuhuBase {
|
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 {
|
||||||
|
|||||||
@ -3,7 +3,7 @@ import POPUP_HTML from "../../static/html/popup.html";
|
|||||||
import Log from "../Log";
|
import Log from "../Log";
|
||||||
|
|
||||||
export default class Popup extends WuhuBase {
|
export default class Popup extends WuhuBase {
|
||||||
protected className = 'Popup';
|
className = 'Popup';
|
||||||
private readonly container: HTMLElement = null;
|
private readonly container: HTMLElement = null;
|
||||||
private readonly node: HTMLElement = null;
|
private readonly node: HTMLElement = null;
|
||||||
|
|
||||||
|
|||||||
@ -204,8 +204,9 @@ export default async function travelHelper(): Promise<null> {
|
|||||||
}
|
}
|
||||||
// 解毒提醒
|
// 解毒提醒
|
||||||
if (bodyAttrs['data-country'] === 'switzerland') {
|
if (bodyAttrs['data-country'] === 'switzerland') {
|
||||||
let block = new TornStyleBlock('解毒提醒').insert2Dom();
|
let block = new TornStyleBlock('解毒提醒');
|
||||||
block.setContent('<p><a href="/index.php?page=rehab">❤️ 点击前往解毒</a></p>');
|
block.setContent('<p><a href="/index.php?page=rehab">❤️ 点击前往解毒</a></p>');
|
||||||
|
document.querySelector('h4#skip-to-content').before(block.getBase());
|
||||||
// let page_title = document.querySelector('h4#skip-to-content');
|
// let page_title = document.querySelector('h4#skip-to-content');
|
||||||
// let msg = document.createElement('div');
|
// let msg = document.createElement('div');
|
||||||
// msg.innerHTML = `<div class="info-msg border-round">
|
// msg.innerHTML = `<div class="info-msg border-round">
|
||||||
|
|||||||
@ -2,6 +2,7 @@ interface MyHTMLElement extends HTMLElement {
|
|||||||
sys_notify?: Notification;
|
sys_notify?: Notification;
|
||||||
msgInnerText?: string;
|
msgInnerText?: string;
|
||||||
close?: () => void;
|
close?: () => void;
|
||||||
|
initTimer?: HTMLElement;
|
||||||
|
|
||||||
// 对象的其他参数
|
// 对象的其他参数
|
||||||
[key: string]: any;
|
[key: string]: any;
|
||||||
|
|||||||
@ -19,9 +19,9 @@
|
|||||||
<th style="border: 1px solid darkgray;padding: 5px;background-color: black;color: white;font-weight: bold;text-align:center;">
|
<th style="border: 1px solid darkgray;padding: 5px;background-color: black;color: white;font-weight: bold;text-align:center;">
|
||||||
攻击
|
攻击
|
||||||
</th>
|
</th>
|
||||||
<th style="border: 1px solid darkgray;padding: 5px;background-color: black;color: white;font-weight: bold;text-align:center;">
|
<!-- <th style="border: 1px solid darkgray;padding: 5px;background-color: black;color: white;font-weight: bold;text-align:center;">-->
|
||||||
BS(M)
|
<!-- BS(M)-->
|
||||||
</th>
|
<!-- </th>-->
|
||||||
</thead>
|
</thead>
|
||||||
<tbody id="table-body"></tbody>
|
<tbody id="table-body"></tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
@ -1,17 +1,17 @@
|
|||||||
import WuhuBase from "../class/WuhuBase";
|
import WuhuBase from "../class/WuhuBase";
|
||||||
import Log from "../class/Log";
|
import Log from "../class/Log";
|
||||||
import Popup from "../class/utils/Popup";
|
import Popup from "../class/utils/Popup";
|
||||||
import TornStyleSwitch from "../class/utils/TornStyleSwitch";
|
|
||||||
import CommonUtils from "../class/utils/CommonUtils";
|
|
||||||
|
|
||||||
export default class Test extends WuhuBase {
|
export default class Test extends WuhuBase {
|
||||||
|
className = 'Test';
|
||||||
public test(): void {
|
public test(): void {
|
||||||
let popup = new Popup('test');
|
let popup = new Popup('');
|
||||||
popup.getElement()['__POOL__'] = Test.getPool();
|
popup.getElement()['__POOL__'] = Test.getPool();
|
||||||
popup.getElement().append(new TornStyleSwitch('123').getBase());
|
|
||||||
|
|
||||||
|
// this.case1()
|
||||||
// this.case2()
|
// this.case2()
|
||||||
this.case3().then();
|
this.case3().then();
|
||||||
|
// window.fetch('/test').then(res=>res.text()).then(o=>Log.info(o))
|
||||||
}
|
}
|
||||||
|
|
||||||
private case1() {
|
private case1() {
|
||||||
@ -44,9 +44,10 @@ export default class Test extends WuhuBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async case3() {
|
private async case3() {
|
||||||
Log.info(await CommonUtils.ajaxFetch({
|
Log.info('window.addRFC', typeof window.addRFC);
|
||||||
url: window.addRFC('https://www.torn.com/profiles.php?step=getProfileData&XID=17003'),
|
Log.info('window.getAction', typeof window.getAction);
|
||||||
method: 'GET'
|
Log.info('window.initializeTooltip', typeof window.initializeTooltip);
|
||||||
}));
|
Log.info('window.renderMiniProfile', typeof window.renderMiniProfile);
|
||||||
|
// 12
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user