diff --git a/torn-trans-zhcn.user.js b/torn-trans-zhcn.user.js
index dd55282..55774cb 100644
--- a/torn-trans-zhcn.user.js
+++ b/torn-trans-zhcn.user.js
@@ -1,8 +1,8 @@
// ==UserScript==
-// @lastmodified 202201280112
+// @lastmodified 202201281534
// @name Torn翻译
// @namespace WOOH
-// @version 0.3.3
+// @version 0.3.4
// @description Torn UI翻译
// @author Woohoo[2687093] Sabrina_Devil[2696209]
// @match https://www.torn.com/*
@@ -17,19 +17,24 @@
try {
window = UWCopy || window;
} catch (e) {
- console.error(`[wh] 错误:window对象是常量 ${e}`);
+ console.error(`[WH] 错误:window对象是常量 ${e}`);
}
// 防止脚本重复运行
if (window.WHTRANS) return;
window.WHTRANS = true;
// 版本
- const version = '0.3.3';
+ const version = '0.3.4';
// 修改历史
const changelist = [
{
todo: true,
cont: `翻译:baza npc商店、imarket、imarket搜索结果`,
},
+ {
+ ver: '0.3.4',
+ date: '20220128',
+ cont: `飞贼小助手现可在所有页面加载`,
+ },
{
ver: '0.3.3',
date: '20220128',
@@ -3027,7 +3032,6 @@
// 加载中html
const loading_gif_html = ``;
-
// 默认设置
const default_settings = [
// 开启翻译
@@ -3100,8 +3104,6 @@
});
saveSettings(true);
- const GS = {};
-
// 插件的设置dom配置列表
const settingsArr = [];
{
@@ -3321,55 +3323,7 @@
domText: '飞贼',
clickFunc: function (e) {
e.target.blur();
- if (getScriptEngine() === UserScriptEngine.PDA && !window.location.href.includes('crimes.php')) {
- notify('因PDA 或 Torn 限制仅某些页面(如 Crime 页面)可开启飞贼小助手,即将转跳,请转跳后开启。后续将会改善。', 3,
- () => window.location.href = 'https://www.torn.com/crimes.php');
- return;
- }
- if (!GS.LOADED) {
- notify('正在加载...');
- COFetch('https://cdn.staticfile.org/vue/2.2.2/vue.min.js')
- .catch(err => notify(err))
- .then(VueJS => {
- window.eval(VueJS);
- GS.LOADED = true;
- notify('已载入依赖');
- 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));
- };
- COFetch(`https://gitee.com/ameto_kasao/tornjs/raw/master/GoldenSnitch.js?${performance.now()}`)
- .then(GSJS => {
- if (getScriptEngine() === UserScriptEngine.GM) {
- window.GM_xmlhttpRequest = GM_xmlhttpRequest;
- } else if (getScriptEngine() === UserScriptEngine.PDA) {
- GSJS = GSJS.replace('http://222.160.142.50:8154/mugger', `https://jjins.github.io/mugger.json?${performance.now()}`);
-
- window.GM_xmlhttpRequest = function (opt) {
- // 暂不适配pda post
- if (opt.method.toLowerCase() === 'post') return;
-
- COFetch(opt.url).then(res => {
- const obj = {}
- obj.responseText = res
- opt.onload(obj)
- });
- };
- }
- window.eval(GSJS);
- if (isDev()) window.GM_setValue("gsp_showContent", true);
- notify('已载入飞贼助手');
- })
- .catch(err => notify(`PDA API错误。${err}`));
- });
- } else {
- notify('飞贼助手已经加载了');
- }
+ loadGS(getScriptEngine());
},
})
// 危险行为开关⚠️
@@ -3416,79 +3370,26 @@
},
})
// 测试按钮
- if (isDev()) settingsArr.push({
- domType: 'button',
- domId: 'wh-test-btn',
- domText: '测试按钮',
- clickFunc: function () {
- let pop = popupMsg('');
- let ifr = document.createElement('iframe');
- ifr.src = 'https://www.torn.com/crimes.php';
- document.body.append(ifr)
- log(ifr.contentDocument)
- ifr.onload = () => {
- const _window = ifr.contentWindow;
- const _docu = _window.document;
- _docu.head.innerHTML = '';
- _docu.body.innerHTML = '';
- COFetch('https://cdn.staticfile.org/vue/2.2.2/vue.min.js')
- // .catch(err => popup_node.innerHTML = err)
- .then(vuejs => {
- _window.eval(vuejs)
- log('Vue: ', typeof _window.Vue)
- // Eval(vuejs).catch(err => log(err)).then(() => {
- // muggerInter.hasVue = true;
- // popup_node.innerHTML += '依赖已载入
';
- _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));
- };
- COFetch(`https://gitee.com/ameto_kasao/tornjs/raw/master/GoldenSnitch.js?${performance.now()}`)
- .then(res => {
- // if (getScriptEngine() === UserScriptEngine.GM) {
- // ifr.contentWindow.GM_xmlhttpRequest = GM_xmlhttpRequest;
- // } else
- if (getScriptEngine() === UserScriptEngine.PDA) {
- res = res.replace('http://222.160.142.50:8154/mugger', `https://jjins.github.io/mugger.json?${performance.now()}`);
- _window.GM_xmlhttpRequest = function (opt) {
- // 暂不适配pda post
- if (opt.method.toLowerCase() === 'post') return;
- COFetch(opt.url).then(res => {
- const obj = {};
- obj.responseText = res;
- opt.onload(obj);
- });
- };
- }
- _window.eval(res);
- // Eval(res).catch(err => log(err)).then(() => {
- if (isDev()) _window.GM_setValue("gsp_showContent", true)
- // });
- // popup_node.innerHTML += '飞贼助手已载入
';
- })
- // .catch(err => popup_node.innerHTML = `PDA API错误。${err}`);
- // })
- });
- };
- },
- })
- // 测试按钮2
- if (isDev()) settingsArr.push({
- domType: 'button',
- domId: 'wh-test2-btn',
- domText: '测试按钮2',
- clickFunc: function () {
- notify(`测试${getRandomInt(0, 99999)}`, 5, () => log('通知关闭'));
- },
- })
+ // if (isDev()) settingsArr.push({
+ // domType: 'button',
+ // domId: 'wh-test-btn',
+ // domText: '测试按钮',
+ // clickFunc: function () {
+ // },
+ // })
+ // // 测试按钮
+ // if (isDev()) settingsArr.push({
+ // domType: 'button',
+ // domId: 'wh-test2-btn',
+ // domText: '测试按钮2',
+ // clickFunc: function () {
+ // let a = WHNotify('test', 10);
+ // },
+ // })
}
// 左侧“中”标签
const $zhongNode = initIcon();
+ // 标签中的按钮
if ($zhongNode) {
// 更新词库按钮
$zhongNode.querySelector('#wh-trans-data-update').onclick = function () {
@@ -3641,16 +3542,17 @@