TS重构
This commit is contained in:
parent
f00148b708
commit
bb83b98a23
@ -21,7 +21,7 @@ export default class Global extends WuhuBase implements IGlobal {
|
|||||||
// 海外库存
|
// 海外库存
|
||||||
fStock: { get: () => Promise<any> } = null;
|
fStock: { get: () => Promise<any> } = null;
|
||||||
// 玩家名和数字id
|
// 玩家名和数字id
|
||||||
player_info: PlayerInfo = null;
|
player_info = null;
|
||||||
// 设备类型
|
// 设备类型
|
||||||
device: Device = null;
|
device: Device = null;
|
||||||
// PDA运行环境
|
// PDA运行环境
|
||||||
@ -70,18 +70,6 @@ export default class Global extends WuhuBase implements IGlobal {
|
|||||||
this.unsafeWindow.whtest = 'unsafeWindow';
|
this.unsafeWindow.whtest = 'unsafeWindow';
|
||||||
window = this.unsafeWindow || this.window;
|
window = this.unsafeWindow || this.window;
|
||||||
Log.info('替换window上下文');
|
Log.info('替换window上下文');
|
||||||
Log.info({
|
|
||||||
setInterval, clearInterval,
|
|
||||||
'window.setInterval': window.setInterval,
|
|
||||||
'window.clearInterval': window.clearInterval,
|
|
||||||
'this.unsafeWindow.setInterval': this.unsafeWindow.setInterval,
|
|
||||||
'this.unsafeWindow.clearInterval': this.unsafeWindow.clearInterval,
|
|
||||||
'this.window.setInterval': this.window.setInterval,
|
|
||||||
'this.window.clearInterval': this.window.clearInterval,
|
|
||||||
})
|
|
||||||
// Log.info(window.whtest)
|
|
||||||
// Log.info(this.unsafeWindow.whtest)
|
|
||||||
// Log.info(this.window.whtest)
|
|
||||||
} catch {
|
} catch {
|
||||||
this.unsafeWindow = null;
|
this.unsafeWindow = null;
|
||||||
this.GM_xmlhttpRequest = null;
|
this.GM_xmlhttpRequest = null;
|
||||||
|
|||||||
@ -1,15 +1,15 @@
|
|||||||
export default class Log {
|
export default class Log {
|
||||||
static info(...o) {
|
static info(...o): void {
|
||||||
if (this.debug()) {
|
if (this.debug()) {
|
||||||
console.log('[WH]', this.getTime(), ...o)
|
console.log('[WH]', this.getTime(), ...o)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static error(...o) {
|
static error(...o): void {
|
||||||
(this.debug()) && (console.error('[WH]', this.getTime(), ...o))
|
(this.debug()) && (console.error('[WH]', this.getTime(), ...o))
|
||||||
}
|
}
|
||||||
|
|
||||||
static debug() {
|
static debug(): boolean {
|
||||||
let ret: boolean;
|
let ret: boolean;
|
||||||
try {
|
try {
|
||||||
let local = JSON.parse(localStorage.getItem('wh_trans_settings'));
|
let local = JSON.parse(localStorage.getItem('wh_trans_settings'));
|
||||||
@ -21,7 +21,7 @@ export default class Log {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static getTime() {
|
static getTime(): string {
|
||||||
let d = new Date();
|
let d = new Date();
|
||||||
let year = d.getFullYear();
|
let year = d.getFullYear();
|
||||||
let month = ('0' + (d.getMonth() + 1)).slice(-2);
|
let month = ('0' + (d.getMonth() + 1)).slice(-2);
|
||||||
|
|||||||
@ -23,8 +23,4 @@ export default class WuhuBase {
|
|||||||
constructor() {
|
constructor() {
|
||||||
Log.info('创建对象:' + this.constructor.name)
|
Log.info('创建对象:' + this.constructor.name)
|
||||||
}
|
}
|
||||||
|
|
||||||
static getGlob(): IGlobal {
|
|
||||||
return this.glob
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@ -1,17 +1,18 @@
|
|||||||
import WuhuBase from "./WuhuBase";
|
import WuhuBase from "./WuhuBase";
|
||||||
|
import Alert from "./utils/Alert";
|
||||||
|
|
||||||
export default class WuhuConfig extends WuhuBase {
|
export default class WuhuConfig extends WuhuBase {
|
||||||
static get(key: string) {
|
static get(key: string) {
|
||||||
return WuhuBase.getLocal()[key];
|
return WuhuConfig.getLocal()[key];
|
||||||
}
|
}
|
||||||
|
|
||||||
static set(key: string, val: any, callback: Function = () => {
|
static set(key: string, val: any, callback: Function = () => null, isNotify = false) {
|
||||||
}) {
|
let config = WuhuConfig.getLocal();
|
||||||
let config = WuhuBase.getLocal();
|
|
||||||
config[key] = val;
|
config[key] = val;
|
||||||
localStorage.setItem('wh_trans_settings', JSON.stringify(config));
|
localStorage.setItem('wh_trans_settings', JSON.stringify(config));
|
||||||
|
|
||||||
// if (isNotify) WHNotify('已保存设置')
|
if (isNotify)
|
||||||
|
new Alert('已保存设置')
|
||||||
new Promise(() => callback()).then();
|
new Promise(() => callback()).then();
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,24 +1,24 @@
|
|||||||
import getWhSettingObj from "../func/utils/getWhSettingObj";
|
|
||||||
import miniprofTrans from "../func/translate/miniprofTrans";
|
import miniprofTrans from "../func/translate/miniprofTrans";
|
||||||
import addStyle from "../func/utils/addStyle";
|
|
||||||
import Utils from "./utils/Utils";
|
import Utils from "./utils/Utils";
|
||||||
import WuhuBase from "./WuhuBase";
|
import WuhuBase from "./WuhuBase";
|
||||||
import TravelItem from "./action/TravelItem";
|
import TravelItem from "./action/TravelItem";
|
||||||
import Global from "./Global";
|
import Global from "./Global";
|
||||||
import Log from "./Log";
|
import Log from "./Log";
|
||||||
|
import WuhuConfig from "./WuhuConfig";
|
||||||
|
|
||||||
export default class WuHuTornHelper extends WuhuBase {
|
export default class WuHuTornHelper extends WuhuBase {
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
Log.info('WuHuTornHelper初始化');
|
Log.info('WuHuTornHelper初始化');
|
||||||
WuhuBase.glob = Global.getInstance();
|
WuhuBase.glob = Global.getInstance();
|
||||||
let glob = WuhuBase.glob;
|
let glob = WuHuTornHelper.glob;
|
||||||
glob.fStock = TravelItem.getInstance();
|
glob.fStock = TravelItem.getInstance();
|
||||||
Log.info(glob.fStock)
|
Log.info('fStock: ', glob.fStock)
|
||||||
|
|
||||||
// 请求通知权限
|
// 请求通知权限
|
||||||
if (window.Notification && Notification.permission !== 'granted') {
|
if (window.Notification && window.Notification.permission !== 'granted') {
|
||||||
Notification.requestPermission().then();
|
window.alert("芜湖助手即将请求浏览器通知权限……");
|
||||||
|
window.Notification.requestPermission().then();
|
||||||
} else {
|
} else {
|
||||||
Log.info({ Notification });
|
Log.info({ Notification });
|
||||||
}
|
}
|
||||||
@ -42,7 +42,7 @@ export default class WuHuTornHelper extends WuhuBase {
|
|||||||
}
|
}
|
||||||
const res = await ori_fetch(url, init);
|
const res = await ori_fetch(url, init);
|
||||||
// mini profile 翻译
|
// mini profile 翻译
|
||||||
if (url.includes('profiles.php?step=getUserNameContextMenu') && getWhSettingObj()['transEnable']) {
|
if (url.includes('profiles.php?step=getUserNameContextMenu') && WuhuConfig.get('transEnable')) {
|
||||||
setTimeout(() => miniprofTrans(), 200);
|
setTimeout(() => miniprofTrans(), 200);
|
||||||
}
|
}
|
||||||
let clone = res.clone();
|
let clone = res.clone();
|
||||||
@ -51,7 +51,7 @@ export default class WuHuTornHelper extends WuhuBase {
|
|||||||
return clone;
|
return clone;
|
||||||
};
|
};
|
||||||
|
|
||||||
addStyle(`
|
Utils.addStyle(`
|
||||||
.wh-hide{display:none;}
|
.wh-hide{display:none;}
|
||||||
#wh-trans-icon{
|
#wh-trans-icon{
|
||||||
user-select:none;
|
user-select:none;
|
||||||
@ -196,6 +196,45 @@ div#wh-popup::after {
|
|||||||
#wh-gym-info-cont button{
|
#wh-gym-info-cont button{
|
||||||
cursor:pointer;
|
cursor:pointer;
|
||||||
}
|
}
|
||||||
|
#wh-notify {
|
||||||
|
display: inline-block;
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
left: calc(50% - 180px);
|
||||||
|
width: 360px;
|
||||||
|
z-index: 9999990;
|
||||||
|
color:#333;
|
||||||
|
}
|
||||||
|
#wh-notify a{
|
||||||
|
color:red;
|
||||||
|
text-decoration:none;
|
||||||
|
}
|
||||||
|
#wh-notify .wh-notify-item {
|
||||||
|
/*height: 50px;*/
|
||||||
|
background: rgb(239 249 255 / 90%);
|
||||||
|
border-radius: 2px;
|
||||||
|
margin: 0.5em 0 0 0;
|
||||||
|
box-shadow: 0 0 5px 0px #959595;
|
||||||
|
}
|
||||||
|
#wh-notify .wh-notify-item:hover {
|
||||||
|
background: rgb(239 249 255 / 98%);
|
||||||
|
}
|
||||||
|
#wh-notify .wh-notify-item .wh-notify-bar {
|
||||||
|
height:2px;
|
||||||
|
background:#2196f3;
|
||||||
|
}
|
||||||
|
#wh-notify .wh-notify-item .wh-notify-close {
|
||||||
|
float:right;
|
||||||
|
padding:0;
|
||||||
|
width:16px;height:16px;
|
||||||
|
background:url('data:image/svg+xml,%3Csvg%20viewBox%3D%220%200%201024%201024%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20d%3D%22M923%20571H130.7c-27.6%200-50-22.4-50-50s22.4-50%2050-50H923c27.6%200%2050%2022.4%2050%2050s-22.4%2050-50%2050z%22%20fill%3D%22%232196f3%22%3E%3C%2Fpath%3E%3C%2Fsvg%3E') no-repeat center;
|
||||||
|
background-size:100%;
|
||||||
|
margin: 6px 6px 0 0;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
#wh-notify .wh-notify-item .wh-notify-msg {
|
||||||
|
padding:12px;
|
||||||
|
}
|
||||||
`);
|
`);
|
||||||
|
|
||||||
// 测试用
|
// 测试用
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
import popupMsg from "../func/utils/popupMsg";
|
import popupMsg from "../func/utils/popupMsg";
|
||||||
import WHNotify from "../func/utils/WHNotify";
|
import WHNotify from "../func/utils/WHNotify";
|
||||||
import forStock from "../func/utils/forStock";
|
import forStock from "../func/utils/forStock";
|
||||||
import addStyle from "../func/utils/addStyle";
|
|
||||||
import doQuickFly from "../func/module/doQuickFly";
|
import doQuickFly from "../func/module/doQuickFly";
|
||||||
import loadGS from "../func/module/loadGS";
|
import loadGS from "../func/module/loadGS";
|
||||||
import loading_gif_html from "../func/utils/loading_gif_html";
|
import loading_gif_html from "../func/utils/loading_gif_html";
|
||||||
@ -16,7 +15,6 @@ import WuhuBase from "./WuhuBase";
|
|||||||
import Log from "./Log";
|
import Log from "./Log";
|
||||||
import Utils from "./utils/Utils";
|
import Utils from "./utils/Utils";
|
||||||
import WuhuConfig from "./WuhuConfig";
|
import WuhuConfig from "./WuhuConfig";
|
||||||
import Alert from "./utils/Alert";
|
|
||||||
|
|
||||||
export default class ZhongIcon extends WuhuBase {
|
export default class ZhongIcon extends WuhuBase {
|
||||||
static ZhongNode: MyHTMLElement = null;
|
static ZhongNode: MyHTMLElement = null;
|
||||||
@ -380,7 +378,7 @@ export default class ZhongIcon extends WuhuBase {
|
|||||||
clickFunc: async function () {
|
clickFunc: async function () {
|
||||||
if (window.hasWHQuickFlyOpt) return;
|
if (window.hasWHQuickFlyOpt) return;
|
||||||
window.hasWHQuickFlyOpt = true;
|
window.hasWHQuickFlyOpt = true;
|
||||||
addStyle(`#wh-quick-fly-opt{
|
Utils.addStyle(`#wh-quick-fly-opt{
|
||||||
position:fixed;
|
position:fixed;
|
||||||
left:64px;
|
left:64px;
|
||||||
top:64px;
|
top:64px;
|
||||||
@ -595,7 +593,7 @@ info{display:block;}
|
|||||||
domText: '🔗 常用链接',
|
domText: '🔗 常用链接',
|
||||||
clickFunc: function (e) {
|
clickFunc: function (e) {
|
||||||
if (!this.styleAdded) {
|
if (!this.styleAdded) {
|
||||||
addStyle(`
|
Utils.addStyle(`
|
||||||
.wh-link-collection-cont a{
|
.wh-link-collection-cont a{
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
border: solid 1px #b3b3b3;
|
border: solid 1px #b3b3b3;
|
||||||
@ -964,11 +962,7 @@ color:black;
|
|||||||
clickFunc: async function () {
|
clickFunc: async function () {
|
||||||
Log.info('测试开始');
|
Log.info('测试开始');
|
||||||
|
|
||||||
// sessionStorage.removeItem('sidebarData2687093')
|
Utils.getSidebarData().then(data => Log.info(data))
|
||||||
// Log.info(await Utils.getSidebarData())
|
|
||||||
// Log.info(await Utils.getUserState())
|
|
||||||
|
|
||||||
new Alert('123', { sysNotify: true });
|
|
||||||
|
|
||||||
Log.info('测试结束');
|
Log.info('测试结束');
|
||||||
},
|
},
|
||||||
@ -1391,6 +1385,7 @@ color:black;
|
|||||||
// 默认设置
|
// 默认设置
|
||||||
static setDefaultSettings(): void {
|
static setDefaultSettings(): void {
|
||||||
Log.info('Wuhu设置默认值');
|
Log.info('Wuhu设置默认值');
|
||||||
|
let count = 0;
|
||||||
[
|
[
|
||||||
// 开启翻译
|
// 开启翻译
|
||||||
{ key: 'transEnable', val: false },
|
{ key: 'transEnable', val: false },
|
||||||
@ -1450,9 +1445,12 @@ color:black;
|
|||||||
// 危险行为⚠️
|
// 危险行为⚠️
|
||||||
{ key: 'dangerZone', val: false },
|
{ key: 'dangerZone', val: false },
|
||||||
].forEach(df => {
|
].forEach(df => {
|
||||||
if (typeof WuhuConfig.get(df.key) !== typeof df.val) WuhuConfig.set(df.key, df.val);
|
if (typeof WuhuConfig.get(df.key) !== typeof df.val) {
|
||||||
|
WuhuConfig.set(df.key, df.val);
|
||||||
|
count++;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
Log.info('Wuhu设置默认值结束');
|
Log.info('Wuhu设置默认值结束,设置新值:' + count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,23 +1,19 @@
|
|||||||
import Utils from "./Utils";
|
|
||||||
import addStyle from "../../func/utils/addStyle";
|
|
||||||
import Log from "../Log";
|
import Log from "../Log";
|
||||||
import IWHNotify from "../../interface/IWHNotify";
|
import IWHNotify from "../../interface/IWHNotify";
|
||||||
import NotificationUtils from "./NotificationUtils";
|
import NotificationUtils from "./NotificationUtils";
|
||||||
|
import WuhuBase from "../WuhuBase";
|
||||||
|
|
||||||
export default class Alert extends Utils {
|
export default class Alert extends WuhuBase {
|
||||||
static container: HTMLElement = null;
|
private static container: HTMLElement = null;
|
||||||
|
|
||||||
notify: MyHTMLElement = null;
|
private notify: MyHTMLElement = null;
|
||||||
intervalID = -1;
|
private intervalID = -1;
|
||||||
|
private readonly callback: Function;
|
||||||
|
|
||||||
constructor(msg: string, options: IWHNotify = {}) {
|
constructor(msg: string, options: IWHNotify = {}) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
let {
|
let { timeout, callback, sysNotify, } = options;
|
||||||
timeout = 3,
|
|
||||||
callback = () => null,
|
|
||||||
sysNotify = false,
|
|
||||||
} = options;
|
|
||||||
|
|
||||||
// 后台窗口、iframe内判断
|
// 后台窗口、iframe内判断
|
||||||
if (!Alert.glob.isWindowActive.get() || (self !== top)) return null;
|
if (!Alert.glob.isWindowActive.get() || (self !== top)) return null;
|
||||||
@ -25,15 +21,16 @@ export default class Alert extends Utils {
|
|||||||
// 通知的容器
|
// 通知的容器
|
||||||
if (Alert.container === null) Alert.initContainer();
|
if (Alert.container === null) Alert.initContainer();
|
||||||
|
|
||||||
this.callback = callback;
|
this.callback = callback || (() => null);
|
||||||
Alert.create(this, msg, timeout);
|
Alert.create(this, msg, timeout || 3);
|
||||||
Log.info('创建新通知:', this);
|
Log.info('创建新通知:', this);
|
||||||
if (sysNotify) NotificationUtils.push(msg, options);
|
if (sysNotify) NotificationUtils.push(msg, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
static create(that: Alert, msg, timeout): void {
|
private static create(that: Alert, msg, timeout): void {
|
||||||
// 通知的唯一id
|
// 通知的唯一id
|
||||||
const uid = '' + Utils.getRandomInt(1000, 9999);
|
// const uid = '' + Alert.getRandomInt(1000, 9999);
|
||||||
|
const uid = '' + performance.now();
|
||||||
// 每条通知
|
// 每条通知
|
||||||
const element: MyHTMLElement = document.createElement('div');
|
const element: MyHTMLElement = document.createElement('div');
|
||||||
element.id = `wh-notify-${ uid }`;
|
element.id = `wh-notify-${ uid }`;
|
||||||
@ -70,61 +67,17 @@ export default class Alert extends Utils {
|
|||||||
Log.info(that.notify)
|
Log.info(that.notify)
|
||||||
}
|
}
|
||||||
|
|
||||||
static initContainer() {
|
private static initContainer() {
|
||||||
this.container = document.createElement('div');
|
this.container = document.createElement('div');
|
||||||
this.container.id = 'wh-notify';
|
this.container.id = 'wh-notify';
|
||||||
addStyle(`
|
|
||||||
#wh-notify {
|
|
||||||
display: inline-block;
|
|
||||||
position: fixed;
|
|
||||||
top: 0;
|
|
||||||
left: calc(50% - 180px);
|
|
||||||
width: 360px;
|
|
||||||
z-index: 9999990;
|
|
||||||
color:#333;
|
|
||||||
}
|
|
||||||
#wh-notify a{
|
|
||||||
color:red;
|
|
||||||
text-decoration:none;
|
|
||||||
}
|
|
||||||
#wh-notify .wh-notify-item {
|
|
||||||
/*height: 50px;*/
|
|
||||||
background: rgb(239 249 255 / 90%);
|
|
||||||
border-radius: 2px;
|
|
||||||
margin: 0.5em 0 0 0;
|
|
||||||
box-shadow: 0 0 5px 0px #959595;
|
|
||||||
}
|
|
||||||
#wh-notify .wh-notify-item:hover {
|
|
||||||
background: rgb(239 249 255 / 98%);
|
|
||||||
}
|
|
||||||
#wh-notify .wh-notify-item .wh-notify-bar {
|
|
||||||
height:2px;
|
|
||||||
background:#2196f3;
|
|
||||||
}
|
|
||||||
#wh-notify .wh-notify-item .wh-notify-close {
|
|
||||||
float:right;
|
|
||||||
padding:0;
|
|
||||||
width:16px;height:16px;
|
|
||||||
background:url('data:image/svg+xml,%3Csvg%20viewBox%3D%220%200%201024%201024%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20d%3D%22M923%20571H130.7c-27.6%200-50-22.4-50-50s22.4-50%2050-50H923c27.6%200%2050%2022.4%2050%2050s-22.4%2050-50%2050z%22%20fill%3D%22%232196f3%22%3E%3C%2Fpath%3E%3C%2Fsvg%3E') no-repeat center;
|
|
||||||
background-size:100%;
|
|
||||||
margin: 6px 6px 0 0;
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
#wh-notify .wh-notify-item .wh-notify-msg {
|
|
||||||
padding:12px;
|
|
||||||
}
|
|
||||||
`);
|
|
||||||
document.body.append(this.container);
|
document.body.append(this.container);
|
||||||
}
|
}
|
||||||
|
|
||||||
close() {
|
public close() {
|
||||||
this.notify.remove();
|
this.notify.remove();
|
||||||
// Log.info('父元素:', this.notify.parentElement);
|
|
||||||
this.notify = null;
|
this.notify = null;
|
||||||
this.callback();
|
this.callback();
|
||||||
let id = this.intervalID;
|
let id = this.intervalID;
|
||||||
window.clearInterval(id);
|
window.clearInterval(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
callback: Function = () => null;
|
|
||||||
}
|
}
|
||||||
@ -1,8 +1,8 @@
|
|||||||
import Utils from "./Utils";
|
|
||||||
import IWHNotify from "../../interface/IWHNotify";
|
import IWHNotify from "../../interface/IWHNotify";
|
||||||
import Log from "../Log";
|
import Log from "../Log";
|
||||||
|
import WuhuBase from "../WuhuBase";
|
||||||
|
|
||||||
export default class NotificationUtils extends Utils {
|
export default class NotificationUtils extends WuhuBase {
|
||||||
static permission: boolean = window.Notification && window.Notification.permission === 'granted';
|
static permission: boolean = window.Notification && window.Notification.permission === 'granted';
|
||||||
|
|
||||||
static push(msg: string, options: IWHNotify = {}) {
|
static push(msg: string, options: IWHNotify = {}) {
|
||||||
|
|||||||
@ -4,10 +4,11 @@ import Log from "../Log";
|
|||||||
import Device from "../../enum/Device";
|
import Device from "../../enum/Device";
|
||||||
import ISidebarData from "../../interface/ISidebarData";
|
import ISidebarData from "../../interface/ISidebarData";
|
||||||
import AjaxFetchOption from "../../interface/AjaxFetchOption";
|
import AjaxFetchOption from "../../interface/AjaxFetchOption";
|
||||||
|
import Alert from "./Alert";
|
||||||
|
|
||||||
export default class Utils extends WuhuBase {
|
export default class Utils extends WuhuBase {
|
||||||
static getScriptEngine() {
|
static getScriptEngine() {
|
||||||
let glob = WuhuBase.glob;
|
let glob = Utils.glob;
|
||||||
return glob.unsafeWindow ? UserScriptEngine.GM : glob.isPDA
|
return glob.unsafeWindow ? UserScriptEngine.GM : glob.isPDA
|
||||||
? UserScriptEngine.PDA : UserScriptEngine.RAW;
|
? UserScriptEngine.PDA : UserScriptEngine.RAW;
|
||||||
}
|
}
|
||||||
@ -57,7 +58,7 @@ export default class Utils extends WuhuBase {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case UserScriptEngine.GM: {
|
case UserScriptEngine.GM: {
|
||||||
let { GM_xmlhttpRequest } = WuhuBase.glob;
|
let { GM_xmlhttpRequest } = Utils.glob;
|
||||||
if (typeof GM_xmlhttpRequest !== 'function') {
|
if (typeof GM_xmlhttpRequest !== 'function') {
|
||||||
Log.error('COFetch网络错误:用户脚本扩展API错误');
|
Log.error('COFetch网络错误:用户脚本扩展API错误');
|
||||||
reject('错误:用户脚本扩展API错误');
|
reject('错误:用户脚本扩展API错误');
|
||||||
@ -85,10 +86,15 @@ export default class Utils extends WuhuBase {
|
|||||||
*/
|
*/
|
||||||
static getPlayerInfo(): PlayerInfo {
|
static 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,
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
new Alert('严重错误:芜湖助手无法获取用户数据,已退出');
|
||||||
|
throw '芜湖助手无法获取用户数据';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 用户设备类型 对应PC MOBILE TABLET
|
// 用户设备类型 对应PC MOBILE TABLET
|
||||||
@ -115,8 +121,8 @@ export default class Utils extends WuhuBase {
|
|||||||
return new Promise(resolve => setTimeout(() => resolve(null), time));
|
return new Promise(resolve => setTimeout(() => resolve(null), time));
|
||||||
}
|
}
|
||||||
|
|
||||||
static getSessionData(): Promise<ISidebarData> {
|
static async getSessionData(): Promise<ISidebarData> {
|
||||||
let field: string = 'sidebarData' + this.getPlayerInfo().userID;
|
let field: string = 'sidebarData' + (await this.getPlayerInfo()).userID;
|
||||||
let ret: ISidebarData = {};
|
let ret: ISidebarData = {};
|
||||||
return new Promise(async resolve => {
|
return new Promise(async resolve => {
|
||||||
let c = 0;
|
let c = 0;
|
||||||
@ -205,7 +211,16 @@ export default class Utils extends WuhuBase {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
static createSystemNotify(): Notification {
|
static addStyle(rules: string): void {
|
||||||
return null;
|
let element = document.querySelector('style#wh-trans-gStyle');
|
||||||
|
if (element) {
|
||||||
|
element.innerHTML += rules;
|
||||||
|
} else {
|
||||||
|
element = document.createElement("style");
|
||||||
|
element.id = 'wh-trans-gStyle';
|
||||||
|
element.innerHTML = rules;
|
||||||
|
document.head.appendChild(element);
|
||||||
|
}
|
||||||
|
Log.info('CSS规则已添加', element);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,14 +1,11 @@
|
|||||||
import Device from "../../enum/Device";
|
import Device from "../../enum/Device";
|
||||||
import elementReady from "../utils/elementReady";
|
|
||||||
import getWhSettingObj from "../utils/getWhSettingObj";
|
|
||||||
import addActionBtn from "../utils/addActionBtn";
|
import addActionBtn from "../utils/addActionBtn";
|
||||||
import addStyle from "../utils/addStyle";
|
|
||||||
import log from "../utils/@deprecated/log";
|
|
||||||
import ZhongIcon from "../../class/ZhongIcon";
|
import ZhongIcon from "../../class/ZhongIcon";
|
||||||
import WuhuBase from "../../class/WuhuBase";
|
import WuhuBase from "../../class/WuhuBase";
|
||||||
import WuhuConfig from "../../class/WuhuConfig";
|
import WuhuConfig from "../../class/WuhuConfig";
|
||||||
import Utils from "../../class/utils/Utils";
|
import Utils from "../../class/utils/Utils";
|
||||||
import Log from "../../class/Log";
|
import Log from "../../class/Log";
|
||||||
|
import Alert from "../../class/utils/Alert";
|
||||||
|
|
||||||
export default async function attackHelper(): Promise<null> {
|
export default async function attackHelper(): Promise<null> {
|
||||||
let { href, device } = WuhuBase.glob;
|
let { href, device } = WuhuBase.glob;
|
||||||
@ -16,7 +13,9 @@ export default async function attackHelper(): Promise<null> {
|
|||||||
// 攻击页面
|
// 攻击页面
|
||||||
if (href.contains(/loader\.php\?sid=attack/)) {
|
if (href.contains(/loader\.php\?sid=attack/)) {
|
||||||
let stop_reload = false;
|
let stop_reload = false;
|
||||||
const { quickAttIndex, quickFinishAtt, attReload } = getWhSettingObj();
|
const quickAttIndex = WuhuConfig.get('quickAttIndex');
|
||||||
|
const quickFinishAtt = WuhuConfig.get('quickFinishAtt');
|
||||||
|
const attReload = WuhuConfig.get('attReload');
|
||||||
|
|
||||||
// 光速刷新按钮
|
// 光速刷新按钮
|
||||||
addActionBtn('光速刷新', doAttackReload, $zhongNode);
|
addActionBtn('光速刷新', doAttackReload, $zhongNode);
|
||||||
@ -31,10 +30,9 @@ export default async function attackHelper(): Promise<null> {
|
|||||||
'tablet': '',
|
'tablet': '',
|
||||||
};
|
};
|
||||||
const selector = selector_device_map[device];
|
const selector = selector_device_map[device];
|
||||||
elementReady(selector).then(elem => {
|
Utils.elementReady(selector).then(elem => {
|
||||||
if (!elem.querySelector('button')) {
|
if (!elem.querySelector('button')) {
|
||||||
if (getWhSettingObj().attReload === 0 && stop_reload !== true) {
|
if (WuhuConfig.get('attReload') === 0 && stop_reload !== true) {
|
||||||
// window.location.reload();
|
|
||||||
doAttackReload();
|
doAttackReload();
|
||||||
} else {
|
} else {
|
||||||
let reload_flag;
|
let reload_flag;
|
||||||
@ -65,23 +63,23 @@ export default async function attackHelper(): Promise<null> {
|
|||||||
|
|
||||||
// 光速拔刀
|
// 光速拔刀
|
||||||
if (quickAttIndex !== 6) {
|
if (quickAttIndex !== 6) {
|
||||||
const btn = await elementReady('div[class^="modal___"] button');
|
const btn = await Utils.elementReady('div[class^="modal___"] button');
|
||||||
log.info(btn);
|
Log.info(btn);
|
||||||
if (!btn.innerText.toLowerCase().includes('fight')) return;
|
if (!btn.innerText.toLowerCase().includes('fight')) return;
|
||||||
// 判断是否存在脚踢
|
// 判断是否存在脚踢
|
||||||
const hasKick = !!document.querySelector('#weapon_boots');
|
const hasKick = !!document.querySelector('#weapon_boots');
|
||||||
// modal层
|
// modal层
|
||||||
const modal: HTMLElement = document.querySelector('div[class^="modal___"]');
|
const modal: HTMLElement = document.querySelector('div[class^="modal___"]');
|
||||||
log.info(`当前设备类型是${ device }`);
|
Log.info(`当前设备类型是${ device }`);
|
||||||
// 区分设备
|
// 区分设备
|
||||||
switch (device) {
|
switch (device) {
|
||||||
case Device.PC: {
|
case Device.PC: {
|
||||||
log.info(`开始调整按钮位置`);
|
Log.info(`开始调整按钮位置`);
|
||||||
// 隐藏modal层
|
// 隐藏modal层
|
||||||
modal.style.display = 'none';
|
modal.style.display = 'none';
|
||||||
// 根据选择的武器调整css
|
// 根据选择的武器调整css
|
||||||
let css_top = '0';
|
let css_top = '0';
|
||||||
switch (getWhSettingObj()['quickAttIndex']) {
|
switch (WuhuConfig.get('quickAttIndex')) {
|
||||||
case 1: { // weapon_second
|
case 1: { // weapon_second
|
||||||
css_top = '97px';
|
css_top = '97px';
|
||||||
break;
|
break;
|
||||||
@ -107,7 +105,7 @@ export default async function attackHelper(): Promise<null> {
|
|||||||
.wh-move-btn #defender div[class^="title___"]{height:0;}
|
.wh-move-btn #defender div[class^="title___"]{height:0;}
|
||||||
.wh-move-btn #defender button{width: 100%;margin:17px 0;height: 60px;}
|
.wh-move-btn #defender button{width: 100%;margin:17px 0;height: 60px;}
|
||||||
`;
|
`;
|
||||||
addStyle(css_rule);
|
Utils.addStyle(css_rule);
|
||||||
document.body.classList.add('wh-move-btn');
|
document.body.classList.add('wh-move-btn');
|
||||||
// 绑定点击事件 联动【光速跑路】
|
// 绑定点击事件 联动【光速跑路】
|
||||||
btn.onclick = () => {
|
btn.onclick = () => {
|
||||||
@ -122,14 +120,14 @@ export default async function attackHelper(): Promise<null> {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Device.MOBILE: {
|
case Device.MOBILE: {
|
||||||
log.info(`开始调整按钮位置`);
|
Log.info(`开始调整按钮位置`);
|
||||||
// 加入css
|
// 加入css
|
||||||
let css_top = '0';
|
let css_top = '0';
|
||||||
let slot_height = '76px';
|
let slot_height = '76px';
|
||||||
// 判断有没有脚踢
|
// 判断有没有脚踢
|
||||||
if (hasKick) {
|
if (hasKick) {
|
||||||
// 根据选择的武器调整
|
// 根据选择的武器调整
|
||||||
switch (getWhSettingObj()['quickAttIndex']) {
|
switch (WuhuConfig.get('quickAttIndex')) {
|
||||||
case 1: { // weapon_second
|
case 1: { // weapon_second
|
||||||
css_top = '76px';
|
css_top = '76px';
|
||||||
break;
|
break;
|
||||||
@ -157,7 +155,7 @@ export default async function attackHelper(): Promise<null> {
|
|||||||
// TODO 待验证
|
// TODO 待验证
|
||||||
slot_height = height + 'px';
|
slot_height = height + 'px';
|
||||||
// 根据选择的武器调整
|
// 根据选择的武器调整
|
||||||
switch (getWhSettingObj().quickAttIndex) {
|
switch (WuhuConfig.get('quickAttIndex')) {
|
||||||
case 1: { // weapon_second
|
case 1: { // weapon_second
|
||||||
css_top = `${ height }px`;
|
css_top = `${ height }px`;
|
||||||
break;
|
break;
|
||||||
@ -187,10 +185,10 @@ export default async function attackHelper(): Promise<null> {
|
|||||||
.wh-move-btn #attacker div[class^="title___"]{height:0;}
|
.wh-move-btn #attacker div[class^="title___"]{height:0;}
|
||||||
.wh-move-btn #attacker button{width:100%;margin:0;height:63px;white-space:normal;}
|
.wh-move-btn #attacker button{width:100%;margin:0;height:63px;white-space:normal;}
|
||||||
`;
|
`;
|
||||||
addStyle(css_rule);
|
Utils.addStyle(css_rule);
|
||||||
document.body.classList.toggle('wh-move-btn');
|
document.body.classList.toggle('wh-move-btn');
|
||||||
btn.onclick = () => {
|
btn.onclick = () => {
|
||||||
if (getWhSettingObj().quickFinishAtt !== 3) {
|
if (WuhuConfig.get('quickFinishAtt') !== 3) {
|
||||||
btn.remove();
|
btn.remove();
|
||||||
// 停止自动刷新
|
// 停止自动刷新
|
||||||
stop_reload = true;
|
stop_reload = true;
|
||||||
@ -205,7 +203,7 @@ export default async function attackHelper(): Promise<null> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 自动开打
|
// 自动开打
|
||||||
if (getWhSettingObj()['autoStartFinish'] === true) {
|
if (WuhuConfig.get('autoStartFinish') === true) {
|
||||||
if (btn.innerText.includes('(')) {
|
if (btn.innerText.includes('(')) {
|
||||||
let interval_id = window.setInterval(() => {
|
let interval_id = window.setInterval(() => {
|
||||||
if (!btn) {
|
if (!btn) {
|
||||||
@ -225,18 +223,18 @@ export default async function attackHelper(): Promise<null> {
|
|||||||
|
|
||||||
// 光速跑路
|
// 光速跑路
|
||||||
if (quickFinishAtt !== 3) {
|
if (quickFinishAtt !== 3) {
|
||||||
const user_btn_select = ['leave', 'mug', 'hosp'][getWhSettingObj()['quickFinishAtt']];
|
const user_btn_select = ['leave', 'mug', 'hosp'][WuhuConfig.get('quickFinishAtt')];
|
||||||
const wrap = document.querySelector('#react-root');
|
const wrap = document.querySelector('#react-root');
|
||||||
log.info('光速跑路选项选中:', user_btn_select);
|
Log.info('光速跑路选项选中:', user_btn_select);
|
||||||
new MutationObserver(() => {
|
new MutationObserver(() => {
|
||||||
const btn_arr = document.querySelectorAll('div[class^="dialogButtons___"] button') as unknown as HTMLButtonElement[];
|
const btn_arr = document.querySelectorAll('div[class^="dialogButtons___"] button') as unknown as HTMLButtonElement[];
|
||||||
if (btn_arr.length > 1) btn_arr.forEach(btn => {
|
if (btn_arr.length > 1) btn_arr.forEach(btn => {
|
||||||
btn = btn as HTMLButtonElement;
|
btn = btn as HTMLButtonElement;
|
||||||
const flag = btn.innerText.toLowerCase().includes(user_btn_select);
|
const flag = btn.innerText.toLowerCase().includes(user_btn_select);
|
||||||
log.info('按钮内容:', btn.innerText, ',是否包含选中:', flag);
|
Log.info('按钮内容:', btn.innerText, ',是否包含选中:', flag);
|
||||||
if (!flag) btn.style.display = 'none';
|
if (!flag) btn.style.display = 'none';
|
||||||
// 自动结束
|
// 自动结束
|
||||||
else if (getWhSettingObj()['autoStartFinish'] === true) {
|
else if (WuhuConfig.get('autoStartFinish') === true) {
|
||||||
try {
|
try {
|
||||||
btn.click();
|
btn.click();
|
||||||
} catch {
|
} catch {
|
||||||
@ -249,7 +247,7 @@ export default async function attackHelper(): Promise<null> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 错误的攻击页面
|
// 错误的攻击页面
|
||||||
if (getWhSettingObj()['attRelocate'] && href.includes('loader2.php')) {
|
if (WuhuConfig.get('attRelocate') && href.includes('loader2.php')) {
|
||||||
const spl = window.location.href.trim().split('=');
|
const spl = window.location.href.trim().split('=');
|
||||||
const uid = spl[spl.length - 1];
|
const uid = spl[spl.length - 1];
|
||||||
if (!/^\d+$/.test(uid)) return;
|
if (!/^\d+$/.test(uid)) return;
|
||||||
@ -260,7 +258,10 @@ export default async function attackHelper(): Promise<null> {
|
|||||||
|
|
||||||
// 战斗页面快速刷新
|
// 战斗页面快速刷新
|
||||||
function doAttackReload() {
|
function doAttackReload() {
|
||||||
if (!window.ReactDOM) return;
|
if (!window.ReactDOM) {
|
||||||
|
new Alert('光速刷新失败:未找到React对象');
|
||||||
|
return;
|
||||||
|
}
|
||||||
let react_root = document.querySelector('#react-root');
|
let react_root = document.querySelector('#react-root');
|
||||||
if (!react_root.querySelector('#attacker')) return;
|
if (!react_root.querySelector('#attacker')) return;
|
||||||
let script = document.querySelector('script[src*="/builds/attack/"]');
|
let script = document.querySelector('script[src*="/builds/attack/"]');
|
||||||
|
|||||||
@ -1,11 +1,10 @@
|
|||||||
import elementReady from "../utils/elementReady";
|
import elementReady from "../utils/elementReady";
|
||||||
import addStyle from "../utils/addStyle";
|
|
||||||
import toThousands from "../utils/toThousands";
|
import toThousands from "../utils/toThousands";
|
||||||
import log from "../utils/@deprecated/log";
|
import log from "../utils/@deprecated/log";
|
||||||
import Utils from "../../class/utils/Utils";
|
import Utils from "../../class/utils/Utils";
|
||||||
|
|
||||||
export default function cityFinder(): void {
|
export default function cityFinder(): void {
|
||||||
addStyle(`
|
Utils.addStyle(`
|
||||||
.wh-city-finds .leaflet-marker-pane img[src*="torn.com/images/items/"]{
|
.wh-city-finds .leaflet-marker-pane img[src*="torn.com/images/items/"]{
|
||||||
display: block !important;
|
display: block !important;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import elementReady from "../utils/elementReady";
|
import elementReady from "../utils/elementReady";
|
||||||
import getWhSettingObj from "../utils/getWhSettingObj";
|
import getWhSettingObj from "../utils/getWhSettingObj";
|
||||||
import addStyle from "../utils/addStyle";
|
import addStyle from "../utils/@deprecated/addStyle";
|
||||||
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";
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import UserScriptEngine from "../../enum/UserScriptEngine";
|
import UserScriptEngine from "../../enum/UserScriptEngine";
|
||||||
import WHNotify from "../utils/WHNotify";
|
import WHNotify from "../utils/WHNotify";
|
||||||
import addStyle from "../utils/addStyle";
|
import addStyle from "../utils/@deprecated/addStyle";
|
||||||
import log from "../utils/@deprecated/log";
|
import log from "../utils/@deprecated/log";
|
||||||
import Utils from "../../class/utils/Utils";
|
import Utils from "../../class/utils/Utils";
|
||||||
|
|
||||||
|
|||||||
@ -2,6 +2,7 @@ import getWhSettingObj from "../utils/getWhSettingObj";
|
|||||||
import log from "../utils/@deprecated/log";
|
import log from "../utils/@deprecated/log";
|
||||||
import toThousands from "../utils/toThousands";
|
import toThousands from "../utils/toThousands";
|
||||||
import WHNotify from "../utils/WHNotify";
|
import WHNotify from "../utils/WHNotify";
|
||||||
|
import Log from "../../class/Log";
|
||||||
|
|
||||||
// 价格监视handle
|
// 价格监视handle
|
||||||
export default function priceWatcherHandle(isPDA: boolean, PDA_APIKey: string) {
|
export default function priceWatcherHandle(isPDA: boolean, PDA_APIKey: string) {
|
||||||
@ -10,7 +11,7 @@ export default function priceWatcherHandle(isPDA: boolean, PDA_APIKey: string) {
|
|||||||
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.error('价格监视失败,无apikey')
|
Log.error('价格监视失败,无apikey')
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (price_conf['pt'] !== -1) priceWatcherPt(apikey, price_conf['pt'], priceTemp).then();
|
if (price_conf['pt'] !== -1) priceWatcherPt(apikey, price_conf['pt'], priceTemp).then();
|
||||||
@ -46,7 +47,7 @@ async function priceWatcherPt(apikey, lower_price, priceWatcher) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// 查询出错了
|
// 查询出错了
|
||||||
log.error('pt查询出错了')
|
Log.error('pt查询出错了')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import Device from "../../enum/Device";
|
|||||||
import WHNotify from "../utils/WHNotify";
|
import WHNotify from "../utils/WHNotify";
|
||||||
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/@deprecated/addStyle";
|
||||||
import log from "../utils/@deprecated/log";
|
import log from "../utils/@deprecated/log";
|
||||||
import doQuickFly from "./doQuickFly";
|
import doQuickFly from "./doQuickFly";
|
||||||
import ZhongIcon from "../../class/ZhongIcon";
|
import ZhongIcon from "../../class/ZhongIcon";
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import UserScriptEngine from "../../enum/UserScriptEngine";
|
import UserScriptEngine from "../../../enum/UserScriptEngine";
|
||||||
import getScriptEngine from "./getScriptEngine";
|
import getScriptEngine from "../getScriptEngine";
|
||||||
import log from "./@deprecated/log";
|
import Log from "../../../class/Log";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated
|
* @deprecated
|
||||||
@ -19,26 +19,26 @@ export default function COFetch(url: URL | string, method: 'get' | 'post' = 'get
|
|||||||
// get
|
// get
|
||||||
if (method === 'get') {
|
if (method === 'get') {
|
||||||
if (typeof PDA_httpGet !== 'function') {
|
if (typeof PDA_httpGet !== 'function') {
|
||||||
log.error('COFetch网络错误:PDA版本不支持');
|
Log.error('COFetch网络错误:PDA版本不支持');
|
||||||
reject('COFetch网络错误:PDA版本不支持');
|
reject('COFetch网络错误:PDA版本不支持');
|
||||||
}
|
}
|
||||||
PDA_httpGet(url)
|
PDA_httpGet(url)
|
||||||
.then(res => resolve(res.responseText))
|
.then(res => resolve(res.responseText))
|
||||||
.catch(e => {
|
.catch(e => {
|
||||||
log.error('COFetch网络错误', e);
|
Log.error('COFetch网络错误', e);
|
||||||
reject(`COFetch网络错误 ${ e }`);
|
reject(`COFetch网络错误 ${ e }`);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
// post
|
// post
|
||||||
else {
|
else {
|
||||||
if (typeof PDA_httpPost !== 'function') {
|
if (typeof PDA_httpPost !== 'function') {
|
||||||
log.error('COFetch网络错误:PDA版本不支持');
|
Log.error('COFetch网络错误:PDA版本不支持');
|
||||||
reject('COFetch网络错误:PDA版本不支持');
|
reject('COFetch网络错误:PDA版本不支持');
|
||||||
}
|
}
|
||||||
PDA_httpPost(url, { 'content-type': 'application/json' }, body)
|
PDA_httpPost(url, { 'content-type': 'application/json' }, body)
|
||||||
.then(res => resolve(res.responseText))
|
.then(res => resolve(res.responseText))
|
||||||
.catch(e => {
|
.catch(e => {
|
||||||
log.error('COFetch网络错误', e);
|
Log.error('COFetch网络错误', e);
|
||||||
reject(`COFetch网络错误 ${ e }`);
|
reject(`COFetch网络错误 ${ e }`);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -47,7 +47,7 @@ export default function COFetch(url: URL | string, method: 'get' | 'post' = 'get
|
|||||||
case UserScriptEngine.GM: {
|
case UserScriptEngine.GM: {
|
||||||
let { GM_xmlhttpRequest } = window;
|
let { GM_xmlhttpRequest } = window;
|
||||||
if (typeof GM_xmlhttpRequest !== 'function') {
|
if (typeof GM_xmlhttpRequest !== 'function') {
|
||||||
log.error('COFetch网络错误:用户脚本扩展API错误');
|
Log.error('COFetch网络错误:用户脚本扩展API错误');
|
||||||
reject('错误:用户脚本扩展API错误');
|
reject('错误:用户脚本扩展API错误');
|
||||||
}
|
}
|
||||||
GM_xmlhttpRequest({
|
GM_xmlhttpRequest({
|
||||||
@ -1,8 +1,7 @@
|
|||||||
import log from "./@deprecated/log";
|
import log from "./log";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加全局style
|
* @deprecated
|
||||||
* @param {string} css CSS规则
|
|
||||||
*/
|
*/
|
||||||
export default function addStyle(css: string) {
|
export default function addStyle(css: string) {
|
||||||
let wh_gStyle = document.querySelector('style#wh-trans-gStyle');
|
let wh_gStyle = document.querySelector('style#wh-trans-gStyle');
|
||||||
@ -1,10 +1,8 @@
|
|||||||
import elementReady from "./elementReady";
|
import elementReady from "../elementReady";
|
||||||
import log from "./@deprecated/log";
|
import log from "./log";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 边栏信息
|
|
||||||
* @deprecated
|
* @deprecated
|
||||||
* @returns {unknown}
|
|
||||||
*/
|
*/
|
||||||
export default async function getSidebarData() {
|
export default async function getSidebarData() {
|
||||||
let ret = {};
|
let ret = {};
|
||||||
@ -1,4 +1,4 @@
|
|||||||
import addStyle from "./addStyle";
|
import addStyle from "./@deprecated/addStyle";
|
||||||
import WuhuBase from "../../class/WuhuBase";
|
import WuhuBase from "../../class/WuhuBase";
|
||||||
import Utils from "../../class/utils/Utils";
|
import Utils from "../../class/utils/Utils";
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import log from "./@deprecated/log";
|
import Log from "../../class/Log";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 播放音频
|
* 播放音频
|
||||||
@ -9,7 +9,7 @@ export default function audioPlay(url: string = 'https://www.torn.com/js/chat/so
|
|||||||
const audio = new Audio(url);
|
const audio = new Audio(url);
|
||||||
audio.addEventListener("canplaythrough", () => {
|
audio.addEventListener("canplaythrough", () => {
|
||||||
audio.play()
|
audio.play()
|
||||||
.catch(err => log.error(err))
|
.catch(err => Log.error(err))
|
||||||
.then();
|
.then();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -2,14 +2,13 @@ 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";
|
||||||
import elementReady from "./func/utils/elementReady";
|
import elementReady from "./func/utils/elementReady";
|
||||||
import setWhSetting from "./func/utils/setWhSetting";
|
|
||||||
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 Device from "./enum/Device";
|
||||||
import addStyle from "./func/utils/addStyle";
|
|
||||||
import WuhuBase from "./class/WuhuBase";
|
import WuhuBase from "./class/WuhuBase";
|
||||||
import Utils from "./class/utils/Utils";
|
import Utils from "./class/utils/Utils";
|
||||||
import Log from "./class/Log";
|
import Log from "./class/Log";
|
||||||
|
import WuhuConfig from "./class/WuhuConfig";
|
||||||
|
|
||||||
export default class UrlPattern extends WuhuBase {
|
export default class UrlPattern extends WuhuBase {
|
||||||
constructor() {
|
constructor() {
|
||||||
@ -17,14 +16,14 @@ export default class UrlPattern extends WuhuBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static resolve() {
|
static resolve() {
|
||||||
let { href, beer } = WuhuBase.glob;
|
let { href, beer } = UrlPattern.glob;
|
||||||
// 捡垃圾助手
|
// 捡垃圾助手
|
||||||
if (href.includes('city.php') && getWhSettingObj()['cityFinder']) {
|
if (href.includes('city.php') && getWhSettingObj()['cityFinder']) {
|
||||||
cityFinder();
|
cityFinder();
|
||||||
}
|
}
|
||||||
|
|
||||||
// pt一键购买
|
// pt一键购买
|
||||||
if (getWhSettingObj()['ptQuickBuy'] && href.includes('pmarket.php')) {
|
if (WuhuConfig.get('ptQuickBuy') && href.includes('pmarket.php')) {
|
||||||
WHNotify('一键购买已开启');
|
WHNotify('一键购买已开启');
|
||||||
// ns脚本
|
// ns脚本
|
||||||
const rmv_cfm = (e) => {
|
const rmv_cfm = (e) => {
|
||||||
@ -58,9 +57,9 @@ export default class UrlPattern extends WuhuBase {
|
|||||||
switch_node.querySelector('input').onchange = e => {
|
switch_node.querySelector('input').onchange = e => {
|
||||||
let target = e.target as HTMLInputElement;
|
let target = e.target as HTMLInputElement;
|
||||||
cont.classList.toggle('wh-display-none');
|
cont.classList.toggle('wh-display-none');
|
||||||
setWhSetting('SEProtect', target.checked);
|
WuhuConfig.set('SEProtect', target.checked, null, true);
|
||||||
};
|
};
|
||||||
elementReady('#gymroot').then(node => {
|
Utils.elementReady('#gymroot').then(node => {
|
||||||
cont = node;
|
cont = node;
|
||||||
if (getWhSettingObj()['SEProtect']) node.classList.add('wh-display-none');
|
if (getWhSettingObj()['SEProtect']) node.classList.add('wh-display-none');
|
||||||
node.before(switch_node);
|
node.before(switch_node);
|
||||||
@ -894,7 +893,7 @@ margin: 0 0 3px;
|
|||||||
};
|
};
|
||||||
const rw_raider = async function () {
|
const rw_raider = async function () {
|
||||||
if (href.includes('#rader')) {
|
if (href.includes('#rader')) {
|
||||||
addStyle('div.content-title,div.info-msg-cont{display:none;}');
|
Utils.addStyle('div.content-title,div.info-msg-cont{display:none;}');
|
||||||
const wh_node = document.createElement('div');
|
const wh_node = document.createElement('div');
|
||||||
wh_node.id = 'wh-rd-cont';
|
wh_node.id = 'wh-rd-cont';
|
||||||
wh_node.innerHTML = `<div class="m-top10">
|
wh_node.innerHTML = `<div class="m-top10">
|
||||||
@ -926,8 +925,9 @@ margin: 0 0 3px;
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 特定代码块
|
// 特定代码块
|
||||||
if (Utils.getPlayerInfo()['userID'] === 2687093 && Utils.getDeviceType() === Device.PC) {
|
if (Utils.getPlayerInfo().userID === 2687093 && Utils.getDeviceType() === Device.PC) {
|
||||||
Utils.getSidebarData().then(() => {
|
Utils.getSidebarData().then(data => {
|
||||||
|
Log.info({ 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);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user