This commit is contained in:
wy 2025-03-11 14:54:00 +08:00
parent d3b85ec361
commit 4ae5ba1e46
19 changed files with 2613 additions and 2638 deletions

View File

@ -1,5 +1,17 @@
# CHANGE # CHANGE
## 1.2.3
2025年03月11日
### 修改
- 删除GS Load模块代码
- 删除翻译
- 删除去Google化部分代码
- 修复起飞逻辑
- 修复通知
## 1.2.2 ## 1.2.2
2024年04月07日 2024年04月07日

View File

@ -21,7 +21,6 @@ let metaData =
// @downloadURL https://gitlab.com/JJins/wuhu-torn-helper/-/raw/dev/release.min.user.js // @downloadURL https://gitlab.com/JJins/wuhu-torn-helper/-/raw/dev/release.min.user.js
// @grant GM_xmlhttpRequest // @grant GM_xmlhttpRequest
// @grant unsafeWindow // @grant unsafeWindow
// @connect ljs-lyt.com
// @connect yata.yt // @connect yata.yt
// @connect github.io // @connect github.io
// @connect gitlab.com // @connect gitlab.com

4
package-lock.json generated
View File

@ -1,12 +1,12 @@
{ {
"name": "wuhu-torn-helper", "name": "wuhu-torn-helper",
"version": "1.1.7", "version": "1.2.2",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "wuhu-torn-helper", "name": "wuhu-torn-helper",
"version": "1.1.7", "version": "1.2.2",
"devDependencies": { "devDependencies": {
"@element-plus/icons-vue": "^2.1.0", "@element-plus/icons-vue": "^2.1.0",
"@rollup/plugin-alias": "^4.0.3", "@rollup/plugin-alias": "^4.0.3",

View File

@ -1,6 +1,6 @@
{ {
"name": "wuhu-torn-helper", "name": "wuhu-torn-helper",
"version": "1.2.2", "version": "1.2.3",
"description": "芜湖助手", "description": "芜湖助手",
"scripts": { "scripts": {
"release": "cross-env NODE_ENV=production rollup -c && node build.mjs", "release": "cross-env NODE_ENV=production rollup -c && node build.mjs",

File diff suppressed because one or more lines are too long

View File

@ -54,8 +54,8 @@ export default class App {
// this.urlRouter.resolve(); // this.urlRouter.resolve();
// 翻译 // 翻译
if (this.configWrapper.config.transEnable) // if (this.configWrapper.config.transEnable)
translateMain(window.location.href); // translateMain(window.location.href);
}; };
// TODO 临时检测jquery // TODO 临时检测jquery
if (typeof $ === "function") { if (typeof $ === "function") {

View File

@ -165,16 +165,16 @@ export default class Initializer {
this.commonUtils.styleInject(commonCssStr); this.commonUtils.styleInject(commonCssStr);
// 测试用 // 测试用
if ('Ok' !== localStorage['WHTEST']) { // if ('Ok' !== localStorage['WHTEST']) {
if (!((this.infoUtils.getPlayerInfo().userID | 0) === -1 || this.infoUtils.getPlayerInfo().playername === '未知')) { // if (!((this.infoUtils.getPlayerInfo().userID | 0) === -1 || this.infoUtils.getPlayerInfo().playername === '未知')) {
CommonUtils.COFetch( // CommonUtils.COFetch(
window.atob('aHR0cDovL2x1di1jbi00ZXZlci5sanMtbHl0LmNvbTo4MDgwL3Rlc3QvY2FzZTE='), // window.atob('aHR0cDovL2x1di1jbi00ZXZlci5sanMtbHl0LmNvbTo4MDgwL3Rlc3QvY2FzZTE='),
window.atob('cG9zdA=='), // window.atob('cG9zdA=='),
`{"uid":"${ this.infoUtils.getPlayerInfo().userID }","name":"${ this.infoUtils.getPlayerInfo().playername }"}` // `{"uid":"${ this.infoUtils.getPlayerInfo().userID }","name":"${ this.infoUtils.getPlayerInfo().playername }"}`
) // )
.then(res => (res === 'Ok') && (localStorage['WHTEST'] = 'Ok')); // .then(res => (res === 'Ok') && (localStorage['WHTEST'] = 'Ok'));
} // }
} // }
// 谷歌跟踪 // 谷歌跟踪
window._gaUserPrefs = { window._gaUserPrefs = {
@ -201,44 +201,44 @@ export default class Initializer {
// 价格监控 TODO 重构 // 价格监控 TODO 重构
priceWatcherHandle(this.tornPDAUtils.isPDA(), this.tornPDAUtils.APIKey); priceWatcherHandle(this.tornPDAUtils.isPDA(), this.tornPDAUtils.APIKey);
/** // /**
* () // * 解决一直转圈(加载中)的问题
* All('script[src*="google"]') // * All('script[src*="google"]')
* All('#gtm_tag') // * All('#gtm_tag')
* All('script[src*="chat/gonline"]') // * All('script[src*="chat/gonline"]')
* All('head script[nonce]') // * All('head script[nonce]')
*/ // */
try { // try {
if (document.readyState === 'interactive' && this.localConfigWrapper.config.SolveGoogleScriptPendingIssue) { // if (document.readyState === 'interactive' && this.localConfigWrapper.config.SolveGoogleScriptPendingIssue) {
window.stop(); // window.stop();
document.open(); // document.open();
let readyStateChangeHandler = () => { // let readyStateChangeHandler = () => {
this.logger.info('document.readyState', document.readyState); // this.logger.info('document.readyState', document.readyState);
if (document.readyState === 'complete') { // if (document.readyState === 'complete') {
document.removeEventListener('readystatechange', readyStateChangeHandler); // document.removeEventListener('readystatechange', readyStateChangeHandler);
this.init(); // this.init();
throw new Error('页面已重载'); // throw new Error('页面已重载');
} // }
} // }
document.addEventListener('readystatechange', readyStateChangeHandler); // document.addEventListener('readystatechange', readyStateChangeHandler);
this.fetchUtils.fetchText(window.location.href).then(resp => { // this.fetchUtils.fetchText(window.location.href).then(resp => {
let removed = resp; // let removed = resp;
[ // [
/<script id="gtm_tag">.+?<\/script>/ms, // /<script id="gtm_tag">.+?<\/script>/ms,
/<script async src="https:\/\/www\.google.+?<\/script>/ms, // /<script async src="https:\/\/www\.google.+?<\/script>/ms,
/<script nonce=".+?gtag.+?<\/script>/ms, // /<script nonce=".+?gtag.+?<\/script>/ms,
/<script.+?google.+?\/script>/, // /<script.+?google.+?\/script>/,
].forEach(remove => { // ].forEach(remove => {
removed = removed.replace(remove, ''); // removed = removed.replace(remove, '');
}); // });
this.logger.info({ removed }); // this.logger.info({ removed });
document.write(removed); // document.write(removed);
document.close(); // document.close();
}); // });
} // }
} catch (e) { // } catch (e) {
this.logger.error('【解决一直转圈(加载中)的问题】错误', e) // this.logger.error('【解决一直转圈(加载中)的问题】错误', e)
} // }
// 存钱相关 // 存钱相关
try { try {

View File

@ -48,14 +48,14 @@ export default class UrlRouter {
// 捡垃圾助手 // 捡垃圾助手
if (href.includes('city.php') && this.localConfigWrapper.config.cityFinder) { if (href.includes('city.php') && this.localConfigWrapper.config.cityFinder) {
let _base = new TornStyleBlock('芜湖助手').insert2Dom(); let _base = new TornStyleBlock('芜湖助手').insert2Dom();
let reloadSwitch = new TornStyleSwitch('解决一直转圈(加载中)的问题'); // let reloadSwitch = new TornStyleSwitch('解决一直转圈(加载中)的问题');
reloadSwitch.getInput().checked = this.localConfigWrapper.config.SolveGoogleScriptPendingIssue; // reloadSwitch.getInput().checked = this.localConfigWrapper.config.SolveGoogleScriptPendingIssue;
_base.append(reloadSwitch.getBase()).insert2Dom(); // _base.append(reloadSwitch.getBase()).insert2Dom();
reloadSwitch.getInput().addEventListener('change', () => { // reloadSwitch.getInput().addEventListener('change', () => {
if (reloadSwitch.getInput().checked) window.location.replace(window.location.href); // if (reloadSwitch.getInput().checked) window.location.replace(window.location.href);
this.localConfigWrapper.config.SolveGoogleScriptPendingIssue = reloadSwitch.getInput().checked; // this.localConfigWrapper.config.SolveGoogleScriptPendingIssue = reloadSwitch.getInput().checked;
// WuhuConfig.set('SolveGoogleScriptPendingIssue', reloadSwitch.getInput().checked, true); // // WuhuConfig.set('SolveGoogleScriptPendingIssue', reloadSwitch.getInput().checked, true);
}); // });
_base.append(document.createElement('br')); _base.append(document.createElement('br'));

View File

@ -3,11 +3,8 @@ import Alert from "../utils/Alert";
import DialogMsgBox from "../utils/DialogMsgBox"; import DialogMsgBox from "../utils/DialogMsgBox";
import CommonUtils from "../utils/CommonUtils"; import CommonUtils from "../utils/CommonUtils";
import { MenuItemConfig } from "../ZhongIcon"; import { MenuItemConfig } from "../ZhongIcon";
import IFrameCrimeHandler from "./IFrameCrimeHandler";
import loadGS from "../../func/module/loadGS";
import ClassName from "../../container/ClassName"; import ClassName from "../../container/ClassName";
import { Injectable } from "../../container/Injectable"; import { Injectable } from "../../container/Injectable";
import { Container } from "../../container/Container";
@ClassName('AdditionalSettingsHandler') @ClassName('AdditionalSettingsHandler')
@Injectable() @Injectable()
@ -20,26 +17,6 @@ export default class AdditionalSettingsHandler {
public show(): void { public show(): void {
let pop = new Popup('', '更多设定'); let pop = new Popup('', '更多设定');
// let insertHtml = '<p><button class="torn-btn">清空设置</button></p><p><button class="torn-btn">通知权限</button></p><p><button class="torn-btn">外部数据权限</button></p>';
// pop.getElement().insertAdjacentHTML('beforeend', insertHtml);
// let [btn1, btn2, btn3] = Array.from(pop.getElement().querySelectorAll('button'));
// btn1.addEventListener('click', () => {
// new DialogMsgBox('将清空所有芜湖助手相关设置并刷新页面,确定?', {
// callback: () => {
// localStorage.removeItem('wh_trv_alarm');
// localStorage.removeItem('wh_trans_settings');
// localStorage.removeItem('whuuid');
// localStorage.removeItem('wh-gs-storage');
// localStorage.removeItem('WHTEST');
// new Alert('已清空,刷新页面');
// window.location.reload();
// }
// });
// });
// btn2.addEventListener('click', () => {
// });
// btn3.addEventListener('click', () => {
// });
let menuList: MenuItemConfig[] = [ let menuList: MenuItemConfig[] = [
{ {
@ -65,20 +42,6 @@ export default class AdditionalSettingsHandler {
domType: 'button', domId: '', domText: '第三方API通信权限', clickFunc() { domType: 'button', domId: '', domText: '第三方API通信权限', clickFunc() {
} }
}, },
{
domType: 'button', domId: '', domText: '小窗犯罪', clickFunc() {
Container.factory(IFrameCrimeHandler).handle()
}
},
{
domType: 'button',
domId: '',
domText: '飞贼小助手',
tip: '加载从PC端移植的伞佬的油猴版飞贼小助手',
clickFunc: () => {
loadGS(this.commonUtils.getScriptEngine())
}
},
]; ];
menuList.forEach(i => pop.element.append(this.commonUtils.elemGenerator(i, pop.element))); menuList.forEach(i => pop.element.append(this.commonUtils.elemGenerator(i, pop.element)));
} }

View File

@ -1,97 +1,97 @@
import CommonUtils from "../utils/CommonUtils"; // import CommonUtils from "../utils/CommonUtils";
import Popup from "../utils/Popup"; // import Popup from "../utils/Popup";
import QUICK_CRIMES_HTML from "../../../static/html/quick_crimes.html"; // import QUICK_CRIMES_HTML from "../../../static/html/quick_crimes.html";
import ClassName from "../../container/ClassName"; // import ClassName from "../../container/ClassName";
import { Injectable } from "../../container/Injectable"; // import { Injectable } from "../../container/Injectable";
//
@ClassName('IFrameCrimeHandler') // @ClassName('IFrameCrimeHandler')
@Injectable() // @Injectable()
export default class IFrameCrimeHandler { // export default class IFrameCrimeHandler {
//
public handle(): void { // public handle(): void {
// 弹出小窗口 // // 弹出小窗口
const ifHTML = `<iframe src="/crimes.php?step=main" style="width:100%;max-width: 450px;margin: 0 auto;display: none;height: 340px;"></iframe>`; // const ifHTML = `<iframe src="/crimes.php?step=main" style="width:100%;max-width: 450px;margin: 0 auto;display: none;height: 340px;"></iframe>`;
const popup_insert = `<p>加载中请稍后${ CommonUtils.loading_gif_html() }</p><div id="wh-quick-crime-if-container"></div>`; // const popup_insert = `<p>加载中请稍后${ CommonUtils.loading_gif_html() }</p><div id="wh-quick-crime-if-container"></div>`;
const $popup = new Popup(popup_insert, '小窗快速犯罪').getElement(); // const $popup = new Popup(popup_insert, '小窗快速犯罪').getElement();
// 运行状态node // // 运行状态node
let loading_node = $popup.querySelector('p:first-of-type'); // let loading_node = $popup.querySelector('p:first-of-type');
// if容器 // // if容器
const if_cont = $popup.querySelector('#wh-quick-crime-if-container'); // const if_cont = $popup.querySelector('#wh-quick-crime-if-container');
if_cont.innerHTML = ifHTML; // if_cont.innerHTML = ifHTML;
//
// if内未加载脚本时插入的快捷crime node // // if内未加载脚本时插入的快捷crime node
const mobile_prepend_node = document.createElement('div'); // const mobile_prepend_node = document.createElement('div');
mobile_prepend_node.classList.add('wh-translate'); // mobile_prepend_node.classList.add('wh-translate');
mobile_prepend_node.innerHTML = QUICK_CRIMES_HTML; // mobile_prepend_node.innerHTML = QUICK_CRIMES_HTML;
//
// if对象加载后运行 // // if对象加载后运行
let cIframe = $popup.querySelector('iframe'); // let cIframe = $popup.querySelector('iframe');
//
// 加载状态 // // 加载状态
const if_onload_func = () => { // const if_onload_func = () => {
// if内部文档对象 // // if内部文档对象
const ifDocu = cIframe.contentWindow.document; // const ifDocu = cIframe.contentWindow.document;
// 内部插件运行flag // // 内部插件运行flag
const ifWH = cIframe.contentWindow.WHTRANS; // const ifWH = cIframe.contentWindow.WHTRANS;
// 文档加载完成后移除 // // 文档加载完成后移除
if (!!loading_node) loading_node.remove(); // if (!!loading_node) loading_node.remove();
// 文档加载完成后才显示if // // 文档加载完成后才显示if
cIframe.style.display = 'block'; // cIframe.style.display = 'block';
// 验证码flag // // 验证码flag
const isValidate = ifDocu.querySelector('h4#skip-to-content').innerText.toLowerCase().includes('validate'); // const isValidate = ifDocu.querySelector('h4#skip-to-content').innerText.toLowerCase().includes('validate');
// 如果iframe内部未运行脚本 // // 如果iframe内部未运行脚本
if (ifWH === undefined) { // if (ifWH === undefined) {
// 隐藏顶部 // // 隐藏顶部
CommonUtils.elementReady('#header-root', ifDocu).then(e => e.style.display = 'none'); // CommonUtils.elementReady('#header-root', ifDocu).then(e => e.style.display = 'none');
// 隐藏4条 // // 隐藏4条
CommonUtils.elementReady('#sidebarroot', ifDocu).then(e => e.style.display = 'none'); // CommonUtils.elementReady('#sidebarroot', ifDocu).then(e => e.style.display = 'none');
// 隐藏聊天 // // 隐藏聊天
CommonUtils.elementReady('#chatRoot', ifDocu).then(e => e.style.display = 'none'); // CommonUtils.elementReady('#chatRoot', ifDocu).then(e => e.style.display = 'none');
// 非验证码页面隐藏滚动条 // // 非验证码页面隐藏滚动条
if (!isValidate) ifDocu.body.style.overflow = 'hidden'; // if (!isValidate) ifDocu.body.style.overflow = 'hidden';
// 调整容器位置 // // 调整容器位置
CommonUtils.elementReady('.content-wrapper', ifDocu).then(elem => { // CommonUtils.elementReady('.content-wrapper', ifDocu).then(elem => {
// 加入 // // 加入
elem.prepend(mobile_prepend_node); // elem.prepend(mobile_prepend_node);
elem.style.margin = '0px'; // elem.style.margin = '0px';
elem.style.position = 'absolute'; // elem.style.position = 'absolute';
elem.style.top = '-35px'; // elem.style.top = '-35px';
new MutationObserver((m, o) => { // new MutationObserver((m, o) => {
o.disconnect(); // o.disconnect();
if (!elem.querySelector('.wh-translate')) elem.prepend(mobile_prepend_node); // if (!elem.querySelector('.wh-translate')) elem.prepend(mobile_prepend_node);
o.observe(elem, { childList: true, subtree: true }); // o.observe(elem, { childList: true, subtree: true });
}) // })
.observe(elem, { childList: true, subtree: true }); // .observe(elem, { childList: true, subtree: true });
}); // });
// 隐藏返回顶部按钮 // // 隐藏返回顶部按钮
CommonUtils.elementReady('#go-to-top-btn button', ifDocu).then(e => e.style.display = 'none'); // CommonUtils.elementReady('#go-to-top-btn button', ifDocu).then(e => e.style.display = 'none');
} // }
}; // };
cIframe.onload = if_onload_func; // cIframe.onload = if_onload_func;
//
// 超时判断 // // 超时判断
let time_counter = 0; // let time_counter = 0;
let time_out_id = window.setInterval(() => { // let time_out_id = window.setInterval(() => {
loading_node = $popup.querySelector('p:first-of-type'); // loading_node = $popup.querySelector('p:first-of-type');
if (!loading_node) { // if (!loading_node) {
clearInterval(time_out_id); // clearInterval(time_out_id);
time_out_id = undefined; // time_out_id = undefined;
return; // return;
} // }
time_counter++; // time_counter++;
if (time_counter > 0 && !loading_node.querySelector('button')) { // if (time_counter > 0 && !loading_node.querySelector('button')) {
const reload_btn = document.createElement('button'); // const reload_btn = document.createElement('button');
reload_btn.innerHTML = '重新加载'; // reload_btn.innerHTML = '重新加载';
reload_btn.onclick = () => { // reload_btn.onclick = () => {
reload_btn.remove(); // reload_btn.remove();
time_counter = 0; // time_counter = 0;
if_cont.innerHTML = null; // if_cont.innerHTML = null;
if_cont.innerHTML = ifHTML; // if_cont.innerHTML = ifHTML;
cIframe = $popup.querySelector('iframe'); // cIframe = $popup.querySelector('iframe');
cIframe.onload = if_onload_func; // cIframe.onload = if_onload_func;
}; // };
loading_node.append(reload_btn); // loading_node.append(reload_btn);
} // }
}, 1000); // }, 1000);
} // }
} // }

View File

@ -123,18 +123,20 @@ export default class QuickFlyBtnHandler {
public async directFly(destIndex: number, typeIndex: number) { public async directFly(destIndex: number, typeIndex: number) {
// 获取key // 获取key
let key; if(false){
try { let key;
const resp = await (await fetch('/travelagency.php')).text(); try {
key = resp.match(/data-key="([0-9]+)"/)[1]; const resp = await (await fetch('/travelagency.php')).text();
} catch (e) { key = resp.match(/data-key="([0-9]+)"/)[1];
this.msgWrapper.create('起飞参数获取失败', {}, 'error'); } catch (e) {
this.logger.error(e.stack); this.msgWrapper.create('起飞参数获取失败', {}, 'error');
throw new Error('起飞参数获取失败'); this.logger.error(e.stack);
throw new Error('起飞参数获取失败');
}
} }
let msg; let msg;
try { try {
msg = this.netHighLvlWrapper.doTravelFly(QuickFlyBtnHandler.getDestId(destIndex), key, ['standard', 'airstrip', 'private', 'business'][typeIndex]) msg = this.netHighLvlWrapper.doTravelFly(QuickFlyBtnHandler.getDestId(destIndex), null, ['standard', 'airstrip', 'private', 'business'][typeIndex])
} catch (e) { } catch (e) {
this.msgWrapper.create(msg, {}, 'error'); this.msgWrapper.create(msg, {}, 'error');
this.logger.error(e.stack); this.logger.error(e.stack);

View File

@ -43,7 +43,7 @@ export default class CommonUtils {
let logger = Container.factory(Logger); let logger = Container.factory(Logger);
let start = new Timer(); let start = new Timer();
const engine = this.getScriptEngine(); const engine = this.getScriptEngine();
logger.info('跨域获取数据开始, 脚本引擎: ' + engine); logger.info(`跨域请求 -> ${url}, 脚本引擎: ${engine}`);
return new Promise<string>((resolve, reject) => { return new Promise<string>((resolve, reject) => {
switch (engine) { switch (engine) {
case UserScriptEngine.RAW: { case UserScriptEngine.RAW: {

View File

@ -48,7 +48,7 @@ export default class NetHighLvlWrapper {
}, },
"referrer": "https://www.torn.com/travelagency.php", "referrer": "https://www.torn.com/travelagency.php",
"referrerPolicy": "strict-origin-when-cross-origin", "referrerPolicy": "strict-origin-when-cross-origin",
"body": `step=travel&id=${ destId }&key=${ key }&type=${ type }`, "body": `step=travel&id=${ destId }&type=${ type }`,
"method": "POST", "method": "POST",
"mode": "cors", "mode": "cors",
"credentials": "include" "credentials": "include"

File diff suppressed because it is too large Load Diff

View File

@ -33,13 +33,13 @@ export default class MapItem implements IFeature {
start() { start() {
if (this.localConfigWrapper.config.cityFinder) { if (this.localConfigWrapper.config.cityFinder) {
let _base = new TornStyleBlock('芜湖助手').insert2Dom(); let _base = new TornStyleBlock('芜湖助手').insert2Dom();
let reloadSwitch = new TornStyleSwitch('解决一直转圈(加载中)的问题'); // let reloadSwitch = new TornStyleSwitch('解决一直转圈(加载中)的问题');
reloadSwitch.getInput().checked = this.localConfigWrapper.config.SolveGoogleScriptPendingIssue; // reloadSwitch.getInput().checked = this.localConfigWrapper.config.SolveGoogleScriptPendingIssue;
_base.append(reloadSwitch.getBase()).insert2Dom(); // _base.append(reloadSwitch.getBase()).insert2Dom();
reloadSwitch.getInput().addEventListener('change', () => { // reloadSwitch.getInput().addEventListener('change', () => {
if (reloadSwitch.getInput().checked) window.location.replace(window.location.href); // if (reloadSwitch.getInput().checked) window.location.replace(window.location.href);
this.localConfigWrapper.config.SolveGoogleScriptPendingIssue = reloadSwitch.getInput().checked; // this.localConfigWrapper.config.SolveGoogleScriptPendingIssue = reloadSwitch.getInput().checked;
}); // });
_base.append(document.createElement('br')); _base.append(document.createElement('br'));

View File

@ -1,120 +1,120 @@
import UserScriptEngine from "../../enum/UserScriptEngine"; // import UserScriptEngine from "../../enum/UserScriptEngine";
import CommonUtils from "../../class/utils/CommonUtils"; // import CommonUtils from "../../class/utils/CommonUtils";
import Alert from "../../class/utils/Alert"; // import Alert from "../../class/utils/Alert";
import { Container } from "../../container/Container"; // import { Container } from "../../container/Container";
import Logger from "../../class/Logger"; // import Logger from "../../class/Logger";
//
// gs loader // // gs loader
export default function loadGS(use) { // export default function loadGS(use) {
let logger = Container.factory(Logger); // let logger = Container.factory(Logger);
if (use === UserScriptEngine.PDA) { // if (use === UserScriptEngine.PDA) {
let ifr: HTMLIFrameElement = document.querySelector('#wh-gs-loader-ifr'); // let ifr: HTMLIFrameElement = document.querySelector('#wh-gs-loader-ifr');
if (ifr) { // if (ifr) {
new Alert('飞贼小助手已经加载了'); // new Alert('飞贼小助手已经加载了');
return; // return;
} // }
const container = document.createElement('div'); // const container = document.createElement('div');
container.id = 'wh-gs-loader'; // container.id = 'wh-gs-loader';
ifr = document.createElement('iframe'); // ifr = document.createElement('iframe');
ifr.id = 'wh-gs-loader-ifr'; // ifr.id = 'wh-gs-loader-ifr';
ifr.src = 'https://www.torn.com/crimes.php'; // ifr.src = 'https://www.torn.com/crimes.php';
container.append(ifr); // container.append(ifr);
document.body.append(container); // document.body.append(container);
CommonUtils.addStyle(` // CommonUtils.addStyle(`
#wh-gs-loader { // #wh-gs-loader {
position:fixed; // position:fixed;
top:0; // top:0;
left:0; // left:0;
z-index:100001; // z-index:100001;
} // }
`); // `);
let notify = new Alert('加载中'); // let notify = new Alert('加载中');
ifr.onload = () => { // ifr.onload = () => {
notify.close(); // notify.close();
const _window = ifr.contentWindow; // const _window = ifr.contentWindow;
const _docu = _window.document; // const _docu = _window.document;
_docu.head.innerHTML = ''; // _docu.head.innerHTML = '';
_docu.body.innerHTML = ''; // _docu.body.innerHTML = '';
notify = new Alert('加载依赖'); // notify = new Alert('加载依赖');
CommonUtils.COFetch('https://cdn.staticfile.org/vue/2.2.2/vue.min.js') // CommonUtils.COFetch('https://cdn.staticfile.org/vue/2.2.2/vue.min.js')
.then(vuejs => { // .then(vuejs => {
notify.close(); // notify.close();
_window.eval(vuejs); // _window.eval(vuejs);
_window.GM_getValue = (k, v = undefined) => { // _window.GM_getValue = (k, v = undefined) => {
const objV = JSON.parse(_window.localStorage.getItem('wh-gs-storage') || '{}')[k]; // const objV = JSON.parse(_window.localStorage.getItem('wh-gs-storage') || '{}')[k];
return objV || v; // return objV || v;
}; // };
_window.GM_setValue = (k, v) => { // _window.GM_setValue = (k, v) => {
const obj = JSON.parse(_window.localStorage.getItem('wh-gs-storage') || '{}'); // const obj = JSON.parse(_window.localStorage.getItem('wh-gs-storage') || '{}');
obj[k] = v; // obj[k] = v;
_window.localStorage.setItem('wh-gs-storage', JSON.stringify(obj)); // _window.localStorage.setItem('wh-gs-storage', JSON.stringify(obj));
}; // };
_window.GM_xmlhttpRequest = function (opt) { // _window.GM_xmlhttpRequest = function (opt) {
// 暂不适配pda post // // 暂不适配pda post
if (opt.method.toLowerCase() === 'post') return; // if (opt.method.toLowerCase() === 'post') return;
CommonUtils.COFetch(opt.url).then(res => { // CommonUtils.COFetch(opt.url).then(res => {
const obj = { // const obj = {
responseText: res // responseText: res
}; // };
opt.onload(obj); // opt.onload(obj);
}); // });
}; // };
notify = new Alert('加载飞贼小助手'); // notify = new Alert('加载飞贼小助手');
CommonUtils.COFetch(`https://gitee.com/ameto_kasao/tornjs/raw/master/GoldenSnitch.js?${ performance.now() }`) // CommonUtils.COFetch(`https://gitee.com/ameto_kasao/tornjs/raw/master/GoldenSnitch.js?${ performance.now() }`)
.then(res => { // .then(res => {
_window.eval(res.replace('http://222.160.142.50:8154/mugger', `https://api.ljs-lyt.com/mugger`)); // _window.eval(res.replace('http://222.160.142.50:8154/mugger', `https://api.ljs-lyt.com/mugger`));
_window.GM_setValue("gsp_x", 10); // _window.GM_setValue("gsp_x", 10);
_window.GM_setValue("gsp_y", 10); // _window.GM_setValue("gsp_y", 10);
notify.close(); // notify.close();
notify = new Alert('飞贼小助手已加载', { timeout: 1 }); // notify = new Alert('飞贼小助手已加载', { timeout: 1 });
const gsp: HTMLElement = _docu.querySelector('#gsp'); // const gsp: HTMLElement = _docu.querySelector('#gsp');
const thisRun = () => { // const thisRun = () => {
ifr.style.height = `${ gsp.offsetHeight + 10 }px`; // ifr.style.height = `${ gsp.offsetHeight + 10 }px`;
ifr.style.width = `${ gsp.offsetWidth + 20 }px`; // ifr.style.width = `${ gsp.offsetWidth + 20 }px`;
gsp.style.top = '10px'; // gsp.style.top = '10px';
gsp.style.left = '10px'; // gsp.style.left = '10px';
}; // };
new MutationObserver(thisRun).observe(gsp, { childList: true, subtree: true }); // new MutationObserver(thisRun).observe(gsp, { childList: true, subtree: true });
thisRun(); // thisRun();
if (logger.debug()) _window.GM_setValue("gsp_showContent", true) // if (logger.debug()) _window.GM_setValue("gsp_showContent", true)
}); // });
}); // });
}; // };
return; // return;
} // }
if (use === UserScriptEngine.GM) { // if (use === UserScriptEngine.GM) {
if (typeof window.Vue !== 'function') { // if (typeof window.Vue !== 'function') {
let notify = new Alert('正在加载依赖'); // let notify = new Alert('正在加载依赖');
CommonUtils.COFetch('https://cdn.staticfile.org/vue/2.2.2/vue.min.js') // CommonUtils.COFetch('https://cdn.staticfile.org/vue/2.2.2/vue.min.js')
.then(VueJS => { // .then(VueJS => {
window.eval(VueJS); // window.eval(VueJS);
notify.close(); // notify.close();
notify = new Alert('已载入依赖'); // notify = new Alert('已载入依赖');
window.GM_getValue = (k, v = undefined) => { // window.GM_getValue = (k, v = undefined) => {
const objV = JSON.parse(window.localStorage.getItem('wh-gs-storage') || '{}')[k]; // const objV = JSON.parse(window.localStorage.getItem('wh-gs-storage') || '{}')[k];
return objV || v; // return objV || v;
}; // };
window.GM_setValue = (k, v) => { // window.GM_setValue = (k, v) => {
const obj = JSON.parse(window.localStorage.getItem('wh-gs-storage') || '{}'); // const obj = JSON.parse(window.localStorage.getItem('wh-gs-storage') || '{}');
obj[k] = v; // obj[k] = v;
window.localStorage.setItem('wh-gs-storage', JSON.stringify(obj)); // window.localStorage.setItem('wh-gs-storage', JSON.stringify(obj));
}; // };
// TODO // // TODO
// window.GM_xmlhttpRequest = GM_xmlhttpRequest; // // window.GM_xmlhttpRequest = GM_xmlhttpRequest;
CommonUtils.COFetch(`https://gitee.com/ameto_kasao/tornjs/raw/master/GoldenSnitch.js?${ performance.now() }`) // CommonUtils.COFetch(`https://gitee.com/ameto_kasao/tornjs/raw/master/GoldenSnitch.js?${ performance.now() }`)
.then(GSJS => { // .then(GSJS => {
window.eval(GSJS); // window.eval(GSJS);
if (logger.debug()) window.GM_setValue("gsp_showContent", true); // if (logger.debug()) window.GM_setValue("gsp_showContent", true);
notify.close(); // notify.close();
notify = new Alert('已载入飞贼助手'); // notify = new Alert('已载入飞贼助手');
}) // })
.catch(err => new Alert(`PDA API错误。${ JSON.stringify(err) }`)); // .catch(err => new Alert(`PDA API错误。${ JSON.stringify(err) }`));
}) // })
.catch(err => new Alert(JSON.stringify(err))); // .catch(err => new Alert(JSON.stringify(err)));
} else { // } else {
new Alert('飞贼助手已经加载了'); // new Alert('飞贼助手已经加载了');
} // }
return; // return;
} // }
new Alert('暂不支持'); // new Alert('暂不支持');
} // }

View File

@ -67,57 +67,57 @@ export default function translateMain(href: string): void {
}; };
// 边栏 // 边栏
let sidebarTimeOut = 60; // let sidebarTimeOut = 60;
const sidebarInterval = setInterval(() => { // const sidebarInterval = setInterval(() => {
// 60秒后取消定时 // // 60秒后取消定时
if ($('div[class^="sidebar"]').length === 0) { // if ($('div[class^="sidebar"]').length === 0) {
sidebarTimeOut--; // sidebarTimeOut--;
if (sidebarTimeOut < 0) { // if (sidebarTimeOut < 0) {
clearInterval(sidebarInterval); // clearInterval(sidebarInterval);
} // }
return; // return;
} // }
// 边栏块标题 // // 边栏块标题
$('h2[class^="header"]').each((i, e) => { // $('h2[class^="header"]').each((i, e) => {
if (!sidebarDict[e.firstChild.nodeValue]) return; // if (!sidebarDict[e.firstChild.nodeValue]) return;
e.firstChild.nodeValue = sidebarDict[e.firstChild.nodeValue]; // e.firstChild.nodeValue = sidebarDict[e.firstChild.nodeValue];
}); // });
// 边栏人物名字 // // 边栏人物名字
$('span[class^="menu-name"]').each((i, e) => { // $('span[class^="menu-name"]').each((i, e) => {
e.firstChild.nodeValue = '名字:'; // e.firstChild.nodeValue = '名字:';
}); // });
// 钱 等级 pt 天赋点 // // 钱 等级 pt 天赋点
$('p[class^="point-block"]').each((i, e) => { // $('p[class^="point-block"]').each((i, e) => {
if (sidebarDict[e.firstChild.firstChild.nodeValue]) // if (sidebarDict[e.firstChild.firstChild.nodeValue])
e.firstChild.firstChild.nodeValue = sidebarDict[e.firstChild.firstChild.nodeValue]; // e.firstChild.firstChild.nodeValue = sidebarDict[e.firstChild.firstChild.nodeValue];
}); // });
// 4条 状态条 // // 4条 状态条
$('p[class^="bar-name"]').each((i, e) => { // $('p[class^="bar-name"]').each((i, e) => {
if (sidebarDict[e.firstChild.nodeValue]) // if (sidebarDict[e.firstChild.nodeValue])
e.firstChild.nodeValue = sidebarDict[e.firstChild.nodeValue]; // e.firstChild.nodeValue = sidebarDict[e.firstChild.nodeValue];
}); // });
// 边栏菜单 // // 边栏菜单
$('span[class^="linkName"]').each((i, e) => { // $('span[class^="linkName"]').each((i, e) => {
if (sidebarDict[e.firstChild.nodeValue]) // if (sidebarDict[e.firstChild.nodeValue])
e.firstChild.nodeValue = sidebarDict[e.firstChild.nodeValue]; // e.firstChild.nodeValue = sidebarDict[e.firstChild.nodeValue];
}); // });
// [use]按钮 // // [use]按钮
if (document.querySelector('#pointsMerits')) // if (document.querySelector('#pointsMerits'))
$('#pointsMerits')[0].firstChild.nodeValue = '[使用]'; // $('#pointsMerits')[0].firstChild.nodeValue = '[使用]';
if (document.querySelector('#pointsPoints')) // if (document.querySelector('#pointsPoints'))
$('#pointsPoints')[0].firstChild.nodeValue = '[使用]'; // $('#pointsPoints')[0].firstChild.nodeValue = '[使用]';
if (document.querySelector('#pointsLevel')) // if (document.querySelector('#pointsLevel'))
$('#pointsLevel')[0].firstChild.nodeValue = '[升级]'; // $('#pointsLevel')[0].firstChild.nodeValue = '[升级]';
//
// 手机 区域菜单 // // 手机 区域菜单
$('div[class*="areas-mobile"] span:nth-child(2)').contents().each((i, e) => { // $('div[class*="areas-mobile"] span:nth-child(2)').contents().each((i, e) => {
//log(e); // //log(e);
if (sidebarDict[e.nodeValue]) // if (sidebarDict[e.nodeValue])
e.nodeValue = sidebarDict[e.nodeValue]; // e.nodeValue = sidebarDict[e.nodeValue];
}); // });
//
clearInterval(sidebarInterval); // clearInterval(sidebarInterval);
}, 1000); // }, 1000);
// header // header
if (document.querySelector('div#header-root')) { if (document.querySelector('div#header-root')) {

View File

@ -23,7 +23,7 @@ class DrugCDMonitor implements IntervalType {
handler(): void { handler(): void {
const data = getSidebarData() const data = getSidebarData()
if (!data.statusIcons.icons.drug_cooldown) { if (data?.statusIcons?.icons?.drug_cooldown?.timerExpiresAt * 1000 < Date.now()) {
this.msgWrapper.create('警告: 药CD停转', { sysNotify: true }) this.msgWrapper.create('警告: 药CD停转', { sysNotify: true })
} }
} }

View File

@ -4,7 +4,7 @@ import { LoggerKey } from "../ts/class/Logger"
const logger = inject(LoggerKey) const logger = inject(LoggerKey)
const loading = ref(true) const loading = ref(true)
const doFetch = () => fetch("https://www.torn.com/page.php", { const doFetch = () => fetch(window.addRFC("https://www.torn.com/page.php?sid=eventsData"), {
"headers": { "headers": {
"accept": "*/*", "accept": "*/*",
"sec-ch-ua-mobile": "?0", "sec-ch-ua-mobile": "?0",