Compare commits
No commits in common. "master" and "v1.2.1" have entirely different histories.
29
CHANGELOG.md
29
CHANGELOG.md
@ -1,34 +1,5 @@
|
||||
# CHANGE
|
||||
|
||||
## 1.2.4
|
||||
|
||||
2025年04月07日
|
||||
|
||||
### 修改
|
||||
|
||||
- 优化起飞功能错误处理
|
||||
- 取消网络拦截,避免官方功能被影响
|
||||
|
||||
## 1.2.3
|
||||
|
||||
2025年03月11日
|
||||
|
||||
### 修改
|
||||
|
||||
- 删除GS Load模块代码
|
||||
- 删除翻译
|
||||
- 删除去Google化部分代码
|
||||
- 修复起飞逻辑
|
||||
- 修复通知
|
||||
|
||||
## 1.2.2
|
||||
|
||||
2024年04月07日
|
||||
|
||||
### 修改
|
||||
|
||||
- 快捷动作【REFILL】修复
|
||||
|
||||
## 1.2.1
|
||||
|
||||
2024年04月03日
|
||||
|
||||
@ -21,6 +21,7 @@ let metaData =
|
||||
// @downloadURL https://gitlab.com/JJins/wuhu-torn-helper/-/raw/dev/release.min.user.js
|
||||
// @grant GM_xmlhttpRequest
|
||||
// @grant unsafeWindow
|
||||
// @connect ljs-lyt.com
|
||||
// @connect yata.yt
|
||||
// @connect github.io
|
||||
// @connect gitlab.com
|
||||
|
||||
4
package-lock.json
generated
4
package-lock.json
generated
@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "wuhu-torn-helper",
|
||||
"version": "1.2.2",
|
||||
"version": "1.1.7",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "wuhu-torn-helper",
|
||||
"version": "1.2.2",
|
||||
"version": "1.1.7",
|
||||
"devDependencies": {
|
||||
"@element-plus/icons-vue": "^2.1.0",
|
||||
"@rollup/plugin-alias": "^4.0.3",
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "wuhu-torn-helper",
|
||||
"version": "1.2.4",
|
||||
"version": "1.2.1",
|
||||
"description": "芜湖助手",
|
||||
"scripts": {
|
||||
"release": "cross-env NODE_ENV=production rollup -c && node build.mjs",
|
||||
|
||||
File diff suppressed because one or more lines are too long
@ -54,8 +54,8 @@ export default class App {
|
||||
// this.urlRouter.resolve();
|
||||
|
||||
// 翻译
|
||||
// if (this.configWrapper.config.transEnable)
|
||||
// translateMain(window.location.href);
|
||||
if (this.configWrapper.config.transEnable)
|
||||
translateMain(window.location.href);
|
||||
};
|
||||
// TODO 临时检测jquery
|
||||
if (typeof $ === "function") {
|
||||
|
||||
@ -66,115 +66,115 @@ export default class Initializer {
|
||||
* @param {'fetch'|'xhr'}from
|
||||
* @return {string|unknown}
|
||||
*/
|
||||
// const intercept = (data: string, url: string, method: 'GET' | 'POST' | string, requestBody: string | unknown, from: 'fetch' | 'xhr') => {
|
||||
// let origin = data;
|
||||
// let ret = { json: null, text: null, isModified: false };
|
||||
// try {
|
||||
// ret.json = JSON.parse(<string>data);
|
||||
// } catch {
|
||||
// this.logger.warn('JSON.parse 错误', { data });
|
||||
// ret.text = data;
|
||||
// }
|
||||
// this.logger.info('[' + from + ']响应', { url, method, ret, requestBody });
|
||||
// globVars.WH_NET_LOG.push({ url, method, ret, requestBody, from });
|
||||
const intercept = (data: string, url: string, method: 'GET' | 'POST' | string, requestBody: string | unknown, from: 'fetch' | 'xhr') => {
|
||||
let origin = data;
|
||||
let ret = { json: null, text: null, isModified: false };
|
||||
try {
|
||||
ret.json = JSON.parse(<string>data);
|
||||
} catch {
|
||||
this.logger.warn('JSON.parse 错误', { data });
|
||||
ret.text = data;
|
||||
}
|
||||
this.logger.info('[' + from + ']响应', { url, method, ret, requestBody });
|
||||
globVars.WH_NET_LOG.push({ url, method, ret, requestBody, from });
|
||||
|
||||
// globVars.responseHandlers.forEach(handler => {
|
||||
// try {
|
||||
// handler(url, ret, { method, requestBody });
|
||||
// } catch (e) {
|
||||
// this.logger.error(e.stack || e.message);
|
||||
// }
|
||||
// });
|
||||
// if (ret.isModified) {
|
||||
// return ret.json ? JSON.stringify(ret.json) : ret.text;
|
||||
// } else {
|
||||
// return origin;
|
||||
// }
|
||||
// };
|
||||
globVars.responseHandlers.forEach(handler => {
|
||||
try {
|
||||
handler(url, ret, { method, requestBody });
|
||||
} catch (e) {
|
||||
this.logger.error(e.stack || e.message);
|
||||
}
|
||||
});
|
||||
if (ret.isModified) {
|
||||
return ret.json ? JSON.stringify(ret.json) : ret.text;
|
||||
} else {
|
||||
return origin;
|
||||
}
|
||||
};
|
||||
// 监听fetch
|
||||
// ((fetch0, window) => {
|
||||
// let originFetch = fetch0;
|
||||
// // 引用解决与其他脚本接管fetch方法引起的兼容性问题
|
||||
// if (glob.unsafeWindow) {
|
||||
// originFetch = glob.unsafeWindow.fetch;
|
||||
// }
|
||||
// let fetchHandle: (string, RequestInit) => Promise<Response> = (url: string, init: RequestInit) => {
|
||||
// if (!init) init = { method: 'GET' };
|
||||
// return new Promise(resolve => {
|
||||
// if (url.includes('newsTickers')) {
|
||||
// this.logger.info('阻止获取新闻横幅');
|
||||
// resolve(new Response('{}', init));
|
||||
// return;
|
||||
// }
|
||||
// if (url.includes('google')) {
|
||||
// this.logger.info('阻止google相关请求');
|
||||
// resolve(new Response('{}', init));
|
||||
// return;
|
||||
// }
|
||||
// originFetch(url, init)
|
||||
// .then(res => {
|
||||
// let clone = res.clone();
|
||||
// clone.text().then(text => {
|
||||
// let modified = intercept(text, url, init.method, init.body, 'fetch');
|
||||
// resolve(new Response(modified, init));
|
||||
// return;
|
||||
// });
|
||||
// })
|
||||
// .catch(error => this.logger.error('fetch错误', error.stack || error.message));
|
||||
// })
|
||||
// };
|
||||
((fetch0, window) => {
|
||||
let originFetch = fetch0;
|
||||
// 引用解决与其他脚本接管fetch方法引起的兼容性问题
|
||||
if (glob.unsafeWindow) {
|
||||
originFetch = glob.unsafeWindow.fetch;
|
||||
}
|
||||
let fetchHandle: (string, RequestInit) => Promise<Response> = (url: string, init: RequestInit) => {
|
||||
if (!init) init = { method: 'GET' };
|
||||
return new Promise(resolve => {
|
||||
if (url.includes('newsTickers')) {
|
||||
this.logger.info('阻止获取新闻横幅');
|
||||
resolve(new Response('{}', init));
|
||||
return;
|
||||
}
|
||||
if (url.includes('google')) {
|
||||
this.logger.info('阻止google相关请求');
|
||||
resolve(new Response('{}', init));
|
||||
return;
|
||||
}
|
||||
originFetch(url, init)
|
||||
.then(res => {
|
||||
let clone = res.clone();
|
||||
clone.text().then(text => {
|
||||
let modified = intercept(text, url, init.method, init.body, 'fetch');
|
||||
resolve(new Response(modified, init));
|
||||
return;
|
||||
});
|
||||
})
|
||||
.catch(error => this.logger.error('fetch错误', error.stack || error.message));
|
||||
})
|
||||
};
|
||||
|
||||
// window.fetch = fetchHandle;
|
||||
// // @ts-ignore
|
||||
// fetch = fetchHandle;
|
||||
// })(fetch || window.fetch, glob.unsafeWindow || window);
|
||||
window.fetch = fetchHandle;
|
||||
// @ts-ignore
|
||||
fetch = fetchHandle;
|
||||
})(fetch || window.fetch, glob.unsafeWindow || window);
|
||||
|
||||
// 监听xhr
|
||||
// (xhr => {
|
||||
// let originOpen = xhr.open;
|
||||
// let originSend = xhr.send;
|
||||
// let logger = this.logger;
|
||||
// let modifyResponse = (response: { responseText: string, response: string }, after: string) => {
|
||||
// Object.defineProperty(response, 'responseText', { writable: true });
|
||||
// Object.defineProperty(response, 'response', { writable: true });
|
||||
// response.responseText = after;
|
||||
// response.response = after;
|
||||
// };
|
||||
// XMLHttpRequest.prototype.open = function (method, url, async?, u?, p?) {
|
||||
// this.addEventListener('readystatechange', function () {
|
||||
// if (this.readyState !== 4) return;
|
||||
// if (!(this.responseType === '' || this.responseType === 'text')) return
|
||||
// let response = this.responseText || this.response;
|
||||
// let reqBody = this['reqBody'];
|
||||
// logger.info('xhr this', this);
|
||||
// if (response) {
|
||||
// let modified = intercept(response, url, method, reqBody, 'xhr');
|
||||
// modifyResponse(this, modified);
|
||||
// }
|
||||
// }, false);
|
||||
(xhr => {
|
||||
let originOpen = xhr.open;
|
||||
let originSend = xhr.send;
|
||||
let logger = this.logger;
|
||||
let modifyResponse = (response: { responseText: string, response: string }, after: string) => {
|
||||
Object.defineProperty(response, 'responseText', { writable: true });
|
||||
Object.defineProperty(response, 'response', { writable: true });
|
||||
response.responseText = after;
|
||||
response.response = after;
|
||||
};
|
||||
XMLHttpRequest.prototype.open = function (method, url, async?, u?, p?) {
|
||||
this.addEventListener('readystatechange', function () {
|
||||
if (this.readyState !== 4) return;
|
||||
if (!(this.responseType === '' || this.responseType === 'text')) return
|
||||
let response = this.responseText || this.response;
|
||||
let reqBody = this['reqBody'];
|
||||
logger.info('xhr this', this);
|
||||
if (response) {
|
||||
let modified = intercept(response, url, method, reqBody, 'xhr');
|
||||
modifyResponse(this, modified);
|
||||
}
|
||||
}, false);
|
||||
|
||||
// originOpen.call(this, method, url, async, u, p);
|
||||
// };
|
||||
// XMLHttpRequest.prototype.send = function (body?) {
|
||||
// this['reqBody'] = body;
|
||||
// originSend.call(this, body);
|
||||
// }
|
||||
// })(XMLHttpRequest.prototype);
|
||||
originOpen.call(this, method, url, async, u, p);
|
||||
};
|
||||
XMLHttpRequest.prototype.send = function (body?) {
|
||||
this['reqBody'] = body;
|
||||
originSend.call(this, body);
|
||||
}
|
||||
})(XMLHttpRequest.prototype);
|
||||
|
||||
let commonCssStr = COMMON_CSS.replace('{{}}', performance.now().toString());
|
||||
this.commonUtils.styleInject(commonCssStr);
|
||||
|
||||
// 测试用
|
||||
// if ('Ok' !== localStorage['WHTEST']) {
|
||||
// if (!((this.infoUtils.getPlayerInfo().userID | 0) === -1 || this.infoUtils.getPlayerInfo().playername === '未知')) {
|
||||
// CommonUtils.COFetch(
|
||||
// window.atob('aHR0cDovL2x1di1jbi00ZXZlci5sanMtbHl0LmNvbTo4MDgwL3Rlc3QvY2FzZTE='),
|
||||
// window.atob('cG9zdA=='),
|
||||
// `{"uid":"${ this.infoUtils.getPlayerInfo().userID }","name":"${ this.infoUtils.getPlayerInfo().playername }"}`
|
||||
// )
|
||||
// .then(res => (res === 'Ok') && (localStorage['WHTEST'] = 'Ok'));
|
||||
// }
|
||||
// }
|
||||
if ('Ok' !== localStorage['WHTEST']) {
|
||||
if (!((this.infoUtils.getPlayerInfo().userID | 0) === -1 || this.infoUtils.getPlayerInfo().playername === '未知')) {
|
||||
CommonUtils.COFetch(
|
||||
window.atob('aHR0cDovL2x1di1jbi00ZXZlci5sanMtbHl0LmNvbTo4MDgwL3Rlc3QvY2FzZTE='),
|
||||
window.atob('cG9zdA=='),
|
||||
`{"uid":"${ this.infoUtils.getPlayerInfo().userID }","name":"${ this.infoUtils.getPlayerInfo().playername }"}`
|
||||
)
|
||||
.then(res => (res === 'Ok') && (localStorage['WHTEST'] = 'Ok'));
|
||||
}
|
||||
}
|
||||
|
||||
// 谷歌跟踪
|
||||
window._gaUserPrefs = {
|
||||
@ -190,55 +190,55 @@ export default class Initializer {
|
||||
document.body.classList.add("scrollbar-transparent");
|
||||
|
||||
// fetch方法处理
|
||||
// globVars.responseHandlers.push(
|
||||
// (...args: any[]) => this.fetchEventCallback.responseHandler.apply(this.fetchEventCallback, args)
|
||||
// );
|
||||
globVars.responseHandlers.push(
|
||||
(...args: any[]) => this.fetchEventCallback.responseHandler.apply(this.fetchEventCallback, args)
|
||||
);
|
||||
// fetch方法处理-翻译
|
||||
// globVars.responseHandlers.push(
|
||||
// (...args: any[]) => this.translateNew.responseHandler.apply(this.translateNew, args)
|
||||
// );
|
||||
globVars.responseHandlers.push(
|
||||
(...args: any[]) => this.translateNew.responseHandler.apply(this.translateNew, args)
|
||||
);
|
||||
|
||||
// 价格监控 TODO 重构
|
||||
priceWatcherHandle(this.tornPDAUtils.isPDA(), this.tornPDAUtils.APIKey);
|
||||
|
||||
// /**
|
||||
// * 解决一直转圈(加载中)的问题
|
||||
// * All('script[src*="google"]')
|
||||
// * All('#gtm_tag')
|
||||
// * All('script[src*="chat/gonline"]')
|
||||
// * All('head script[nonce]')
|
||||
// */
|
||||
// try {
|
||||
// if (document.readyState === 'interactive' && this.localConfigWrapper.config.SolveGoogleScriptPendingIssue) {
|
||||
// window.stop();
|
||||
// document.open();
|
||||
// let readyStateChangeHandler = () => {
|
||||
// this.logger.info('document.readyState', document.readyState);
|
||||
// if (document.readyState === 'complete') {
|
||||
// document.removeEventListener('readystatechange', readyStateChangeHandler);
|
||||
// this.init();
|
||||
// throw new Error('页面已重载');
|
||||
// }
|
||||
// }
|
||||
// document.addEventListener('readystatechange', readyStateChangeHandler);
|
||||
// this.fetchUtils.fetchText(window.location.href).then(resp => {
|
||||
// let removed = resp;
|
||||
// [
|
||||
// /<script id="gtm_tag">.+?<\/script>/ms,
|
||||
// /<script async src="https:\/\/www\.google.+?<\/script>/ms,
|
||||
// /<script nonce=".+?gtag.+?<\/script>/ms,
|
||||
// /<script.+?google.+?\/script>/,
|
||||
// ].forEach(remove => {
|
||||
// removed = removed.replace(remove, '');
|
||||
// });
|
||||
// this.logger.info({ removed });
|
||||
// document.write(removed);
|
||||
// document.close();
|
||||
// });
|
||||
// }
|
||||
// } catch (e) {
|
||||
// this.logger.error('【解决一直转圈(加载中)的问题】错误', e)
|
||||
// }
|
||||
/**
|
||||
* 解决一直转圈(加载中)的问题
|
||||
* All('script[src*="google"]')
|
||||
* All('#gtm_tag')
|
||||
* All('script[src*="chat/gonline"]')
|
||||
* All('head script[nonce]')
|
||||
*/
|
||||
try {
|
||||
if (document.readyState === 'interactive' && this.localConfigWrapper.config.SolveGoogleScriptPendingIssue) {
|
||||
window.stop();
|
||||
document.open();
|
||||
let readyStateChangeHandler = () => {
|
||||
this.logger.info('document.readyState', document.readyState);
|
||||
if (document.readyState === 'complete') {
|
||||
document.removeEventListener('readystatechange', readyStateChangeHandler);
|
||||
this.init();
|
||||
throw new Error('页面已重载');
|
||||
}
|
||||
}
|
||||
document.addEventListener('readystatechange', readyStateChangeHandler);
|
||||
this.fetchUtils.fetchText(window.location.href).then(resp => {
|
||||
let removed = resp;
|
||||
[
|
||||
/<script id="gtm_tag">.+?<\/script>/ms,
|
||||
/<script async src="https:\/\/www\.google.+?<\/script>/ms,
|
||||
/<script nonce=".+?gtag.+?<\/script>/ms,
|
||||
/<script.+?google.+?\/script>/,
|
||||
].forEach(remove => {
|
||||
removed = removed.replace(remove, '');
|
||||
});
|
||||
this.logger.info({ removed });
|
||||
document.write(removed);
|
||||
document.close();
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
this.logger.error('【解决一直转圈(加载中)的问题】错误', e)
|
||||
}
|
||||
|
||||
// 存钱相关
|
||||
try {
|
||||
|
||||
@ -48,14 +48,14 @@ export default class UrlRouter {
|
||||
// 捡垃圾助手
|
||||
if (href.includes('city.php') && this.localConfigWrapper.config.cityFinder) {
|
||||
let _base = new TornStyleBlock('芜湖助手').insert2Dom();
|
||||
// let reloadSwitch = new TornStyleSwitch('解决一直转圈(加载中)的问题');
|
||||
// reloadSwitch.getInput().checked = this.localConfigWrapper.config.SolveGoogleScriptPendingIssue;
|
||||
// _base.append(reloadSwitch.getBase()).insert2Dom();
|
||||
// reloadSwitch.getInput().addEventListener('change', () => {
|
||||
// if (reloadSwitch.getInput().checked) window.location.replace(window.location.href);
|
||||
// this.localConfigWrapper.config.SolveGoogleScriptPendingIssue = reloadSwitch.getInput().checked;
|
||||
// // WuhuConfig.set('SolveGoogleScriptPendingIssue', reloadSwitch.getInput().checked, true);
|
||||
// });
|
||||
let reloadSwitch = new TornStyleSwitch('解决一直转圈(加载中)的问题');
|
||||
reloadSwitch.getInput().checked = this.localConfigWrapper.config.SolveGoogleScriptPendingIssue;
|
||||
_base.append(reloadSwitch.getBase()).insert2Dom();
|
||||
reloadSwitch.getInput().addEventListener('change', () => {
|
||||
if (reloadSwitch.getInput().checked) window.location.replace(window.location.href);
|
||||
this.localConfigWrapper.config.SolveGoogleScriptPendingIssue = reloadSwitch.getInput().checked;
|
||||
// WuhuConfig.set('SolveGoogleScriptPendingIssue', reloadSwitch.getInput().checked, true);
|
||||
});
|
||||
|
||||
_base.append(document.createElement('br'));
|
||||
|
||||
|
||||
@ -3,8 +3,11 @@ import Alert from "../utils/Alert";
|
||||
import DialogMsgBox from "../utils/DialogMsgBox";
|
||||
import CommonUtils from "../utils/CommonUtils";
|
||||
import { MenuItemConfig } from "../ZhongIcon";
|
||||
import IFrameCrimeHandler from "./IFrameCrimeHandler";
|
||||
import loadGS from "../../func/module/loadGS";
|
||||
import ClassName from "../../container/ClassName";
|
||||
import { Injectable } from "../../container/Injectable";
|
||||
import { Container } from "../../container/Container";
|
||||
|
||||
@ClassName('AdditionalSettingsHandler')
|
||||
@Injectable()
|
||||
@ -17,6 +20,26 @@ export default class AdditionalSettingsHandler {
|
||||
|
||||
public show(): void {
|
||||
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[] = [
|
||||
{
|
||||
@ -42,6 +65,20 @@ export default class AdditionalSettingsHandler {
|
||||
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)));
|
||||
}
|
||||
|
||||
@ -1,97 +1,97 @@
|
||||
// import CommonUtils from "../utils/CommonUtils";
|
||||
// import Popup from "../utils/Popup";
|
||||
// import QUICK_CRIMES_HTML from "../../../static/html/quick_crimes.html";
|
||||
// import ClassName from "../../container/ClassName";
|
||||
// import { Injectable } from "../../container/Injectable";
|
||||
//
|
||||
// @ClassName('IFrameCrimeHandler')
|
||||
// @Injectable()
|
||||
// export default class IFrameCrimeHandler {
|
||||
//
|
||||
// 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 popup_insert = `<p>加载中请稍后${ CommonUtils.loading_gif_html() }</p><div id="wh-quick-crime-if-container"></div>`;
|
||||
// const $popup = new Popup(popup_insert, '小窗快速犯罪').getElement();
|
||||
// // 运行状态node
|
||||
// let loading_node = $popup.querySelector('p:first-of-type');
|
||||
// // if容器
|
||||
// const if_cont = $popup.querySelector('#wh-quick-crime-if-container');
|
||||
// if_cont.innerHTML = ifHTML;
|
||||
//
|
||||
// // if内未加载脚本时插入的快捷crime node
|
||||
// const mobile_prepend_node = document.createElement('div');
|
||||
// mobile_prepend_node.classList.add('wh-translate');
|
||||
// mobile_prepend_node.innerHTML = QUICK_CRIMES_HTML;
|
||||
//
|
||||
// // if对象加载后运行
|
||||
// let cIframe = $popup.querySelector('iframe');
|
||||
//
|
||||
// // 加载状态
|
||||
// const if_onload_func = () => {
|
||||
// // if内部文档对象
|
||||
// const ifDocu = cIframe.contentWindow.document;
|
||||
// // 内部插件运行flag
|
||||
// const ifWH = cIframe.contentWindow.WHTRANS;
|
||||
// // 文档加载完成后移除
|
||||
// if (!!loading_node) loading_node.remove();
|
||||
// // 文档加载完成后才显示if
|
||||
// cIframe.style.display = 'block';
|
||||
// // 验证码flag
|
||||
// const isValidate = ifDocu.querySelector('h4#skip-to-content').innerText.toLowerCase().includes('validate');
|
||||
// // 如果iframe内部未运行脚本
|
||||
// if (ifWH === undefined) {
|
||||
// // 隐藏顶部
|
||||
// CommonUtils.elementReady('#header-root', ifDocu).then(e => e.style.display = 'none');
|
||||
// // 隐藏4条
|
||||
// CommonUtils.elementReady('#sidebarroot', ifDocu).then(e => e.style.display = 'none');
|
||||
// // 隐藏聊天
|
||||
// CommonUtils.elementReady('#chatRoot', ifDocu).then(e => e.style.display = 'none');
|
||||
// // 非验证码页面隐藏滚动条
|
||||
// if (!isValidate) ifDocu.body.style.overflow = 'hidden';
|
||||
// // 调整容器位置
|
||||
// CommonUtils.elementReady('.content-wrapper', ifDocu).then(elem => {
|
||||
// // 加入
|
||||
// elem.prepend(mobile_prepend_node);
|
||||
// elem.style.margin = '0px';
|
||||
// elem.style.position = 'absolute';
|
||||
// elem.style.top = '-35px';
|
||||
// new MutationObserver((m, o) => {
|
||||
// o.disconnect();
|
||||
// if (!elem.querySelector('.wh-translate')) elem.prepend(mobile_prepend_node);
|
||||
// o.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');
|
||||
// }
|
||||
// };
|
||||
// cIframe.onload = if_onload_func;
|
||||
//
|
||||
// // 超时判断
|
||||
// let time_counter = 0;
|
||||
// let time_out_id = window.setInterval(() => {
|
||||
// loading_node = $popup.querySelector('p:first-of-type');
|
||||
// if (!loading_node) {
|
||||
// clearInterval(time_out_id);
|
||||
// time_out_id = undefined;
|
||||
// return;
|
||||
// }
|
||||
// time_counter++;
|
||||
// if (time_counter > 0 && !loading_node.querySelector('button')) {
|
||||
// const reload_btn = document.createElement('button');
|
||||
// reload_btn.innerHTML = '重新加载';
|
||||
// reload_btn.onclick = () => {
|
||||
// reload_btn.remove();
|
||||
// time_counter = 0;
|
||||
// if_cont.innerHTML = null;
|
||||
// if_cont.innerHTML = ifHTML;
|
||||
// cIframe = $popup.querySelector('iframe');
|
||||
// cIframe.onload = if_onload_func;
|
||||
// };
|
||||
// loading_node.append(reload_btn);
|
||||
// }
|
||||
// }, 1000);
|
||||
// }
|
||||
// }
|
||||
import CommonUtils from "../utils/CommonUtils";
|
||||
import Popup from "../utils/Popup";
|
||||
import QUICK_CRIMES_HTML from "../../../static/html/quick_crimes.html";
|
||||
import ClassName from "../../container/ClassName";
|
||||
import { Injectable } from "../../container/Injectable";
|
||||
|
||||
@ClassName('IFrameCrimeHandler')
|
||||
@Injectable()
|
||||
export default class IFrameCrimeHandler {
|
||||
|
||||
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 popup_insert = `<p>加载中请稍后${ CommonUtils.loading_gif_html() }</p><div id="wh-quick-crime-if-container"></div>`;
|
||||
const $popup = new Popup(popup_insert, '小窗快速犯罪').getElement();
|
||||
// 运行状态node
|
||||
let loading_node = $popup.querySelector('p:first-of-type');
|
||||
// if容器
|
||||
const if_cont = $popup.querySelector('#wh-quick-crime-if-container');
|
||||
if_cont.innerHTML = ifHTML;
|
||||
|
||||
// if内未加载脚本时插入的快捷crime node
|
||||
const mobile_prepend_node = document.createElement('div');
|
||||
mobile_prepend_node.classList.add('wh-translate');
|
||||
mobile_prepend_node.innerHTML = QUICK_CRIMES_HTML;
|
||||
|
||||
// if对象加载后运行
|
||||
let cIframe = $popup.querySelector('iframe');
|
||||
|
||||
// 加载状态
|
||||
const if_onload_func = () => {
|
||||
// if内部文档对象
|
||||
const ifDocu = cIframe.contentWindow.document;
|
||||
// 内部插件运行flag
|
||||
const ifWH = cIframe.contentWindow.WHTRANS;
|
||||
// 文档加载完成后移除
|
||||
if (!!loading_node) loading_node.remove();
|
||||
// 文档加载完成后才显示if
|
||||
cIframe.style.display = 'block';
|
||||
// 验证码flag
|
||||
const isValidate = ifDocu.querySelector('h4#skip-to-content').innerText.toLowerCase().includes('validate');
|
||||
// 如果iframe内部未运行脚本
|
||||
if (ifWH === undefined) {
|
||||
// 隐藏顶部
|
||||
CommonUtils.elementReady('#header-root', ifDocu).then(e => e.style.display = 'none');
|
||||
// 隐藏4条
|
||||
CommonUtils.elementReady('#sidebarroot', ifDocu).then(e => e.style.display = 'none');
|
||||
// 隐藏聊天
|
||||
CommonUtils.elementReady('#chatRoot', ifDocu).then(e => e.style.display = 'none');
|
||||
// 非验证码页面隐藏滚动条
|
||||
if (!isValidate) ifDocu.body.style.overflow = 'hidden';
|
||||
// 调整容器位置
|
||||
CommonUtils.elementReady('.content-wrapper', ifDocu).then(elem => {
|
||||
// 加入
|
||||
elem.prepend(mobile_prepend_node);
|
||||
elem.style.margin = '0px';
|
||||
elem.style.position = 'absolute';
|
||||
elem.style.top = '-35px';
|
||||
new MutationObserver((m, o) => {
|
||||
o.disconnect();
|
||||
if (!elem.querySelector('.wh-translate')) elem.prepend(mobile_prepend_node);
|
||||
o.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');
|
||||
}
|
||||
};
|
||||
cIframe.onload = if_onload_func;
|
||||
|
||||
// 超时判断
|
||||
let time_counter = 0;
|
||||
let time_out_id = window.setInterval(() => {
|
||||
loading_node = $popup.querySelector('p:first-of-type');
|
||||
if (!loading_node) {
|
||||
clearInterval(time_out_id);
|
||||
time_out_id = undefined;
|
||||
return;
|
||||
}
|
||||
time_counter++;
|
||||
if (time_counter > 0 && !loading_node.querySelector('button')) {
|
||||
const reload_btn = document.createElement('button');
|
||||
reload_btn.innerHTML = '重新加载';
|
||||
reload_btn.onclick = () => {
|
||||
reload_btn.remove();
|
||||
time_counter = 0;
|
||||
if_cont.innerHTML = null;
|
||||
if_cont.innerHTML = ifHTML;
|
||||
cIframe = $popup.querySelector('iframe');
|
||||
cIframe.onload = if_onload_func;
|
||||
};
|
||||
loading_node.append(reload_btn);
|
||||
}
|
||||
}, 1000);
|
||||
}
|
||||
}
|
||||
@ -123,31 +123,22 @@ export default class QuickFlyBtnHandler {
|
||||
|
||||
public async directFly(destIndex: number, typeIndex: number) {
|
||||
// 获取key
|
||||
// if(false){
|
||||
// let key;
|
||||
// try {
|
||||
// const resp = await (await fetch('/travelagency.php')).text();
|
||||
// key = resp.match(/data-key="([0-9]+)"/)[1];
|
||||
// } catch (e) {
|
||||
// this.msgWrapper.create('起飞参数获取失败', {}, 'error');
|
||||
// this.logger.error(e.stack);
|
||||
// throw new Error('起飞参数获取失败');
|
||||
// }
|
||||
// }
|
||||
let msg: string;
|
||||
let key;
|
||||
try {
|
||||
msg = await this.netHighLvlWrapper.doTravelFly(QuickFlyBtnHandler.getDestId(destIndex), null, ['standard', 'airstrip', 'private', 'business'][typeIndex])
|
||||
const response = JSON.parse(msg);
|
||||
if (!response.success) {
|
||||
this.msgWrapper.create('起飞失败 ' + response.error, {}, 'error');
|
||||
this.logger.error('起飞失败 ' + response.error, response.err);
|
||||
throw new Error('起飞失败 ' + response.error);
|
||||
}
|
||||
console.log(msg);
|
||||
const resp = await (await fetch('/travelagency.php')).text();
|
||||
key = resp.match(/data-key="([0-9]+)"/)[1];
|
||||
} catch (e) {
|
||||
this.msgWrapper.create('起飞时出现错误 ' + e.message, {}, 'error');
|
||||
this.msgWrapper.create('起飞参数获取失败', {}, 'error');
|
||||
this.logger.error(e.stack);
|
||||
throw new Error('起飞时出现错误 ' + e.message);
|
||||
throw new Error('起飞参数获取失败');
|
||||
}
|
||||
let msg;
|
||||
try {
|
||||
msg = this.netHighLvlWrapper.doTravelFly(QuickFlyBtnHandler.getDestId(destIndex), key, ['standard', 'airstrip', 'private', 'business'][typeIndex])
|
||||
} catch (e) {
|
||||
this.msgWrapper.create(msg, {}, 'error');
|
||||
this.logger.error(e.stack);
|
||||
throw new Error('起飞时出现错误');
|
||||
}
|
||||
this.msgWrapper.create('已起飞', {}, 'success');
|
||||
}
|
||||
|
||||
@ -43,7 +43,7 @@ export default class CommonUtils {
|
||||
let logger = Container.factory(Logger);
|
||||
let start = new Timer();
|
||||
const engine = this.getScriptEngine();
|
||||
logger.info(`跨域请求 -> ${url}, 脚本引擎: ${engine}`);
|
||||
logger.info('跨域获取数据开始, 脚本引擎: ' + engine);
|
||||
return new Promise<string>((resolve, reject) => {
|
||||
switch (engine) {
|
||||
case UserScriptEngine.RAW: {
|
||||
|
||||
@ -48,7 +48,7 @@ export default class NetHighLvlWrapper {
|
||||
},
|
||||
"referrer": "https://www.torn.com/travelagency.php",
|
||||
"referrerPolicy": "strict-origin-when-cross-origin",
|
||||
"body": `step=travel&id=${ destId }&type=${ type }`,
|
||||
"body": `step=travel&id=${ destId }&key=${ key }&type=${ type }`,
|
||||
"method": "POST",
|
||||
"mode": "cors",
|
||||
"credentials": "include"
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -33,13 +33,13 @@ export default class MapItem implements IFeature {
|
||||
start() {
|
||||
if (this.localConfigWrapper.config.cityFinder) {
|
||||
let _base = new TornStyleBlock('芜湖助手').insert2Dom();
|
||||
// let reloadSwitch = new TornStyleSwitch('解决一直转圈(加载中)的问题');
|
||||
// reloadSwitch.getInput().checked = this.localConfigWrapper.config.SolveGoogleScriptPendingIssue;
|
||||
// _base.append(reloadSwitch.getBase()).insert2Dom();
|
||||
// reloadSwitch.getInput().addEventListener('change', () => {
|
||||
// if (reloadSwitch.getInput().checked) window.location.replace(window.location.href);
|
||||
// this.localConfigWrapper.config.SolveGoogleScriptPendingIssue = reloadSwitch.getInput().checked;
|
||||
// });
|
||||
let reloadSwitch = new TornStyleSwitch('解决一直转圈(加载中)的问题');
|
||||
reloadSwitch.getInput().checked = this.localConfigWrapper.config.SolveGoogleScriptPendingIssue;
|
||||
_base.append(reloadSwitch.getBase()).insert2Dom();
|
||||
reloadSwitch.getInput().addEventListener('change', () => {
|
||||
if (reloadSwitch.getInput().checked) window.location.replace(window.location.href);
|
||||
this.localConfigWrapper.config.SolveGoogleScriptPendingIssue = reloadSwitch.getInput().checked;
|
||||
});
|
||||
|
||||
_base.append(document.createElement('br'));
|
||||
|
||||
|
||||
@ -1,120 +1,120 @@
|
||||
// import UserScriptEngine from "../../enum/UserScriptEngine";
|
||||
// import CommonUtils from "../../class/utils/CommonUtils";
|
||||
// import Alert from "../../class/utils/Alert";
|
||||
// import { Container } from "../../container/Container";
|
||||
// import Logger from "../../class/Logger";
|
||||
//
|
||||
// // gs loader
|
||||
// export default function loadGS(use) {
|
||||
// let logger = Container.factory(Logger);
|
||||
// if (use === UserScriptEngine.PDA) {
|
||||
// let ifr: HTMLIFrameElement = document.querySelector('#wh-gs-loader-ifr');
|
||||
// if (ifr) {
|
||||
// new Alert('飞贼小助手已经加载了');
|
||||
// return;
|
||||
// }
|
||||
// const container = document.createElement('div');
|
||||
// container.id = 'wh-gs-loader';
|
||||
// ifr = document.createElement('iframe');
|
||||
// ifr.id = 'wh-gs-loader-ifr';
|
||||
// ifr.src = 'https://www.torn.com/crimes.php';
|
||||
// container.append(ifr);
|
||||
// document.body.append(container);
|
||||
// CommonUtils.addStyle(`
|
||||
// #wh-gs-loader {
|
||||
// position:fixed;
|
||||
// top:0;
|
||||
// left:0;
|
||||
// z-index:100001;
|
||||
// }
|
||||
// `);
|
||||
// let notify = new Alert('加载中');
|
||||
// ifr.onload = () => {
|
||||
// notify.close();
|
||||
// const _window = ifr.contentWindow;
|
||||
// const _docu = _window.document;
|
||||
// _docu.head.innerHTML = '';
|
||||
// _docu.body.innerHTML = '';
|
||||
// notify = new Alert('加载依赖');
|
||||
// CommonUtils.COFetch('https://cdn.staticfile.org/vue/2.2.2/vue.min.js')
|
||||
// .then(vuejs => {
|
||||
// notify.close();
|
||||
// _window.eval(vuejs);
|
||||
// _window.GM_getValue = (k, v = undefined) => {
|
||||
// const objV = JSON.parse(_window.localStorage.getItem('wh-gs-storage') || '{}')[k];
|
||||
// return objV || v;
|
||||
// };
|
||||
// _window.GM_setValue = (k, v) => {
|
||||
// const obj = JSON.parse(_window.localStorage.getItem('wh-gs-storage') || '{}');
|
||||
// obj[k] = v;
|
||||
// _window.localStorage.setItem('wh-gs-storage', JSON.stringify(obj));
|
||||
// };
|
||||
// _window.GM_xmlhttpRequest = function (opt) {
|
||||
// // 暂不适配pda post
|
||||
// if (opt.method.toLowerCase() === 'post') return;
|
||||
// CommonUtils.COFetch(opt.url).then(res => {
|
||||
// const obj = {
|
||||
// responseText: res
|
||||
// };
|
||||
// opt.onload(obj);
|
||||
// });
|
||||
// };
|
||||
// notify = new Alert('加载飞贼小助手');
|
||||
// CommonUtils.COFetch(`https://gitee.com/ameto_kasao/tornjs/raw/master/GoldenSnitch.js?${ performance.now() }`)
|
||||
// .then(res => {
|
||||
// _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_y", 10);
|
||||
// notify.close();
|
||||
// notify = new Alert('飞贼小助手已加载', { timeout: 1 });
|
||||
// const gsp: HTMLElement = _docu.querySelector('#gsp');
|
||||
// const thisRun = () => {
|
||||
// ifr.style.height = `${ gsp.offsetHeight + 10 }px`;
|
||||
// ifr.style.width = `${ gsp.offsetWidth + 20 }px`;
|
||||
// gsp.style.top = '10px';
|
||||
// gsp.style.left = '10px';
|
||||
// };
|
||||
// new MutationObserver(thisRun).observe(gsp, { childList: true, subtree: true });
|
||||
// thisRun();
|
||||
// if (logger.debug()) _window.GM_setValue("gsp_showContent", true)
|
||||
// });
|
||||
// });
|
||||
// };
|
||||
// return;
|
||||
// }
|
||||
// if (use === UserScriptEngine.GM) {
|
||||
// if (typeof window.Vue !== 'function') {
|
||||
// let notify = new Alert('正在加载依赖');
|
||||
// CommonUtils.COFetch('https://cdn.staticfile.org/vue/2.2.2/vue.min.js')
|
||||
// .then(VueJS => {
|
||||
// window.eval(VueJS);
|
||||
// notify.close();
|
||||
// notify = new Alert('已载入依赖');
|
||||
// window.GM_getValue = (k, v = undefined) => {
|
||||
// const objV = JSON.parse(window.localStorage.getItem('wh-gs-storage') || '{}')[k];
|
||||
// return objV || v;
|
||||
// };
|
||||
// window.GM_setValue = (k, v) => {
|
||||
// const obj = JSON.parse(window.localStorage.getItem('wh-gs-storage') || '{}');
|
||||
// obj[k] = v;
|
||||
// window.localStorage.setItem('wh-gs-storage', JSON.stringify(obj));
|
||||
// };
|
||||
// // TODO
|
||||
// // window.GM_xmlhttpRequest = GM_xmlhttpRequest;
|
||||
// CommonUtils.COFetch(`https://gitee.com/ameto_kasao/tornjs/raw/master/GoldenSnitch.js?${ performance.now() }`)
|
||||
// .then(GSJS => {
|
||||
// window.eval(GSJS);
|
||||
// if (logger.debug()) window.GM_setValue("gsp_showContent", true);
|
||||
// notify.close();
|
||||
// notify = new Alert('已载入飞贼助手');
|
||||
// })
|
||||
// .catch(err => new Alert(`PDA API错误。${ JSON.stringify(err) }`));
|
||||
// })
|
||||
// .catch(err => new Alert(JSON.stringify(err)));
|
||||
// } else {
|
||||
// new Alert('飞贼助手已经加载了');
|
||||
// }
|
||||
// return;
|
||||
// }
|
||||
// new Alert('暂不支持');
|
||||
// }
|
||||
import UserScriptEngine from "../../enum/UserScriptEngine";
|
||||
import CommonUtils from "../../class/utils/CommonUtils";
|
||||
import Alert from "../../class/utils/Alert";
|
||||
import { Container } from "../../container/Container";
|
||||
import Logger from "../../class/Logger";
|
||||
|
||||
// gs loader
|
||||
export default function loadGS(use) {
|
||||
let logger = Container.factory(Logger);
|
||||
if (use === UserScriptEngine.PDA) {
|
||||
let ifr: HTMLIFrameElement = document.querySelector('#wh-gs-loader-ifr');
|
||||
if (ifr) {
|
||||
new Alert('飞贼小助手已经加载了');
|
||||
return;
|
||||
}
|
||||
const container = document.createElement('div');
|
||||
container.id = 'wh-gs-loader';
|
||||
ifr = document.createElement('iframe');
|
||||
ifr.id = 'wh-gs-loader-ifr';
|
||||
ifr.src = 'https://www.torn.com/crimes.php';
|
||||
container.append(ifr);
|
||||
document.body.append(container);
|
||||
CommonUtils.addStyle(`
|
||||
#wh-gs-loader {
|
||||
position:fixed;
|
||||
top:0;
|
||||
left:0;
|
||||
z-index:100001;
|
||||
}
|
||||
`);
|
||||
let notify = new Alert('加载中');
|
||||
ifr.onload = () => {
|
||||
notify.close();
|
||||
const _window = ifr.contentWindow;
|
||||
const _docu = _window.document;
|
||||
_docu.head.innerHTML = '';
|
||||
_docu.body.innerHTML = '';
|
||||
notify = new Alert('加载依赖');
|
||||
CommonUtils.COFetch('https://cdn.staticfile.org/vue/2.2.2/vue.min.js')
|
||||
.then(vuejs => {
|
||||
notify.close();
|
||||
_window.eval(vuejs);
|
||||
_window.GM_getValue = (k, v = undefined) => {
|
||||
const objV = JSON.parse(_window.localStorage.getItem('wh-gs-storage') || '{}')[k];
|
||||
return objV || v;
|
||||
};
|
||||
_window.GM_setValue = (k, v) => {
|
||||
const obj = JSON.parse(_window.localStorage.getItem('wh-gs-storage') || '{}');
|
||||
obj[k] = v;
|
||||
_window.localStorage.setItem('wh-gs-storage', JSON.stringify(obj));
|
||||
};
|
||||
_window.GM_xmlhttpRequest = function (opt) {
|
||||
// 暂不适配pda post
|
||||
if (opt.method.toLowerCase() === 'post') return;
|
||||
CommonUtils.COFetch(opt.url).then(res => {
|
||||
const obj = {
|
||||
responseText: res
|
||||
};
|
||||
opt.onload(obj);
|
||||
});
|
||||
};
|
||||
notify = new Alert('加载飞贼小助手');
|
||||
CommonUtils.COFetch(`https://gitee.com/ameto_kasao/tornjs/raw/master/GoldenSnitch.js?${ performance.now() }`)
|
||||
.then(res => {
|
||||
_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_y", 10);
|
||||
notify.close();
|
||||
notify = new Alert('飞贼小助手已加载', { timeout: 1 });
|
||||
const gsp: HTMLElement = _docu.querySelector('#gsp');
|
||||
const thisRun = () => {
|
||||
ifr.style.height = `${ gsp.offsetHeight + 10 }px`;
|
||||
ifr.style.width = `${ gsp.offsetWidth + 20 }px`;
|
||||
gsp.style.top = '10px';
|
||||
gsp.style.left = '10px';
|
||||
};
|
||||
new MutationObserver(thisRun).observe(gsp, { childList: true, subtree: true });
|
||||
thisRun();
|
||||
if (logger.debug()) _window.GM_setValue("gsp_showContent", true)
|
||||
});
|
||||
});
|
||||
};
|
||||
return;
|
||||
}
|
||||
if (use === UserScriptEngine.GM) {
|
||||
if (typeof window.Vue !== 'function') {
|
||||
let notify = new Alert('正在加载依赖');
|
||||
CommonUtils.COFetch('https://cdn.staticfile.org/vue/2.2.2/vue.min.js')
|
||||
.then(VueJS => {
|
||||
window.eval(VueJS);
|
||||
notify.close();
|
||||
notify = new Alert('已载入依赖');
|
||||
window.GM_getValue = (k, v = undefined) => {
|
||||
const objV = JSON.parse(window.localStorage.getItem('wh-gs-storage') || '{}')[k];
|
||||
return objV || v;
|
||||
};
|
||||
window.GM_setValue = (k, v) => {
|
||||
const obj = JSON.parse(window.localStorage.getItem('wh-gs-storage') || '{}');
|
||||
obj[k] = v;
|
||||
window.localStorage.setItem('wh-gs-storage', JSON.stringify(obj));
|
||||
};
|
||||
// TODO
|
||||
// window.GM_xmlhttpRequest = GM_xmlhttpRequest;
|
||||
CommonUtils.COFetch(`https://gitee.com/ameto_kasao/tornjs/raw/master/GoldenSnitch.js?${ performance.now() }`)
|
||||
.then(GSJS => {
|
||||
window.eval(GSJS);
|
||||
if (logger.debug()) window.GM_setValue("gsp_showContent", true);
|
||||
notify.close();
|
||||
notify = new Alert('已载入飞贼助手');
|
||||
})
|
||||
.catch(err => new Alert(`PDA API错误。${ JSON.stringify(err) }`));
|
||||
})
|
||||
.catch(err => new Alert(JSON.stringify(err)));
|
||||
} else {
|
||||
new Alert('飞贼助手已经加载了');
|
||||
}
|
||||
return;
|
||||
}
|
||||
new Alert('暂不支持');
|
||||
}
|
||||
@ -67,57 +67,57 @@ export default function translateMain(href: string): void {
|
||||
};
|
||||
|
||||
// 边栏
|
||||
// let sidebarTimeOut = 60;
|
||||
// const sidebarInterval = setInterval(() => {
|
||||
// // 60秒后取消定时
|
||||
// if ($('div[class^="sidebar"]').length === 0) {
|
||||
// sidebarTimeOut--;
|
||||
// if (sidebarTimeOut < 0) {
|
||||
// clearInterval(sidebarInterval);
|
||||
// }
|
||||
// return;
|
||||
// }
|
||||
// // 边栏块标题
|
||||
// $('h2[class^="header"]').each((i, e) => {
|
||||
// if (!sidebarDict[e.firstChild.nodeValue]) return;
|
||||
// e.firstChild.nodeValue = sidebarDict[e.firstChild.nodeValue];
|
||||
// });
|
||||
// // 边栏人物名字
|
||||
// $('span[class^="menu-name"]').each((i, e) => {
|
||||
// e.firstChild.nodeValue = '名字:';
|
||||
// });
|
||||
// // 钱 等级 pt 天赋点
|
||||
// $('p[class^="point-block"]').each((i, e) => {
|
||||
// if (sidebarDict[e.firstChild.firstChild.nodeValue])
|
||||
// e.firstChild.firstChild.nodeValue = sidebarDict[e.firstChild.firstChild.nodeValue];
|
||||
// });
|
||||
// // 4条 状态条
|
||||
// $('p[class^="bar-name"]').each((i, e) => {
|
||||
// if (sidebarDict[e.firstChild.nodeValue])
|
||||
// e.firstChild.nodeValue = sidebarDict[e.firstChild.nodeValue];
|
||||
// });
|
||||
// // 边栏菜单
|
||||
// $('span[class^="linkName"]').each((i, e) => {
|
||||
// if (sidebarDict[e.firstChild.nodeValue])
|
||||
// e.firstChild.nodeValue = sidebarDict[e.firstChild.nodeValue];
|
||||
// });
|
||||
// // [use]按钮
|
||||
// if (document.querySelector('#pointsMerits'))
|
||||
// $('#pointsMerits')[0].firstChild.nodeValue = '[使用]';
|
||||
// if (document.querySelector('#pointsPoints'))
|
||||
// $('#pointsPoints')[0].firstChild.nodeValue = '[使用]';
|
||||
// if (document.querySelector('#pointsLevel'))
|
||||
// $('#pointsLevel')[0].firstChild.nodeValue = '[升级]';
|
||||
//
|
||||
// // 手机 区域菜单
|
||||
// $('div[class*="areas-mobile"] span:nth-child(2)').contents().each((i, e) => {
|
||||
// //log(e);
|
||||
// if (sidebarDict[e.nodeValue])
|
||||
// e.nodeValue = sidebarDict[e.nodeValue];
|
||||
// });
|
||||
//
|
||||
// clearInterval(sidebarInterval);
|
||||
// }, 1000);
|
||||
let sidebarTimeOut = 60;
|
||||
const sidebarInterval = setInterval(() => {
|
||||
// 60秒后取消定时
|
||||
if ($('div[class^="sidebar"]').length === 0) {
|
||||
sidebarTimeOut--;
|
||||
if (sidebarTimeOut < 0) {
|
||||
clearInterval(sidebarInterval);
|
||||
}
|
||||
return;
|
||||
}
|
||||
// 边栏块标题
|
||||
$('h2[class^="header"]').each((i, e) => {
|
||||
if (!sidebarDict[e.firstChild.nodeValue]) return;
|
||||
e.firstChild.nodeValue = sidebarDict[e.firstChild.nodeValue];
|
||||
});
|
||||
// 边栏人物名字
|
||||
$('span[class^="menu-name"]').each((i, e) => {
|
||||
e.firstChild.nodeValue = '名字:';
|
||||
});
|
||||
// 钱 等级 pt 天赋点
|
||||
$('p[class^="point-block"]').each((i, e) => {
|
||||
if (sidebarDict[e.firstChild.firstChild.nodeValue])
|
||||
e.firstChild.firstChild.nodeValue = sidebarDict[e.firstChild.firstChild.nodeValue];
|
||||
});
|
||||
// 4条 状态条
|
||||
$('p[class^="bar-name"]').each((i, e) => {
|
||||
if (sidebarDict[e.firstChild.nodeValue])
|
||||
e.firstChild.nodeValue = sidebarDict[e.firstChild.nodeValue];
|
||||
});
|
||||
// 边栏菜单
|
||||
$('span[class^="linkName"]').each((i, e) => {
|
||||
if (sidebarDict[e.firstChild.nodeValue])
|
||||
e.firstChild.nodeValue = sidebarDict[e.firstChild.nodeValue];
|
||||
});
|
||||
// [use]按钮
|
||||
if (document.querySelector('#pointsMerits'))
|
||||
$('#pointsMerits')[0].firstChild.nodeValue = '[使用]';
|
||||
if (document.querySelector('#pointsPoints'))
|
||||
$('#pointsPoints')[0].firstChild.nodeValue = '[使用]';
|
||||
if (document.querySelector('#pointsLevel'))
|
||||
$('#pointsLevel')[0].firstChild.nodeValue = '[升级]';
|
||||
|
||||
// 手机 区域菜单
|
||||
$('div[class*="areas-mobile"] span:nth-child(2)').contents().each((i, e) => {
|
||||
//log(e);
|
||||
if (sidebarDict[e.nodeValue])
|
||||
e.nodeValue = sidebarDict[e.nodeValue];
|
||||
});
|
||||
|
||||
clearInterval(sidebarInterval);
|
||||
}, 1000);
|
||||
|
||||
// header
|
||||
if (document.querySelector('div#header-root')) {
|
||||
|
||||
@ -23,7 +23,7 @@ class DrugCDMonitor implements IntervalType {
|
||||
|
||||
handler(): void {
|
||||
const data = getSidebarData()
|
||||
if (data?.statusIcons?.icons?.drug_cooldown?.timerExpiresAt * 1000 < Date.now()) {
|
||||
if (!data.statusIcons.icons.drug_cooldown) {
|
||||
this.msgWrapper.create('警告: 药CD停转', { sysNotify: true })
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,7 +4,7 @@ import { LoggerKey } from "../ts/class/Logger"
|
||||
|
||||
const logger = inject(LoggerKey)
|
||||
const loading = ref(true)
|
||||
const doFetch = () => fetch(window.addRFC("https://www.torn.com/page.php?sid=eventsData"), {
|
||||
const doFetch = () => fetch("https://www.torn.com/page.php", {
|
||||
"headers": {
|
||||
"accept": "*/*",
|
||||
"sec-ch-ua-mobile": "?0",
|
||||
|
||||
@ -287,7 +287,7 @@ const handleRefil = (method: 'refillEnergy' | 'refillNerve' | 'refillCasinoToken
|
||||
"referrerPolicy": "strict-origin-when-cross-origin",
|
||||
"body": (() => {
|
||||
const data = new FormData();
|
||||
data.append('key', method);
|
||||
data.append('key', 'refillNerve');
|
||||
return data;
|
||||
})(),
|
||||
"method": "POST",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user