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