更新
This commit is contained in:
parent
efcd95586d
commit
6f6712ee1b
5
build.js
5
build.js
@ -1,3 +1,8 @@
|
|||||||
|
/**
|
||||||
|
* 此脚本用于加入userscript meta,
|
||||||
|
* 并生成日期时间与版本号
|
||||||
|
*/
|
||||||
|
|
||||||
let fs = require('fs');
|
let fs = require('fs');
|
||||||
|
|
||||||
let date = new Date();
|
let date = new Date();
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "wuhu-torn-helper",
|
"name": "wuhu-torn-helper",
|
||||||
"version": "0.5.6",
|
"version": "0.5.7",
|
||||||
"description": "芜湖助手",
|
"description": "芜湖助手",
|
||||||
"dependencies": {},
|
"dependencies": {},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@ -8,9 +8,7 @@ import translateMain from "../func/translate/translateMain";
|
|||||||
|
|
||||||
export default class Application {
|
export default class Application {
|
||||||
|
|
||||||
private readonly common = Common.getInstance();
|
public main() {
|
||||||
|
|
||||||
main() {
|
|
||||||
let started = performance.now();
|
let started = performance.now();
|
||||||
|
|
||||||
WuhuBase.PDAExecute();
|
WuhuBase.PDAExecute();
|
||||||
@ -21,8 +19,7 @@ export default class Application {
|
|||||||
let glob = WuhuBase.glob;
|
let glob = WuhuBase.glob;
|
||||||
ZhongIcon.getInstance().initialize();
|
ZhongIcon.getInstance().initialize();
|
||||||
|
|
||||||
// Common.resolve();
|
Common.getInstance().resolve();
|
||||||
this.common.resolve();
|
|
||||||
|
|
||||||
UrlPattern.resolve();
|
UrlPattern.resolve();
|
||||||
|
|
||||||
|
|||||||
@ -63,7 +63,7 @@ export class Common extends WuhuBase {
|
|||||||
* 清除多余的脚本
|
* 清除多余的脚本
|
||||||
* TODO 无效、弃用
|
* TODO 无效、弃用
|
||||||
*/
|
*/
|
||||||
if (WuhuConfig.get('removeScripts')) {
|
if (WuhuConfig.get('removeScripts') && false) {
|
||||||
document.querySelectorAll('script[src*="google"]').forEach(item => item.remove());
|
document.querySelectorAll('script[src*="google"]').forEach(item => item.remove());
|
||||||
document.querySelectorAll('#gtm_tag').forEach(item => item.remove());
|
document.querySelectorAll('#gtm_tag').forEach(item => item.remove());
|
||||||
document.querySelectorAll('script[src*="chat/gonline"]').forEach(item => item.remove());
|
document.querySelectorAll('script[src*="chat/gonline"]').forEach(item => item.remove());
|
||||||
|
|||||||
@ -16,7 +16,7 @@ export default class Global extends WuhuBase implements IGlobal {
|
|||||||
// 留存的通知
|
// 留存的通知
|
||||||
notifies: NotifyWrapper = null;
|
notifies: NotifyWrapper = null;
|
||||||
// 海外库存
|
// 海外库存
|
||||||
fStock: { get: () => Promise<any> } = null;
|
fStock = null;
|
||||||
// 玩家名和数字id
|
// 玩家名和数字id
|
||||||
player_info = null;
|
player_info = null;
|
||||||
// 设备类型
|
// 设备类型
|
||||||
|
|||||||
@ -55,7 +55,7 @@ export default class Log {
|
|||||||
private static saveLogs(...o) {
|
private static saveLogs(...o) {
|
||||||
o.forEach(item => {
|
o.forEach(item => {
|
||||||
if (typeof item === 'string') this.logs += item;
|
if (typeof item === 'string') this.logs += item;
|
||||||
else {
|
else if (item) {
|
||||||
let json = '{}';
|
let json = '{}';
|
||||||
try {
|
try {
|
||||||
json = JSON.stringify(item);
|
json = JSON.stringify(item);
|
||||||
|
|||||||
@ -14,6 +14,7 @@ import QUICK_CRIMES_HTML from "../static/html/quick_crimes.html";
|
|||||||
import RW_RIDER_HTML from "../static/html/rw_rider.html";
|
import RW_RIDER_HTML from "../static/html/rw_rider.html";
|
||||||
import christmasTownHelper from "../func/module/christmasTownHelper";
|
import christmasTownHelper from "../func/module/christmasTownHelper";
|
||||||
import LotteryHelper from "./action/LotteryHelper";
|
import LotteryHelper from "./action/LotteryHelper";
|
||||||
|
import TornStyleBlock from "./utils/TornStyleBlock";
|
||||||
|
|
||||||
export default class UrlPattern extends WuhuBase {
|
export default class UrlPattern extends WuhuBase {
|
||||||
static resolve() {
|
static resolve() {
|
||||||
@ -51,47 +52,49 @@ export default class UrlPattern extends WuhuBase {
|
|||||||
|
|
||||||
// 叠e助手
|
// 叠e助手
|
||||||
if (href.includes('gym.php')) {
|
if (href.includes('gym.php')) {
|
||||||
let cont = null;
|
let block = new TornStyleBlock('叠E保护').insert2Dom();
|
||||||
const switch_node = document.createElement('div');
|
block.setContent(`<label class="non-selection"><input class="" type="checkbox" ${ WuhuConfig.get('SEProtect') ? 'checked' : '' }/> 启用</label>`);
|
||||||
switch_node.innerHTML = `<label><input type="checkbox" ${ WuhuConfig.get('SEProtect') ? 'checked' : '' }/> 叠E保护</label>`;
|
// 绑定点击事件
|
||||||
switch_node.id = 'wh-gym-info-cont';
|
block.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');
|
document.body.classList.toggle('wh-gym-stack');
|
||||||
WuhuConfig.set('SEProtect', target.checked, true);
|
WuhuConfig.set('SEProtect', target.checked, true);
|
||||||
};
|
};
|
||||||
CommonUtils.elementReady('#gymroot').then(node => {
|
if (WuhuConfig.get('SEProtect')) document.body.classList.add('wh-gym-stack');
|
||||||
cont = node;
|
|
||||||
if (WuhuConfig.get('SEProtect')) node.classList.add('wh-display-none');
|
|
||||||
node.before(switch_node);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 啤酒店
|
// 啤酒店
|
||||||
if (href.includes('shops.php?step=bitsnbobs')) {
|
if (href.includes('shops.php?step=bitsnbobs')) {
|
||||||
|
let block = new TornStyleBlock('啤酒助手').insert2Dom();
|
||||||
|
block.setContent(ADD_BEER_HEAD_HTML);
|
||||||
|
const msg_node = block.querySelector('#wh-msg');
|
||||||
// 加入啤酒
|
// 加入啤酒
|
||||||
CommonUtils.elementReady('ul.items-list').then(node => {
|
// CommonUtils.elementReady('ul.items-list').then(node => {
|
||||||
const add_btn_node = document.createElement('div');
|
block.querySelector('button').addEventListener('click', e => {
|
||||||
add_btn_node.id = 'wh-gym-info-cont';
|
let node = document.querySelector('ul.items-list');
|
||||||
add_btn_node.innerHTML = ADD_BEER_HEAD_HTML;
|
if (!node) {
|
||||||
add_btn_node.querySelector('button').addEventListener('click', e => {
|
msg_node.innerHTML = '❌ 商品未加载完';
|
||||||
const msg_node = add_btn_node.querySelector('#wh-msg');
|
Log.error('商品未加载完');
|
||||||
if (node.querySelector('span[id="180-name"]')) {
|
return;
|
||||||
msg_node.innerHTML = '❌ 页面已经有啤酒了';
|
}
|
||||||
return;
|
if (node.querySelector('span[id="180-name"]')) {
|
||||||
}
|
msg_node.innerHTML = '❌ 页面已经有啤酒了';
|
||||||
const clear_node = node.querySelector('li.clear');
|
Log.warn('商店页面已有啤酒');
|
||||||
const beer = document.createElement('li');
|
return;
|
||||||
beer.classList.add('torn-divider', 'divider-vertical');
|
}
|
||||||
beer.style.backgroundColor = '#c8c8c8';
|
const clear_node = node.querySelector('li.clear');
|
||||||
beer.innerHTML = SHOP_BEER_STATIC_ITEM_HTML;
|
const beer = document.createElement('li');
|
||||||
if (clear_node) clear_node.before(beer);
|
beer.classList.add('torn-divider', 'divider-vertical');
|
||||||
else node.append(beer);
|
beer.style.backgroundColor = '#c8c8c8';
|
||||||
(<MyHTMLElement>e.target).remove();
|
beer.innerHTML = SHOP_BEER_STATIC_ITEM_HTML;
|
||||||
msg_node.innerHTML = '添加成功';
|
if (clear_node) clear_node.before(beer);
|
||||||
});
|
else node.append(beer);
|
||||||
document.querySelector('.content-wrapper').prepend(add_btn_node);
|
// (<MyHTMLElement>e.target).remove();
|
||||||
|
(<HTMLInputElement>e.target).disabled = true;
|
||||||
|
msg_node.innerHTML = '添加成功';
|
||||||
});
|
});
|
||||||
|
// });
|
||||||
|
|
||||||
// 监听啤酒购买
|
// 监听啤酒购买
|
||||||
$(document).ajaxComplete((_, xhr, settings) => {
|
$(document).ajaxComplete((_, xhr, settings) => {
|
||||||
Log.info({ xhr, settings });
|
Log.info({ xhr, settings });
|
||||||
|
|||||||
@ -71,6 +71,13 @@ export default class WuHuTornHelper extends WuhuBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 谷歌跟踪
|
||||||
|
window._gaUserPrefs = {
|
||||||
|
ioo() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
Log.info('WuHuTornHelper初始化结束');
|
Log.info('WuHuTornHelper初始化结束');
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -22,11 +22,10 @@ import ZHONG_MENU_HTML from "../static/html/zhong/zhong_menu.html";
|
|||||||
import ZHONG_UPDATE_HTML from "../static/html/zhong/zhong_update.html";
|
import ZHONG_UPDATE_HTML from "../static/html/zhong/zhong_update.html";
|
||||||
import ZHONG_LOOT_HTML from "../static/html/zhong/zhong_loot.html";
|
import ZHONG_LOOT_HTML from "../static/html/zhong/zhong_loot.html";
|
||||||
import QUICK_CRIMES_HTML from "../static/html/quick_crimes.html";
|
import QUICK_CRIMES_HTML from "../static/html/quick_crimes.html";
|
||||||
import DEV_DETAILS_HTML from "../static/html/zhong/setting/dev_details.html";
|
|
||||||
import QUICK_FLY_CSS from "../static/css/quick_fly.css";
|
import QUICK_FLY_CSS from "../static/css/quick_fly.css";
|
||||||
import QUICK_LINK_CSS from "../static/css/quick_link.css";
|
import QUICK_LINK_CSS from "../static/css/quick_link.css";
|
||||||
import MDUtils from "./utils/MDUtils";
|
import MDUtils from "./utils/MDUtils";
|
||||||
import TornStyleBlock from "./utils/TornStyleBlock";
|
import Test from "../test/Test";
|
||||||
|
|
||||||
export default class ZhongIcon extends WuhuBase {
|
export default class ZhongIcon extends WuhuBase {
|
||||||
public static ZhongNode: MyHTMLElement = null;
|
public static ZhongNode: MyHTMLElement = null;
|
||||||
@ -112,7 +111,7 @@ export default class ZhongIcon extends WuhuBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 移动节点
|
// 移动节点
|
||||||
Log.info('创建node', new_node);
|
// Log.info('创建node', new_node);
|
||||||
return root_node.appendChild(new_node);
|
return root_node.appendChild(new_node);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -737,24 +736,27 @@ export default class ZhongIcon extends WuhuBase {
|
|||||||
$zhongNode.setting_root = document.createElement('div');
|
$zhongNode.setting_root = document.createElement('div');
|
||||||
$zhongNode.setting_root.classList.add('gSetting');
|
$zhongNode.setting_root.classList.add('gSetting');
|
||||||
// ZhongIcon.getSettingItems(glob).forEach(set => ZhongIcon.elemGenerator(set, $zhongNode.setting_root));
|
// ZhongIcon.getSettingItems(glob).forEach(set => ZhongIcon.elemGenerator(set, $zhongNode.setting_root));
|
||||||
|
let startTime = performance.now();
|
||||||
|
Log.info('构造设置开始');
|
||||||
this.settingItemList.forEach(set => this.elemGenerator(set, $zhongNode.setting_root));
|
this.settingItemList.forEach(set => this.elemGenerator(set, $zhongNode.setting_root));
|
||||||
let pop = new Popup('', '芜湖助手设置');
|
let pop = new Popup('', '芜湖助手设置');
|
||||||
pop.getElement().appendChild($zhongNode.setting_root);
|
pop.getElement().appendChild($zhongNode.setting_root);
|
||||||
// 本日不提醒
|
// 本日不提醒
|
||||||
$zhongNode.setting_root.querySelector('#wh-qua-alarm-check-btn').addEventListener('click', glob.beer.skip_today);
|
$zhongNode.setting_root.querySelector('#wh-qua-alarm-check-btn').addEventListener('click', glob.beer.skip_today);
|
||||||
// 开发详情按钮
|
// 开发详情按钮
|
||||||
if (Log.debug()) $zhongNode.setting_root.querySelector('button#wh-devInfo').onclick = () => {
|
// if (Log.debug()) $zhongNode.setting_root.querySelector('button#wh-devInfo').onclick = () => {
|
||||||
const date = new Date();
|
// const date = new Date();
|
||||||
let os = '未知';
|
// let os = '未知';
|
||||||
try {
|
// try {
|
||||||
os = window.navigator.userAgentData.platform || window.navigator.platform
|
// os = window.navigator.userAgentData.platform || window.navigator.platform
|
||||||
} catch {
|
// } catch {
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
pop.close();
|
// pop.close();
|
||||||
new Popup(DEV_DETAILS_HTML, '开发者详情');
|
// new Popup(DEV_DETAILS_HTML, '开发者详情');
|
||||||
};
|
// };
|
||||||
(window.initializeTooltip) && (window.initializeTooltip('#wh-popup-cont', 'white-tooltip'));
|
(window.initializeTooltip) && (window.initializeTooltip('#wh-popup-cont', 'white-tooltip'));
|
||||||
|
Log.info('构造设置结束,' + ((performance.now() - startTime) | 0) + 'ms');
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
// 测试
|
// 测试
|
||||||
@ -763,11 +765,15 @@ export default class ZhongIcon extends WuhuBase {
|
|||||||
domId: '',
|
domId: '',
|
||||||
domText: '📐️ 测试',
|
domText: '📐️ 测试',
|
||||||
clickFunc: async function () {
|
clickFunc: async function () {
|
||||||
|
let startTime = performance.now();
|
||||||
Log.info('测试开始');
|
Log.info('测试开始');
|
||||||
|
try {
|
||||||
|
Test.getInstance().test();
|
||||||
|
} catch (e) {
|
||||||
|
Log.error('测试异常,' + JSON.stringify(e));
|
||||||
|
}
|
||||||
|
|
||||||
new TornStyleBlock('123').insert2Dom();
|
Log.info('测试结束 ' + ((performance.now() - startTime) | 0) + 'ms');
|
||||||
|
|
||||||
Log.info('测试结束');
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -1024,7 +1030,6 @@ export default class ZhongIcon extends WuhuBase {
|
|||||||
domText: '啤酒提醒时间设定',
|
domText: '啤酒提醒时间设定',
|
||||||
// tip: '通知提前时间',
|
// tip: '通知提前时间',
|
||||||
clickFunc: function () {
|
clickFunc: function () {
|
||||||
popup_node.close();
|
|
||||||
let popup = new Popup(`<label>提前提醒时间(秒):<input type="number" value="${ WuhuConfig.get('_15AlarmTime') }" /></label><p>区间为 1 ~ 60,默认 50</p>`, '啤酒提醒时间设定');
|
let popup = new Popup(`<label>提前提醒时间(秒):<input type="number" value="${ WuhuConfig.get('_15AlarmTime') }" /></label><p>区间为 1 ~ 60,默认 50</p>`, '啤酒提醒时间设定');
|
||||||
let confirm = document.createElement('button');
|
let confirm = document.createElement('button');
|
||||||
confirm.innerHTML = '确定';
|
confirm.innerHTML = '确定';
|
||||||
|
|||||||
@ -35,7 +35,6 @@ export default class BuyBeerHelper extends WuhuBase implements BeerMonitorLoop {
|
|||||||
const now = [dt.getUTCFullYear(), dt.getUTCMonth(), dt.getUTCDate()];
|
const now = [dt.getUTCFullYear(), dt.getUTCMonth(), dt.getUTCDate()];
|
||||||
const ignore_date = WuhuConfig.get('_15_alarm_ignore') || '{}';
|
const ignore_date = WuhuConfig.get('_15_alarm_ignore') || '{}';
|
||||||
if (JSON.stringify(now) === JSON.stringify(ignore_date)) return;
|
if (JSON.stringify(now) === JSON.stringify(ignore_date)) return;
|
||||||
Log.info('不提醒状态', now, ignore_date);
|
|
||||||
// 正常提醒
|
// 正常提醒
|
||||||
let m = 14 - (dt.getMinutes() % 15);
|
let m = 14 - (dt.getMinutes() % 15);
|
||||||
let s = 60 - dt.getSeconds();
|
let s = 60 - dt.getSeconds();
|
||||||
|
|||||||
@ -8,28 +8,19 @@ 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 {
|
||||||
private obj: any = null;
|
private readonly apiUrl: string = 'https://yata.yt/api/v1/travel/export/';
|
||||||
private res: any = null;
|
private foreignStockInfo: any = null;
|
||||||
|
|
||||||
public constructor() {
|
public constructor() {
|
||||||
super();
|
super();
|
||||||
window.setInterval(async () => {
|
window.setInterval(async () => {
|
||||||
if (!WindowActiveState.getInstance().get()) return;
|
if (!WindowActiveState.getInstance().get()) return;
|
||||||
Log.info('fetching https://yata.yt/api/v1/travel/export/');
|
Log.info('fetching ', this.apiUrl);
|
||||||
const res = await CommonUtils.COFetch('https://yata.yt/api/v1/travel/export/');
|
this.foreignStockInfo = JSON.parse(await CommonUtils.COFetch(this.apiUrl));
|
||||||
Log.info({ 'fetch returned': res });
|
Log.info({ 'fetch returned': this.foreignStockInfo });
|
||||||
this.obj = JSON.parse(res);
|
|
||||||
}, 30 * 1000);
|
}, 30 * 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
async get() {
|
|
||||||
if (!this.obj) {
|
|
||||||
const str = await this.res
|
|
||||||
this.obj = JSON.parse(str);
|
|
||||||
}
|
|
||||||
return this.obj;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 呈现内容
|
// 呈现内容
|
||||||
public async clickHandler(): Promise<void> {
|
public async clickHandler(): Promise<void> {
|
||||||
if (CommonUtils.getScriptEngine() === UserScriptEngine.RAW) {
|
if (CommonUtils.getScriptEngine() === UserScriptEngine.RAW) {
|
||||||
@ -41,7 +32,7 @@ export default class TravelItem extends WuhuBase {
|
|||||||
const now = new Date();
|
const now = new Date();
|
||||||
const res = await this.get();
|
const res = await this.get();
|
||||||
Log.info({ res })
|
Log.info({ res })
|
||||||
if (!res.stocks) return;
|
if (!res || !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
|
||||||
table += `<tr><td>${ el.show }</td><td>${ update / 60 | 0 }分${ update % 60 | 0 }秒前</td>`;
|
table += `<tr><td>${ el.show }</td><td>${ update / 60 | 0 }分${ update % 60 | 0 }秒前</td>`;
|
||||||
@ -62,4 +53,8 @@ export default class TravelItem extends WuhuBase {
|
|||||||
popup.getElement().innerHTML = table;
|
popup.getElement().innerHTML = table;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async get() {
|
||||||
|
return this.foreignStockInfo ||= JSON.parse(await CommonUtils.COFetch(this.apiUrl));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -21,7 +21,6 @@ export default class Provider {
|
|||||||
public static getPool() {
|
public static getPool() {
|
||||||
return {
|
return {
|
||||||
pool: Provider.pool,
|
pool: Provider.pool,
|
||||||
// Json: JSON.stringify(Provider.pool)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -135,27 +135,27 @@ export default class CommonUtils extends WuhuBase {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过 mutation.observe 方法异步返回元素
|
* 通过 mutation.observe 方法异步返回元素
|
||||||
* @param {String} selector - CSS规则的HTML元素选择器
|
* @param {String} selectors - CSS规则的HTML元素选择器
|
||||||
* @param {Document} content - 上下文
|
* @param {Document} content - 上下文
|
||||||
* @param {number} timeout - 超时毫秒数
|
* @param {number} timeout - 超时毫秒数
|
||||||
* @returns {Promise<HTMLElement|null>}
|
* @returns {Promise<HTMLElement|null>}
|
||||||
*/
|
*/
|
||||||
static elementReady(selector: string, content: Document = document, timeout: number = 30000): Promise<HTMLElement> {
|
static elementReady(selectors: string, content: Document = document, timeout: number = 30000): Promise<HTMLElement> {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
let el = content.querySelector(selector) as HTMLElement;
|
let el = content.querySelector(selectors) as HTMLElement;
|
||||||
if (el) {
|
if (el) {
|
||||||
resolve(el);
|
resolve(el);
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
let observer = new MutationObserver((_, observer) => {
|
let observer = new MutationObserver((_, observer) => {
|
||||||
content.querySelectorAll(selector).forEach((element) => {
|
content.querySelectorAll(selectors).forEach((element) => {
|
||||||
observer.disconnect();
|
observer.disconnect();
|
||||||
resolve(element as HTMLElement);
|
resolve(element as HTMLElement);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
observer.disconnect();
|
observer.disconnect();
|
||||||
reject(`等待元素超时! [${ selector }]\n${ content.documentElement.tagName }`);
|
reject(`等待元素超时! [${ selectors }]\n${ content.documentElement.tagName }`);
|
||||||
}, timeout);
|
}, timeout);
|
||||||
observer.observe(content.documentElement, { childList: true, subtree: true });
|
observer.observe(content.documentElement, { childList: true, subtree: true });
|
||||||
});
|
});
|
||||||
|
|||||||
@ -20,6 +20,7 @@ export default class Popup extends WuhuBase {
|
|||||||
this.container = popup;
|
this.container = popup;
|
||||||
this.node = popup.querySelector('#wh-popup-cont');
|
this.node = popup.querySelector('#wh-popup-cont');
|
||||||
this.hideChat();
|
this.hideChat();
|
||||||
|
Popup.glob.popup_node = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public close() {
|
public close() {
|
||||||
|
|||||||
@ -10,14 +10,17 @@ export default class TornStyleBlock {
|
|||||||
this.baseElement = document.createElement('div');
|
this.baseElement = document.createElement('div');
|
||||||
this.headElement = document.createElement('div');
|
this.headElement = document.createElement('div');
|
||||||
this.elem = document.createElement('div');
|
this.elem = document.createElement('div');
|
||||||
|
// let hr = document.createElement('hr');
|
||||||
|
|
||||||
this.headElement.classList.add('title-black', 'm-top10', 'top-round');
|
this.headElement.classList.add('title-black', 'm-top10', 'top-round');
|
||||||
this.headElement.innerHTML = title;
|
this.headElement.innerHTML = title;
|
||||||
this.elem.classList.add('cont-gray', 'bottom-round');
|
this.elem.classList.add('cont-gray', 'bottom-round');
|
||||||
this.elem.style.padding = '0.5em';
|
this.elem.style.padding = '0.5em';
|
||||||
|
// hr.classList.add('delimiter-999', 'm-top10', 'm-bottom10');
|
||||||
|
|
||||||
this.baseElement.append(this.headElement, this.elem);
|
this.baseElement.append(this.headElement, this.elem);
|
||||||
this.baseElement.id = 'WHTornStyleBlock' + MathUtils.getInstance().getRandomInt(0, 100);
|
this.baseElement.id = 'WHTornStyleBlock' + MathUtils.getInstance().getRandomInt(0, 100);
|
||||||
|
this.baseElement.insertAdjacentHTML('beforeend', '<hr class="delimiter-999 m-top10 m-bottom10" />');
|
||||||
}
|
}
|
||||||
|
|
||||||
public append(...el: Element[]): TornStyleBlock {
|
public append(...el: Element[]): TornStyleBlock {
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import ActionButtonUtils from "../../class/utils/ActionButtonUtils";
|
|||||||
import WuhuConfig from "../../class/WuhuConfig";
|
import WuhuConfig from "../../class/WuhuConfig";
|
||||||
import FetchUtils from "../../class/utils/FetchUtils";
|
import FetchUtils from "../../class/utils/FetchUtils";
|
||||||
import DEPO_CSS from "../../static/css/depo.css";
|
import DEPO_CSS from "../../static/css/depo.css";
|
||||||
|
import TornStyleBlock from "../../class/utils/TornStyleBlock";
|
||||||
|
|
||||||
export default function depoHelper() {
|
export default function depoHelper() {
|
||||||
let actionButtonUtils: ActionButtonUtils = ActionButtonUtils.getInstance();
|
let actionButtonUtils: ActionButtonUtils = ActionButtonUtils.getInstance();
|
||||||
@ -65,18 +66,23 @@ export default function depoHelper() {
|
|||||||
if (location.pathname.startsWith('/trade.php')) {
|
if (location.pathname.startsWith('/trade.php')) {
|
||||||
// GT助手
|
// GT助手
|
||||||
let node_link = null;
|
let node_link = null;
|
||||||
let handle = () => {
|
let handle = (id: string = null) => {
|
||||||
let { addRFC } = window;
|
let { addRFC } = window;
|
||||||
// 不重复加载、已关闭的交易不加载
|
// 不重复加载、已关闭的交易不加载
|
||||||
if (node_link !== null || location.hash.includes('Logview')) return;
|
if (node_link !== null || location.hash.toLowerCase().includes('logview')) {
|
||||||
|
if (node_link) {
|
||||||
|
node_link.return();
|
||||||
|
node_link = null;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
Log.info('已添加GT助手');
|
Log.info('已添加GT助手');
|
||||||
// 获取交易id
|
// 获取交易id
|
||||||
let query_params = location.hash.slice(1);
|
let query_params = location.hash.slice(1);
|
||||||
let traceId;
|
let traceId = id;
|
||||||
query_params.split('&')
|
if (!traceId) query_params.split('&').forEach(param =>
|
||||||
.forEach(param =>
|
(param.startsWith('ID=')) && (traceId = param.slice(3))
|
||||||
(param.startsWith('ID=')) && (traceId = param.slice(3))
|
);
|
||||||
);
|
|
||||||
Log.info('交易id为', traceId);
|
Log.info('交易id为', traceId);
|
||||||
|
|
||||||
// 获取全部的钱数
|
// 获取全部的钱数
|
||||||
@ -90,38 +96,44 @@ export default function depoHelper() {
|
|||||||
if (Log.debug()) $(document).ajaxComplete((_, xhr, settings) => Log.info({ xhr, settings }));
|
if (Log.debug()) $(document).ajaxComplete((_, xhr, settings) => Log.info({ xhr, settings }));
|
||||||
// react 加载完成后将节点加入视图中
|
// react 加载完成后将节点加入视图中
|
||||||
CommonUtils.elementReady('#trade-container').then(() =>
|
CommonUtils.elementReady('#trade-container').then(() =>
|
||||||
document.querySelector('#trade-container').before(node)
|
document.querySelector('#trade-container').before(_node.getBase())
|
||||||
);
|
);
|
||||||
// 构建dom节点
|
// 构建dom节点
|
||||||
let node = document.createElement('div');
|
// let node = document.createElement('div');
|
||||||
node_link = node;
|
let _node = new TornStyleBlock('GT助手');
|
||||||
let nodeTitle = document.createElement('div');
|
// node_link = node;
|
||||||
let nodeCont = document.createElement('div');
|
node_link = _node;
|
||||||
|
// let nodeTitle = document.createElement('div');
|
||||||
|
// let nodeCont = document.createElement('div');
|
||||||
let inputMoney = document.createElement('input');
|
let inputMoney = document.createElement('input');
|
||||||
let buttonDepositAll = document.createElement('button');
|
let buttonDepositAll = document.createElement('button');
|
||||||
let buttonWithdraw = document.createElement('button');
|
let buttonWithdraw = document.createElement('button');
|
||||||
let buttonWithdrawAll = document.createElement('button');
|
let buttonWithdrawAll = document.createElement('button');
|
||||||
let style = document.createElement('style');
|
// let style = document.createElement('style');
|
||||||
|
|
||||||
inputMoney.placeholder = '定额取钱';
|
inputMoney.placeholder = '定额取钱';
|
||||||
inputMoney.type = 'number';
|
inputMoney.type = 'number';
|
||||||
inputMoney.style.padding = '7px';
|
inputMoney.style.padding = '7px';
|
||||||
inputMoney.style.paddingLeft = '14px';
|
inputMoney.style.paddingLeft = '14px';
|
||||||
inputMoney.classList.add('m-right10');
|
// inputMoney.classList.add('m-right10');
|
||||||
buttonDepositAll.innerHTML = '全存';
|
buttonDepositAll.innerHTML = '全存';
|
||||||
buttonDepositAll.style.color = 'green';
|
buttonDepositAll.style.color = 'green';
|
||||||
|
buttonDepositAll.classList.add('torn-btn');
|
||||||
buttonWithdraw.innerHTML = '定取';
|
buttonWithdraw.innerHTML = '定取';
|
||||||
|
buttonWithdraw.classList.add('torn-btn');
|
||||||
buttonWithdrawAll.innerHTML = '全取';
|
buttonWithdrawAll.innerHTML = '全取';
|
||||||
buttonWithdrawAll.style.color = 'red';
|
buttonWithdrawAll.style.color = 'red';
|
||||||
nodeTitle.innerHTML = 'GT助手';
|
buttonWithdrawAll.classList.add('torn-btn');
|
||||||
nodeTitle.classList.add('title-black', 'top-round');
|
// nodeTitle.innerHTML = 'GT助手';
|
||||||
style.innerHTML = '#WHGTHelper button{cursor:pointer;}#WHGTHelper button:hover{opacity:0.5;}';
|
// nodeTitle.classList.add('title-black', 'top-round');
|
||||||
nodeCont.append(inputMoney, buttonWithdraw, buttonDepositAll, buttonWithdrawAll);
|
// style.innerHTML = '#WHGTHelper button{cursor:pointer;}#WHGTHelper button:hover{opacity:0.5;}';
|
||||||
nodeCont.classList.add('cont-gray', 'bottom-round');
|
// nodeCont.append(inputMoney, buttonWithdraw, buttonDepositAll, buttonWithdrawAll);
|
||||||
nodeCont.style.padding = '10px';
|
// nodeCont.classList.add('cont-gray', 'bottom-round');
|
||||||
node.id = 'WHGTHelper';
|
// nodeCont.style.padding = '10px';
|
||||||
node.classList.add('m-bottom10');
|
// node.id = 'WHGTHelper';
|
||||||
node.append(nodeTitle, nodeCont, style);
|
// node.classList.add('m-bottom10');
|
||||||
|
// node.append(nodeTitle, nodeCont, style);
|
||||||
|
_node.append(inputMoney, buttonWithdraw, buttonDepositAll, buttonWithdrawAll);
|
||||||
|
|
||||||
// 定取
|
// 定取
|
||||||
buttonWithdraw.addEventListener('click', async () => {
|
buttonWithdraw.addEventListener('click', async () => {
|
||||||
@ -170,8 +182,12 @@ export default function depoHelper() {
|
|||||||
if (location.hash.includes('ID=')) handle();
|
if (location.hash.includes('ID=')) handle();
|
||||||
addEventListener('hashchange', () => {
|
addEventListener('hashchange', () => {
|
||||||
if (location.hash.includes('ID=')) handle();
|
if (location.hash.includes('ID=')) handle();
|
||||||
else {
|
else if (location.hash.includes('initiateTrade')) {
|
||||||
node_link.remove();
|
CommonUtils.elementReady('a[href*="trade.php#step=addmoney"]').then(node => {
|
||||||
|
handle(node.getAttribute('href').split('ID=')[1])
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
if (node_link) node_link.remove();
|
||||||
node_link = null;
|
node_link = null;
|
||||||
Log.info('已移除GT助手');
|
Log.info('已移除GT助手');
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,40 +1,40 @@
|
|||||||
import UserScriptEngine from "../../../enum/UserScriptEngine";
|
// import UserScriptEngine from "../../../enum/UserScriptEngine";
|
||||||
import WuhuBase from "../../../class/WuhuBase";
|
// import WuhuBase from "../../../class/WuhuBase";
|
||||||
import CommonUtils from "../../../class/utils/CommonUtils";
|
// import CommonUtils from "../../../class/utils/CommonUtils";
|
||||||
import Popup from "../../../class/utils/Popup";
|
// import Popup from "../../../class/utils/Popup";
|
||||||
import * as FILTER from "../../../static/json/for_stock_item_filter.json";
|
// import * as FILTER from "../../../static/json/for_stock_item_filter.json";
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* @deprecated
|
// * @deprecated
|
||||||
*/
|
// */
|
||||||
export default async function forStock() {
|
// export default async function forStock() {
|
||||||
if (CommonUtils.getScriptEngine() === UserScriptEngine.RAW) {
|
// if (CommonUtils.getScriptEngine() === UserScriptEngine.RAW) {
|
||||||
const insert = `<img alt="stock.png" src="https://jjins.github.io/t2i/stock.png?{{}}" style="max-width:100%;display:block;margin:0 auto;" />`;
|
// const insert = `<img alt="stock.png" src="https://jjins.github.io/t2i/stock.png?{{}}" style="max-width:100%;display:block;margin:0 auto;" />`;
|
||||||
new Popup(insert, '飞花库存');
|
// new Popup(insert, '飞花库存');
|
||||||
} else {
|
// } else {
|
||||||
const popup = new Popup(`请稍后${ CommonUtils.loading_gif_html() }`, '飞花库存');
|
// const popup = new Popup(`请稍后${ CommonUtils.loading_gif_html() }`, '飞花库存');
|
||||||
let table = `<table><tr><th colspan="2">目的地 - 更新时间</th><th colspan="3">库存</th></tr>`;
|
// let table = `<table><tr><th colspan="2">目的地 - 更新时间</th><th colspan="3">库存</th></tr>`;
|
||||||
const dest = FILTER;
|
// const dest = FILTER;
|
||||||
const now = new Date();
|
// const now = new Date();
|
||||||
const res = await WuhuBase.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
|
||||||
table += `<tr><td>${ el.show }</td><td>${ update / 60 | 0 }分${ update % 60 | 0 }秒前</td>`;
|
// table += `<tr><td>${ el.show }</td><td>${ update / 60 | 0 }分${ update % 60 | 0 }秒前</td>`;
|
||||||
let count = 0;
|
// let count = 0;
|
||||||
res.stocks[el.name]['stocks'].forEach(stock => {
|
// res.stocks[el.name]['stocks'].forEach(stock => {
|
||||||
if (el.stocks[stock.name]) {
|
// if (el.stocks[stock.name]) {
|
||||||
table += `<td${ stock['quantity'] === 0 ? ' style="background-color:#f44336;color:white;border-color:#000;"' : '' }>${ el.stocks[stock.name] } (${ stock['quantity'] })</td>`;
|
// table += `<td${ stock['quantity'] === 0 ? ' style="background-color:#f44336;color:white;border-color:#000;"' : '' }>${ el.stocks[stock.name] } (${ stock['quantity'] })</td>`;
|
||||||
count++;
|
// count++;
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
while (count < 3) {
|
// while (count < 3) {
|
||||||
count++;
|
// count++;
|
||||||
table += '<td></td>';
|
// table += '<td></td>';
|
||||||
}
|
// }
|
||||||
table += '</tr>';
|
// table += '</tr>';
|
||||||
});
|
// });
|
||||||
table += '</table>';
|
// table += '</table>';
|
||||||
popup.getElement().innerHTML = table;
|
// popup.getElement().innerHTML = table;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
@ -1,5 +1,7 @@
|
|||||||
import Device from "../enum/Device";
|
import Device from "../enum/Device";
|
||||||
import { BeerMonitorLoop } from "../class/action/BuyBeerHelper";
|
import { BeerMonitorLoop } from "../class/action/BuyBeerHelper";
|
||||||
|
import Popup from "../class/utils/Popup";
|
||||||
|
import TravelItem from "../class/action/TravelItem";
|
||||||
|
|
||||||
export default interface IGlobal {
|
export default interface IGlobal {
|
||||||
GM_xmlhttpRequest?: Function;
|
GM_xmlhttpRequest?: Function;
|
||||||
@ -8,7 +10,7 @@ export default interface IGlobal {
|
|||||||
// 插件图标
|
// 插件图标
|
||||||
$zhongNode?: MyHTMLElement;
|
$zhongNode?: MyHTMLElement;
|
||||||
// 弹窗
|
// 弹窗
|
||||||
popup_node?: MyHTMLElement;
|
popup_node?: MyHTMLElement | Popup;
|
||||||
// 啤酒助手
|
// 啤酒助手
|
||||||
beer?: BeerMonitorLoop;
|
beer?: BeerMonitorLoop;
|
||||||
// 留存的通知
|
// 留存的通知
|
||||||
@ -16,7 +18,7 @@ export default interface IGlobal {
|
|||||||
// 价格监控
|
// 价格监控
|
||||||
// priceWatcher?: { status: boolean };
|
// priceWatcher?: { status: boolean };
|
||||||
// 海外库存
|
// 海外库存
|
||||||
fStock?: { get: () => Promise<any> };
|
fStock?: TravelItem;
|
||||||
// 玩家名和数字id
|
// 玩家名和数字id
|
||||||
player_info?: PlayerInfo;
|
player_info?: PlayerInfo;
|
||||||
// 设备类型
|
// 设备类型
|
||||||
|
|||||||
@ -115,7 +115,7 @@ div#wh-popup::after {
|
|||||||
max-width: 568px;
|
max-width: 568px;
|
||||||
margin: 5em auto 0;
|
margin: 5em auto 0;
|
||||||
/*background: #d7d7d7;*/
|
/*background: #d7d7d7;*/
|
||||||
min-height: 120px;
|
/*min-height: 120px;*/
|
||||||
box-shadow: 0 0 5px 1px #898989;
|
box-shadow: 0 0 5px 1px #898989;
|
||||||
/*border-radius: 4px;*/
|
/*border-radius: 4px;*/
|
||||||
}
|
}
|
||||||
@ -129,11 +129,12 @@ div#wh-popup::after {
|
|||||||
|
|
||||||
/** 弹出窗口的内容 **/
|
/** 弹出窗口的内容 **/
|
||||||
#wh-popup-cont {
|
#wh-popup-cont {
|
||||||
padding: 0 1em 1em;
|
padding: 1em;
|
||||||
max-height: 30em;
|
max-height: 30em;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
line-height: 16px;
|
line-height: 16px;
|
||||||
|
min-height: 120px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#wh-popup-cont .gSetting > div {
|
#wh-popup-cont .gSetting > div {
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
<div>
|
<div>
|
||||||
<button style="color:white;">👉添加啤酒商品</button>
|
<button class="torn-btn">👉添加啤酒商品</button>
|
||||||
<p>如果当前商店没有啤酒这个商品可以提前显示以省去刷新步骤,增加抢酒成功率。</p>
|
<p>如果当前商店没有啤酒这个商品可以提前显示以省去刷新步骤,增加抢酒成功率。</p>
|
||||||
<p id="wh-msg"></p>
|
<p id="wh-msg"></p>
|
||||||
</div>
|
</div>
|
||||||
@ -1,9 +1,45 @@
|
|||||||
import WuhuBase from "../class/WuhuBase";
|
import WuhuBase from "../class/WuhuBase";
|
||||||
import Popup from "../class/utils/Popup";
|
|
||||||
import Log from "../class/Log";
|
import Log from "../class/Log";
|
||||||
|
|
||||||
export default class Test extends WuhuBase {
|
export default class Test extends WuhuBase {
|
||||||
public test(): void {
|
public test(): void {
|
||||||
new Popup(Log.getLogs());
|
Log.info(Test.getPool());
|
||||||
|
|
||||||
|
// this.case2()
|
||||||
|
// this.case3();
|
||||||
|
}
|
||||||
|
|
||||||
|
private case1() {
|
||||||
|
const temp = document.createElement("DIV");
|
||||||
|
const temp2 = document.createElement("DIV");
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
|
temp.append(...document.body.childNodes);
|
||||||
|
// @ts-ignore
|
||||||
|
temp2.append(...document.head.childNodes);
|
||||||
|
|
||||||
|
window.stop();
|
||||||
|
|
||||||
|
// document.body.outerHTML = document.body.outerHTML;
|
||||||
|
Log.info(document.body.outerHTML);
|
||||||
|
document.body.innerHTML = "";
|
||||||
|
document.head.innerHTML = "";
|
||||||
|
// @ts-ignore
|
||||||
|
document.body.append(...temp.childNodes);
|
||||||
|
// @ts-ignore
|
||||||
|
document.head.append(...temp2.childNodes);
|
||||||
|
}
|
||||||
|
|
||||||
|
private case2() {
|
||||||
|
document.head.insertAdjacentHTML(
|
||||||
|
"afterbegin",
|
||||||
|
// `<meta http-equiv="Content-Security-Policy" content="script-src 'none'">`
|
||||||
|
`<meta http-equiv="Content-Security-Policy" content="connect-src 'self'">`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private case3() {
|
||||||
|
let xmlhttp = new XMLHttpRequest();
|
||||||
|
xmlhttp.abort();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user