更新
This commit is contained in:
parent
700151510b
commit
4220ce577c
@ -4,6 +4,14 @@
|
|||||||
|
|
||||||
# CHANGE
|
# CHANGE
|
||||||
|
|
||||||
|
## 0.7.0
|
||||||
|
|
||||||
|
2022年11月10日
|
||||||
|
|
||||||
|
### 添加
|
||||||
|
|
||||||
|
- 官方引入Google登陆方式及相关脚本后引起的无限加载中的问题的不完美解决办法
|
||||||
|
|
||||||
## 0.6.9
|
## 0.6.9
|
||||||
|
|
||||||
2022年11月8日
|
2022年11月8日
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "wuhu-torn-helper",
|
"name": "wuhu-torn-helper",
|
||||||
"version": "0.6.9",
|
"version": "0.7.0",
|
||||||
"description": "芜湖助手",
|
"description": "芜湖助手",
|
||||||
"dependencies": {},
|
"dependencies": {},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@ -9,21 +9,25 @@ import CommonUtils from "./utils/CommonUtils";
|
|||||||
|
|
||||||
export default class Application {
|
export default class Application {
|
||||||
|
|
||||||
public static main() {
|
public static main(): void {
|
||||||
WuhuBase.conditionInterrupt();
|
WuhuBase.conditionInterrupt();
|
||||||
|
|
||||||
// 初始化
|
// 初始化
|
||||||
WuHuTornHelper.getInstance();
|
WuHuTornHelper.getInstance().init();
|
||||||
|
|
||||||
// 插件设置默认值
|
// 插件设置默认值
|
||||||
WuhuConfig.setDefaults();
|
WuhuConfig.setDefaults();
|
||||||
|
|
||||||
// 插件图标和设置菜单
|
// 插件图标和设置菜单
|
||||||
ZhongIcon.getInstance();
|
ZhongIcon.getInstance().init();
|
||||||
|
|
||||||
let tmp = () => {
|
let tmp = () => {
|
||||||
// 所有页面通用
|
// 所有页面通用
|
||||||
Common.getInstance().resolve();
|
try {
|
||||||
|
Common.getInstance().resolve(Application.main);
|
||||||
|
} catch (e) {
|
||||||
|
// if (e.message === '重载') Common.getInstance().resolve(null);
|
||||||
|
}
|
||||||
|
|
||||||
// URL匹配
|
// URL匹配
|
||||||
UrlPattern.getInstance().resolve();
|
UrlPattern.getInstance().resolve();
|
||||||
|
|||||||
@ -8,11 +8,12 @@ import AttackHelper from "./action/AttackHelper";
|
|||||||
import SidebarHelper from "./action/SidebarHelper";
|
import SidebarHelper from "./action/SidebarHelper";
|
||||||
import CommonUtils from "./utils/CommonUtils";
|
import CommonUtils from "./utils/CommonUtils";
|
||||||
import Log from "./Log";
|
import Log from "./Log";
|
||||||
|
import FetchUtils from "./utils/FetchUtils";
|
||||||
|
|
||||||
export class Common extends WuhuBase {
|
export class Common extends WuhuBase {
|
||||||
className = 'Common';
|
className = 'Common';
|
||||||
|
|
||||||
public resolve() {
|
public resolve(mainMethod) {
|
||||||
let glob = Common.glob;
|
let glob = Common.glob;
|
||||||
// 价格监控
|
// 价格监控
|
||||||
priceWatcherHandle(glob.isPDA, glob.PDA_APIKey);
|
priceWatcherHandle(glob.isPDA, glob.PDA_APIKey);
|
||||||
@ -23,11 +24,38 @@ export class Common extends WuhuBase {
|
|||||||
SidebarHelper.getInstance();
|
SidebarHelper.getInstance();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* 解决一直转圈(加载中)的问题
|
||||||
* 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]')
|
||||||
*/
|
*/
|
||||||
|
if (document.readyState === 'interactive' && WuhuConfig.get('SolveGoogleScriptPendingIssue')) {
|
||||||
|
window.stop();
|
||||||
|
document.open();
|
||||||
|
document.addEventListener('readystatechange', function readyStateChangeHandler() {
|
||||||
|
Log.info('document.readyState', document.readyState);
|
||||||
|
if (document.readyState === 'complete') {
|
||||||
|
document.removeEventListener('readystatechange', readyStateChangeHandler);
|
||||||
|
mainMethod();
|
||||||
|
throw new Error('页面已重载');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
FetchUtils.getInstance().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, '');
|
||||||
|
});
|
||||||
|
Log.info({ removed });
|
||||||
|
document.write(removed);
|
||||||
|
document.close();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// 存钱相关
|
// 存钱相关
|
||||||
depoHelper();
|
depoHelper();
|
||||||
|
|||||||
@ -59,13 +59,14 @@ export default class Log {
|
|||||||
if (typeof item === 'string') this.logs += item;
|
if (typeof item === 'string') this.logs += item;
|
||||||
else if (item !== null && item !== undefined) {
|
else if (item !== null && item !== undefined) {
|
||||||
let json = '{}';
|
let json = '{}';
|
||||||
let name = item.toString ? item.toString() : 'UNKNOWN_OBJECT';
|
let name = Object.getPrototypeOf(item).constructor.name;
|
||||||
try {
|
try {
|
||||||
json = JSON.stringify(item);
|
json = JSON.stringify(item);
|
||||||
name = Object.getPrototypeOf(item).constructor.name;
|
|
||||||
} catch {
|
} catch {
|
||||||
}
|
}
|
||||||
this.logs += ` [${ name }] [${ json }] `;
|
this.logs += ` [${ name }] [${ json }] `;
|
||||||
|
if (item.message) this.logs += '错误信息: ' + item.message;
|
||||||
|
if (item.stack) this.logs += '错误堆栈: ' + item.stack;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
this.logs += '\r\n';
|
this.logs += '\r\n';
|
||||||
|
|||||||
@ -19,6 +19,7 @@ import BuyBeerHelper from "./action/BuyBeerHelper";
|
|||||||
import XZMZ from "./action/XZMZ";
|
import XZMZ from "./action/XZMZ";
|
||||||
import ProfileHelper from "./action/ProfileHelper";
|
import ProfileHelper from "./action/ProfileHelper";
|
||||||
import SearchHelper from "./action/SearchHelper";
|
import SearchHelper from "./action/SearchHelper";
|
||||||
|
import TornStyleSwitch from "./utils/TornStyleSwitch";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO 去除jq
|
* TODO 去除jq
|
||||||
@ -29,7 +30,16 @@ export default class UrlPattern extends WuhuBase {
|
|||||||
public resolve(): void {
|
public resolve(): void {
|
||||||
let href = window.location.href;
|
let href = window.location.href;
|
||||||
// 捡垃圾助手
|
// 捡垃圾助手
|
||||||
if (href.includes('city.php') && WuhuConfig.get('cityFinder')) cityFinder();
|
if (href.includes('city.php') && WuhuConfig.get('cityFinder')) {
|
||||||
|
cityFinder();
|
||||||
|
let reloadSwitch = new TornStyleSwitch('解决一直转圈(加载中)的问题');
|
||||||
|
reloadSwitch.getInput().checked = WuhuConfig.get('SolveGoogleScriptPendingIssue');
|
||||||
|
new TornStyleBlock('芜湖助手').append(reloadSwitch.getBase()).insert2Dom();
|
||||||
|
reloadSwitch.getInput().addEventListener('change', () => {
|
||||||
|
if (reloadSwitch.getInput().checked) window.location.replace(window.location.href);
|
||||||
|
WuhuConfig.set('SolveGoogleScriptPendingIssue', reloadSwitch.getInput().checked, true);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// pt一键购买
|
// pt一键购买
|
||||||
if (href.includes('pmarket.php')) PTHelper.getInstance();
|
if (href.includes('pmarket.php')) PTHelper.getInstance();
|
||||||
|
|||||||
@ -115,6 +115,8 @@ export default class WuhuConfig extends WuhuBase {
|
|||||||
{ key: 'HideSidebarBtn', val: true },
|
{ key: 'HideSidebarBtn', val: true },
|
||||||
// 搜索页占位区
|
// 搜索页占位区
|
||||||
{ key: 'SearchPagePlaceholder', val: true },
|
{ key: 'SearchPagePlaceholder', val: true },
|
||||||
|
// 解决一直转圈(加载中)的问题
|
||||||
|
{ key: 'SolveGoogleScriptPendingIssue', val: false },
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 危险行为⚠️
|
* 危险行为⚠️
|
||||||
|
|||||||
@ -12,6 +12,9 @@ export default class WuHuTornHelper extends WuhuBase {
|
|||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public init() {
|
||||||
Log.info('WuHuTornHelper初始化');
|
Log.info('WuHuTornHelper初始化');
|
||||||
WuhuBase.glob = Global.getInstance();
|
WuhuBase.glob = Global.getInstance();
|
||||||
let glob = WuHuTornHelper.glob;
|
let glob = WuHuTornHelper.glob;
|
||||||
|
|||||||
@ -30,11 +30,12 @@ export default class ZhongIcon extends WuhuBase {
|
|||||||
// private settingItemList: MenuItemConfig[] = null;
|
// private settingItemList: MenuItemConfig[] = null;
|
||||||
|
|
||||||
public constructor() {
|
public constructor() {
|
||||||
Log.info('ZhongIcon初始化, 设置图标开始');
|
|
||||||
super();
|
super();
|
||||||
this
|
}
|
||||||
// .constructWuhuSettingList()
|
|
||||||
.constructMenuList()
|
public init() {
|
||||||
|
Log.info('ZhongIcon初始化, 设置图标开始');
|
||||||
|
this.constructMenuList()
|
||||||
.insert2Dom();
|
.insert2Dom();
|
||||||
Log.info('设置图标结束, ZhongIcon初始化结束');
|
Log.info('设置图标结束, ZhongIcon初始化结束');
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,13 +18,17 @@ export default class CompanyHelper extends WuhuBase {
|
|||||||
WuhuConfig.get('CHTrainsDetectSwitch') && this.trainsDetect().then();
|
WuhuConfig.get('CHTrainsDetectSwitch') && this.trainsDetect().then();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public detectNow(): void {
|
||||||
|
this.trainsDetect(true).then();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 火车检测
|
* 火车检测
|
||||||
* 每日判断一次,非公司老板跳过检测
|
* 每日判断一次,非公司老板跳过检测
|
||||||
* TODO 优化、URL判断
|
* TODO 优化、URL判断
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
private async trainsDetect(): Promise<null> {
|
private async trainsDetect(test: boolean = false): Promise<null> {
|
||||||
// 通过用户的icon判断公司老板
|
// 通过用户的icon判断公司老板
|
||||||
if ((await InfoUtils.getInstance().getSessionData()).statusIcons.icons.company.iconID !== 'icon73') {
|
if ((await InfoUtils.getInstance().getSessionData()).statusIcons.icons.company.iconID !== 'icon73') {
|
||||||
Log.info('火车检测跳过:非公司老板');
|
Log.info('火车检测跳过:非公司老板');
|
||||||
@ -33,19 +37,33 @@ export default class CompanyHelper extends WuhuBase {
|
|||||||
// 上次检测时间戳
|
// 上次检测时间戳
|
||||||
let lastDetect: number = WuhuConfig.get('CHTrainsDetect') || 0;
|
let lastDetect: number = WuhuConfig.get('CHTrainsDetect') || 0;
|
||||||
// 检测是否过了一天
|
// 检测是否过了一天
|
||||||
if (CommonUtils.getInstance().isNewDay(lastDetect, -6)) {
|
if (test || CommonUtils.getInstance().isNewDay(lastDetect, -6)) {
|
||||||
WuhuConfig.set('CHTrainsDetect', Date.now());
|
|
||||||
let travelStage = CommonUtils.getInstance().getTravelStage(),
|
let travelStage = CommonUtils.getInstance().getTravelStage(),
|
||||||
userStatus = (await InfoUtils.getInstance().getUserState()).status;
|
userStatus = (await InfoUtils.getInstance().getUserState()).status;
|
||||||
|
test && Log.info({ travelStage, userStatus });
|
||||||
if (travelStage === TRAVEL_STATE.IN_TORN && userStatus === 'ok')
|
if (travelStage === TRAVEL_STATE.IN_TORN && userStatus === 'ok')
|
||||||
FetchUtils.getInstance().fetchText('/companies.php')
|
FetchUtils.getInstance().fetchText('/companies.php')
|
||||||
.then(res => {
|
.then(res => {
|
||||||
let tmp: HTMLElement = document.createElement('div');
|
let tmp: HTMLElement = document.createElement('div');
|
||||||
// TODO 未去除body标签
|
let bodyTagStart = CommonUtils.getInstance().matchOne(res, /<body.+>/);
|
||||||
tmp.innerHTML = res.split('</head>')[1].replace('</html>', '').trim();
|
if (!bodyTagStart) {
|
||||||
let trains: number = parseInt(tmp.querySelector('span.trains').innerText);
|
Log.warn('火车检测: 无法获取数据');
|
||||||
|
throw new Error('火车检测: 无法获取数据');
|
||||||
|
}
|
||||||
|
tmp.innerHTML = res.split(bodyTagStart)[1].split('</body>')[0].trim()
|
||||||
|
.replaceAll('rel="stylesheet"', '')
|
||||||
|
.replaceAll('.css', '?404')
|
||||||
|
.replaceAll('type="text/javascript"', 'type="application/json"');
|
||||||
|
let trainsNode = tmp.querySelector('span.trains');
|
||||||
|
if (!trainsNode) {
|
||||||
|
Log.error('火车检测出错: 无法获取火车数');
|
||||||
|
throw new Error('火车检测出错: 无法获取火车数');
|
||||||
|
}
|
||||||
|
let trains: number = parseInt(trainsNode.innerText);
|
||||||
let stars: number = tmp.querySelectorAll('.company-rating .active').length / 2 || 1;
|
let stars: number = tmp.querySelectorAll('.company-rating .active').length / 2 || 1;
|
||||||
Log.info('火车/星级: ' + trains + '/' + stars);
|
WuhuConfig.set('CHTrainsDetect', Date.now());
|
||||||
|
Log.info('火车检测: 火车/星级: ' + trains + '/' + stars);
|
||||||
|
Log.info({ tmp });
|
||||||
if (trains + stars > 20) {
|
if (trains + stars > 20) {
|
||||||
new Alert(`公司助手<br/><br/>火车检测:火车明日将溢出!${ trains }/20火车`, {
|
new Alert(`公司助手<br/><br/>火车检测:火车明日将溢出!${ trains }/20火车`, {
|
||||||
timeout: 15,
|
timeout: 15,
|
||||||
@ -53,10 +71,11 @@ export default class CompanyHelper extends WuhuBase {
|
|||||||
sysNotify: true
|
sysNotify: true
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
tmp.remove();
|
||||||
|
tmp = null;
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
Log.error('火车检测出错', error);
|
Log.error('火车检测出错', error);
|
||||||
WuhuConfig.set('CHTrainsDetect', 0);
|
|
||||||
});
|
});
|
||||||
else Log.warn('[火车检测] 用户状态错误,跳过火车检测', { travelStage, userStatus });
|
else Log.warn('[火车检测] 用户状态错误,跳过火车检测', { travelStage, userStatus });
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
293
src/class/action/Translate.ts
Normal file
293
src/class/action/Translate.ts
Normal file
@ -0,0 +1,293 @@
|
|||||||
|
import WuhuBase from "../WuhuBase";
|
||||||
|
import { chatDict, eventsDict, headerDict, propertyDict, sidebarDict } from "../../dictionary/translation";
|
||||||
|
import Log from "../Log";
|
||||||
|
import Timer from "../utils/Timer";
|
||||||
|
|
||||||
|
export default class Translate extends WuhuBase {
|
||||||
|
className = 'Translate';
|
||||||
|
|
||||||
|
public translateVer: string = '1.0';
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
Log.info('翻译开始');
|
||||||
|
let start = new Timer();
|
||||||
|
// 时分秒转换
|
||||||
|
String.prototype.replaceHMS = function replaceHMS() {
|
||||||
|
return this.replace('and', '')
|
||||||
|
.replace('days', '天')
|
||||||
|
.replace('days', '天')
|
||||||
|
.replace('hours', '小时')
|
||||||
|
.replace('hour', '小时')
|
||||||
|
.replace('minutes', '分钟')
|
||||||
|
.replace('minute', '分钟')
|
||||||
|
.replace('seconds', '秒钟')
|
||||||
|
.replace('second', '秒钟');
|
||||||
|
};
|
||||||
|
|
||||||
|
// 数词转换 a/an/some
|
||||||
|
String.prototype.numWordTrans = function numWordTrans() {
|
||||||
|
return this.replace(/\ban\b/, '1 个')
|
||||||
|
.replace(/\ba\b/, '1 个')
|
||||||
|
.replace(/\bsome\b/, '1 个')
|
||||||
|
.replace(/([0-9])x\b/, '$1 个');
|
||||||
|
};
|
||||||
|
|
||||||
|
window.setTimeout(() => {
|
||||||
|
this.headerTranslate();
|
||||||
|
this.sidebarTranslate();
|
||||||
|
this.chatTranslate();
|
||||||
|
this.playerSearchBoxTrans();
|
||||||
|
this.urlMatchPageTranslate(window.location.href);
|
||||||
|
Log.info('翻译结束, 耗时' + start.getTimeMs());
|
||||||
|
}, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public urlMatchPageTranslate(href: string): void {
|
||||||
|
}
|
||||||
|
|
||||||
|
private sidebarTranslate(): 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
private headerTranslate(): void {
|
||||||
|
let headerRoot = document.querySelector('div#header-root');
|
||||||
|
if (headerRoot) {
|
||||||
|
// const headerOB =
|
||||||
|
new MutationObserver((_, observer) => {
|
||||||
|
observer.disconnect();
|
||||||
|
headerTrans();
|
||||||
|
observer.observe(headerRoot, { childList: true, subtree: true, attributes: true });
|
||||||
|
}).observe(headerRoot, { childList: true, subtree: true, attributes: true });
|
||||||
|
|
||||||
|
const headerTrans = () => {
|
||||||
|
// 搜索内容下拉框中的文字 已选中
|
||||||
|
let toggle = document.querySelector('div.find button.toggler.down');
|
||||||
|
if (toggle) {
|
||||||
|
let text = toggle.innerText.trim();
|
||||||
|
if (headerDict[text]) toggle.innerText = headerDict[text];
|
||||||
|
}
|
||||||
|
|
||||||
|
// pc端 搜索下拉框点击后的搜索类型文字 TODO 去除jq each
|
||||||
|
$('div.find li.item').each((i, e) => {
|
||||||
|
let $e = $(e);
|
||||||
|
if (headerDict[$e.text()])
|
||||||
|
$e.text(headerDict[$e.text()]);
|
||||||
|
});
|
||||||
|
|
||||||
|
// 手机端 搜索下拉框点击后的搜索类型文字 TODO 去除jq each
|
||||||
|
$('li[class^="search-type-"] label').each((i, e) => {
|
||||||
|
if (headerDict[$(e).text()])
|
||||||
|
$(e).text(headerDict[$(e).text()]);
|
||||||
|
});
|
||||||
|
|
||||||
|
// 搜索框placeholder
|
||||||
|
let searchInput = document.querySelector('input[class^="searchInput"]');
|
||||||
|
if (searchInput) {
|
||||||
|
let searchInputPlaceholder = searchInput.getAttribute('placeholder').trim();
|
||||||
|
if (headerDict[searchInputPlaceholder])
|
||||||
|
searchInput.setAttribute('placeholder', headerDict[searchInputPlaceholder]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 高级搜索框 search by
|
||||||
|
if (headerDict[document.querySelector('div#header-root legend.title').innerText]) {
|
||||||
|
let $title = $('div#header-root legend.title');
|
||||||
|
$title.text(headerDict[$title.text()]);
|
||||||
|
}
|
||||||
|
// 高级搜索框的条件 左 键
|
||||||
|
$('ul.advancedSearchFormBody label.label').each((i, e) => {
|
||||||
|
let $e = $(e);
|
||||||
|
if (headerDict[$e.text()])
|
||||||
|
$e.text(headerDict[$e.text()]);
|
||||||
|
});
|
||||||
|
// 高级搜索框的已选中
|
||||||
|
$('ul.advancedSearchFormBody div.select-wrapper button.toggler.down').each((i, e) => {
|
||||||
|
let $e = $(e);
|
||||||
|
if (headerDict[$e.text().trim()])
|
||||||
|
$e.text(headerDict[$e.text().trim()]);
|
||||||
|
else if (propertyDict[$e.text().trim()])
|
||||||
|
$e.text(propertyDict[$e.text().trim()]);
|
||||||
|
});
|
||||||
|
// 高级搜索的下拉选项
|
||||||
|
$('ul.advancedSearchFormBody li.item').each((i, e) => {
|
||||||
|
let $e = $(e);
|
||||||
|
if (headerDict[$e.text()])
|
||||||
|
$e.text(headerDict[$e.text()]);
|
||||||
|
else if (propertyDict[$e.text()])
|
||||||
|
$e.text(propertyDict[$e.text()]);
|
||||||
|
});
|
||||||
|
// 高级搜索的"Not"
|
||||||
|
$('ul.advancedSearchFormBody label.search-condition-not').each((i, e) => {
|
||||||
|
let $e = $(e);
|
||||||
|
if (headerDict[$e.text()])
|
||||||
|
$e.text(headerDict[$e.text()]);
|
||||||
|
});
|
||||||
|
// 高级搜索的"to"
|
||||||
|
$('ul.advancedSearchFormBody label[for*="To"]').each((i, e) => {
|
||||||
|
let $e = $(e);
|
||||||
|
if (headerDict[$e.text()])
|
||||||
|
$e.text(headerDict[$e.text()]);
|
||||||
|
});
|
||||||
|
// 高级搜索的reset search按钮
|
||||||
|
$('form.form-search-extend div.bottom button').each((i, e) => {
|
||||||
|
let $e = $(e);
|
||||||
|
if (headerDict[$e.text()])
|
||||||
|
$e.text(headerDict[$e.text()]);
|
||||||
|
});
|
||||||
|
// log按钮“view log”
|
||||||
|
const $view_log = $('div.recentHistory a[class^="link"] span[class^="text"]')
|
||||||
|
if (headerDict[$view_log.text().trim()])
|
||||||
|
$view_log
|
||||||
|
.text(headerDict[$view_log.text().trim()]);
|
||||||
|
// 点击头像打开的菜单
|
||||||
|
$('ul.settings-menu span').each((i, e) => {
|
||||||
|
let $e = $(e);
|
||||||
|
if (headerDict[$e.text()] && e.childNodes.length === 1)
|
||||||
|
$e.text(headerDict[$e.text()]);
|
||||||
|
else if (e.childNodes.length === 3)
|
||||||
|
if (headerDict[e.firstChild.nodeValue])
|
||||||
|
e.firstChild.nodeValue = headerDict[e.firstChild.nodeValue];
|
||||||
|
});
|
||||||
|
};
|
||||||
|
headerTrans();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private chatTranslate(): void {
|
||||||
|
if (document.querySelector('div#chatRoot')) {
|
||||||
|
const chatOB = new MutationObserver(_ => {
|
||||||
|
chatOB.disconnect();
|
||||||
|
chatTrans();
|
||||||
|
chatOB.observe($('div#chatRoot').get(0), { childList: true, subtree: true, attributes: true });
|
||||||
|
});
|
||||||
|
const chatTrans = function chatTrans() {
|
||||||
|
// 聊天框的标题
|
||||||
|
$('div#chatRoot div[class^="chat-box-title"] span[class^="name"]').each((i, e) => {
|
||||||
|
let $e = $(e);
|
||||||
|
if (chatDict[$e.text().trim()])
|
||||||
|
$e.text(chatDict[$e.text().trim()]);
|
||||||
|
});
|
||||||
|
// 聊天设置的左边label
|
||||||
|
$('div[class^="chat-settings-opts"] div[class*="label"]').each((i, e) => {
|
||||||
|
let $e = $(e);
|
||||||
|
if ($e.next().children('div.rc-slider').length > 0) {
|
||||||
|
// 高度和宽度有响应式的%
|
||||||
|
if (chatDict[$e.text().split(' ')[0]]) {
|
||||||
|
$e.text($e.text().replace($e.text().split(' ')[0], chatDict[$e.text().split(' ')[0]]));
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (chatDict[$e.text().trim()])
|
||||||
|
$e.text(chatDict[$e.text().trim()]);
|
||||||
|
});
|
||||||
|
// 选项下拉栏
|
||||||
|
$('div[class^="dropdown-root"]').find('*').contents().each((i, e) => {
|
||||||
|
if (e.nodeType !== 3) return;
|
||||||
|
if (chatDict[e.nodeValue])
|
||||||
|
e.nodeValue = chatDict[e.nodeValue];
|
||||||
|
});
|
||||||
|
// 设置的两个选项
|
||||||
|
$('label[class^="privacy-label"]').each((i, e) => {
|
||||||
|
let $e = $(e);
|
||||||
|
if (chatDict[$e.text().trim()])
|
||||||
|
$e.text(chatDict[$e.text().trim()]);
|
||||||
|
});
|
||||||
|
// people中的5个分类 faction friend...
|
||||||
|
$('ul[class^="type-list"] li a').each((i, e) => {
|
||||||
|
let $e = $(e);
|
||||||
|
if (chatDict[$e.text().trim()])
|
||||||
|
$e.text(chatDict[$e.text().trim()]);
|
||||||
|
});
|
||||||
|
// people中的列表添加框placeholder
|
||||||
|
$('div.ac-wrapper input.ac-search').each((i, e) => {
|
||||||
|
let $e = $(e);
|
||||||
|
if (chatDict[$e.attr('placeholder')])
|
||||||
|
$e.attr('placeholder', chatDict[$e.attr('placeholder')]);
|
||||||
|
});
|
||||||
|
//
|
||||||
|
let $chatRootOverview = document.querySelector('div#chatRoot div[class^="overview"] > div > div:nth-child(2)');
|
||||||
|
if (eventsDict[$chatRootOverview.innerText.trim()]) {
|
||||||
|
$chatRootOverview.innerText = eventsDict[$chatRootOverview.innerText.trim()];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
chatTrans();
|
||||||
|
chatOB.observe(document.querySelector('div#chatRoot'), {
|
||||||
|
childList: true,
|
||||||
|
subtree: true,
|
||||||
|
attributes: true
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 搜索玩家的4个分类按钮
|
||||||
|
private playerSearchBoxTrans(): void {
|
||||||
|
const opt = {
|
||||||
|
childList: true,
|
||||||
|
subtree: true,
|
||||||
|
};
|
||||||
|
new MutationObserver((mutation, observer) => {
|
||||||
|
let peopleCat = document.querySelectorAll('ul.ac-options li a');
|
||||||
|
observer.disconnect();
|
||||||
|
mutation.forEach((e) => {
|
||||||
|
if ((<HTMLElement>e.target).className === 'ac-wrapper') {
|
||||||
|
peopleCat.forEach((e) => {
|
||||||
|
if (chatDict[e.innerText.trim()])
|
||||||
|
e.innerText = chatDict[e.innerText.trim()];
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})
|
||||||
|
observer.observe(document.body, opt);
|
||||||
|
}).observe(document.body, opt);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -474,6 +474,14 @@ export default class SettingsHandler extends WuhuBase {
|
|||||||
domText: ' 搜索页空白占位区',
|
domText: ' 搜索页空白占位区',
|
||||||
dictName: 'SearchPagePlaceholder',
|
dictName: 'SearchPagePlaceholder',
|
||||||
});
|
});
|
||||||
|
// 解决一直转圈(加载中)的问题
|
||||||
|
list.push({
|
||||||
|
domType: 'checkbox',
|
||||||
|
domId: null,
|
||||||
|
domText: ' 解决一直转圈(加载中)的问题',
|
||||||
|
dictName: 'SolveGoogleScriptPendingIssue',
|
||||||
|
tip: 'Torn引入Google登陆后可能会出现这种问题<br/>启用功能影响:<br/>页面加载速度变慢,与其他插件冲突,如遇到问题请关闭<br/>并使用其他更科学的方法解决'
|
||||||
|
});
|
||||||
// 清除多余的脚本
|
// 清除多余的脚本
|
||||||
// list.push({
|
// list.push({
|
||||||
// domType: 'checkbox',
|
// domType: 'checkbox',
|
||||||
|
|||||||
@ -11,8 +11,7 @@ export default class Starter {
|
|||||||
try {
|
try {
|
||||||
T.main();
|
T.main();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
Log.error('[Starter]加载出错信息: ' + e.message);
|
Log.error('[Starter]加载出错信息: ' + e.stack || e.message);
|
||||||
Log.info('错误堆栈: ', e.stack);
|
|
||||||
}
|
}
|
||||||
let runTime: number = (performance.now() - started) | 0;
|
let runTime: number = (performance.now() - started) | 0;
|
||||||
Log.info(`芜湖脚本完成加载, 耗时${ runTime }ms`);
|
Log.info(`芜湖脚本完成加载, 耗时${ runTime }ms`);
|
||||||
|
|||||||
@ -31,7 +31,8 @@ export default class Alert extends WuhuBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 通知的容器
|
// 通知的容器
|
||||||
if (Alert.container === null) Alert.initContainer();
|
Log.info('通知的容器', Alert.container);
|
||||||
|
if (!Alert.container || !document.contains(Alert.container)) Alert.initContainer();
|
||||||
|
|
||||||
this.callback = callback || (() => null);
|
this.callback = callback || (() => null);
|
||||||
Alert.create(this, msg, timeout || 3);
|
Alert.create(this, msg, timeout || 3);
|
||||||
|
|||||||
@ -353,4 +353,12 @@ export default class CommonUtils extends WuhuBase {
|
|||||||
return TRAVEL_STATE.FLYING;
|
return TRAVEL_STATE.FLYING;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public matchOne(src: string, reg: string | RegExp): string {
|
||||||
|
let regExp = typeof reg === 'string' ? new RegExp(reg) : reg,
|
||||||
|
ret = null;
|
||||||
|
let match = src.match(regExp);
|
||||||
|
if (match.length > 0) ret = match[0];
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -39,6 +39,10 @@ import contentTitleLinksTransReact from "./contentTitleLinksTransReact";
|
|||||||
import titleTransReact from "./titleTransReact";
|
import titleTransReact from "./titleTransReact";
|
||||||
import Log from "../../class/Log";
|
import Log from "../../class/Log";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
* @param href
|
||||||
|
*/
|
||||||
export default function translateMain(href: string): void {
|
export default function translateMain(href: string): void {
|
||||||
// 时分秒转换
|
// 时分秒转换
|
||||||
String.prototype.replaceHMS = function replaceHMS() {
|
String.prototype.replaceHMS = function replaceHMS() {
|
||||||
|
|||||||
@ -2,6 +2,7 @@ import WuhuBase from "../class/WuhuBase";
|
|||||||
import Log from "../class/Log";
|
import Log from "../class/Log";
|
||||||
import CommonUtils from "../class/utils/CommonUtils";
|
import CommonUtils from "../class/utils/CommonUtils";
|
||||||
import Popup from "../class/utils/Popup";
|
import Popup from "../class/utils/Popup";
|
||||||
|
import CompanyHelper from "../class/action/CompanyHelper";
|
||||||
|
|
||||||
export default class Test extends WuhuBase {
|
export default class Test extends WuhuBase {
|
||||||
className = 'Test';
|
className = 'Test';
|
||||||
@ -50,6 +51,6 @@ export default class Test extends WuhuBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async case3() {
|
private async case3() {
|
||||||
// CustomCssHandler.getInstance().handle();
|
CompanyHelper.getInstance().detectNow();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user