更新
This commit is contained in:
parent
25047e9b67
commit
c2faf00855
@ -9,114 +9,263 @@
|
|||||||
// ==/UserScript==
|
// ==/UserScript==
|
||||||
|
|
||||||
|
|
||||||
!(function() {
|
!(function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
const $ = window.jQuery;
|
const $ = window.jQuery;
|
||||||
|
let invervalID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 飞行
|
* 飞行
|
||||||
*/
|
*/
|
||||||
if ($('.travelling h4').length!==0){
|
if (window.location.href.indexOf('index.php') >= 0 &&
|
||||||
|
$('.travelling h4').length !== 0) {
|
||||||
|
const travelingDict = { // todo jsonify
|
||||||
|
'Recruit Citizens': '招募玩家',
|
||||||
|
'Torn to London.': '正在飞往英国伦敦(London)。',
|
||||||
|
'London to Torn.': '正从英国伦敦(London)回城。', // todo 所有目的地
|
||||||
|
'\nRemaining Flight Time -\n': ' 剩余时间 - ',
|
||||||
|
};
|
||||||
|
$('#skip-to-content')[0].firstChild.nodeValue += '飞行中';
|
||||||
|
// eg. Remaining Flight Time -
|
||||||
|
$('span.remaining-time')[0].firstChild.nodeValue = travelingDict[$('span.remaining-time')[0].firstChild.nodeValue];
|
||||||
|
$("#recruit-citizens")[0].firstChild.nodeValue = travelingDict[$("#recruit-citizens")[0].firstChild.nodeValue];
|
||||||
|
// eg. Torn to London.
|
||||||
|
new MutationObserver(mutations => {
|
||||||
|
$('span.description')[0].firstChild.nodeValue = travelingDict[$('span.description')[0].firstChild.nodeValue];
|
||||||
|
}).observe($('span.description')[0], {attributes: true, childList: true, subtree: true});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 边栏
|
* 边栏
|
||||||
*/
|
*/
|
||||||
const sidebarDict={ // todo 从json加载
|
const sidebarDict = { // todo 从json加载
|
||||||
'Money':'现金',
|
'Money': '现金',
|
||||||
'Level':'等级',
|
'Level': '等级',
|
||||||
'Points':'PT',
|
'Points': 'PT',
|
||||||
'Merits':'技能点',
|
'Merits': '技能点',
|
||||||
'Energy':'能量E',
|
'Energy': '能量E',
|
||||||
'Nerve':'犯罪N',
|
'Nerve': '犯罪N',
|
||||||
'Happy':'快乐',
|
'Happy': '快乐',
|
||||||
'Life':'血量',
|
'Life': '血量',
|
||||||
'Chain':'连击链Chain',
|
'Chain': '连击链Chain',
|
||||||
'Home':'主页',
|
'Home': '主页',
|
||||||
'Items':'物品',
|
'Items': '物品',
|
||||||
'City':'城市',
|
'City': '城市',
|
||||||
'Job':'工作',
|
'Job': '工作',
|
||||||
'Gym':'健身房',
|
'Gym': '健身房',
|
||||||
'Properties':'房产',
|
'Properties': '房产',
|
||||||
'Education':'教育',
|
'Education': '教育',
|
||||||
'Crimes':'犯罪',
|
'Crimes': '犯罪',
|
||||||
'Missions':'任务',
|
'Missions': '任务',
|
||||||
'Newspaper':'报纸',
|
'Newspaper': '报纸',
|
||||||
'Jail':'监狱',
|
'Jail': '监狱',
|
||||||
'Hospital':'医院',
|
'Hospital': '医院',
|
||||||
'Casino':'赌场',
|
'Casino': '赌场',
|
||||||
'Forums':'论坛',
|
'Forums': '论坛',
|
||||||
'Hall of Fame':'名人堂',
|
'Hall of Fame': '名人堂',
|
||||||
'My Faction':'帮派',
|
'My Faction': '帮派',
|
||||||
'Recruit Citizens':'招募玩家',
|
'Recruit Citizens': '招募玩家',
|
||||||
'Competitions':'活动日历',
|
'Competitions': '活动日历',
|
||||||
'Community Events':'社区事件',
|
'Community Events': '社区事件',
|
||||||
'Friends':'好友',
|
'Friends': '好友',
|
||||||
'Enemies':'敌人',
|
'Enemies': '敌人',
|
||||||
};
|
};
|
||||||
const transSidebar=function (){
|
const sidebarInterval = setInterval(() => {
|
||||||
|
if ($('div[class^="sidebar"]').length === 0)
|
||||||
|
return;
|
||||||
// 边栏块标题
|
// 边栏块标题
|
||||||
$('h2[class^="header"]')[0].firstChild.nodeValue='信息';
|
$('h2[class^="header"]')[0].firstChild.nodeValue = '信息';
|
||||||
$('h2[class^="header"]')[1].firstChild.nodeValue='区域';
|
$('h2[class^="header"]')[1].firstChild.nodeValue = '区域'; // todo 当前文字替换会触发torn js bug
|
||||||
$('h2[class^="header"]')[2].firstChild.nodeValue='列表';
|
$('h2[class^="header"]')[2].firstChild.nodeValue = '列表';
|
||||||
// 边栏人物名字
|
// 边栏人物名字
|
||||||
$('span[class^="menu-name"]')[0].firstChild.nodeValue='名字:';
|
$('span[class^="menu-name"]')[0].firstChild.nodeValue = '名字:';
|
||||||
// 钱 等级 pt 技能点
|
// 钱 等级 pt 技能点
|
||||||
$('p[class^="point-block"]').each((i,e)=>{
|
$('p[class^="point-block"]').each((i, e) => {
|
||||||
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) => {
|
||||||
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) => {
|
||||||
e.firstChild.nodeValue=sidebarDict[e.firstChild.nodeValue];
|
e.firstChild.nodeValue = sidebarDict[e.firstChild.nodeValue];
|
||||||
});
|
});
|
||||||
|
// [use]按钮
|
||||||
|
$('#pointsMerits')[0].firstChild.nodeValue = '[使用]';
|
||||||
|
$('#pointsPoints')[0].firstChild.nodeValue = '[使用]';
|
||||||
|
|
||||||
// 监控配置
|
clearInterval(sidebarInterval);
|
||||||
let tooltip=$('div[class^="tooltip"]')[0];
|
}, 1000);
|
||||||
const config = { attributes: true, childList: true, subtree: true };
|
|
||||||
const observer = new MutationObserver(tooltip,config);
|
// 浮窗
|
||||||
|
const tootipDict = {
|
||||||
|
'Full ': '回满',
|
||||||
|
'energy': '能量E',
|
||||||
|
'happy': '快乐',
|
||||||
|
' in ': '还需',
|
||||||
|
'You have full ': '你已有满',
|
||||||
|
'life': '血量',
|
||||||
|
'nerve': '犯罪N',
|
||||||
|
'You are currently traveling': '你正在飞行中',
|
||||||
|
'You don\'t own a Laptop!': '你没有笔记本电脑!',
|
||||||
|
'You are not in Torn': '你不在城里',
|
||||||
|
'Rank': '阶级',
|
||||||
};
|
};
|
||||||
|
let tooltip = $('div.ToolTipPortal')[0];
|
||||||
|
let intervalID = setInterval(() => {
|
||||||
|
tooltip = $('div.ToolTipPortal')[0];
|
||||||
|
if (tooltip) {
|
||||||
|
clearInterval(intervalID);
|
||||||
|
new MutationObserver(mutations => {
|
||||||
|
let barDescr = $('div[class^="tooltip"]').children('p[class^="bar-descr"]');
|
||||||
|
if (barDescr.length !== 0) {
|
||||||
|
barDescr[0].childNodes.forEach(i => {
|
||||||
|
if (tootipDict[i.nodeValue]) i.nodeValue = tootipDict[i.nodeValue];
|
||||||
|
})
|
||||||
|
}
|
||||||
|
let miniprof_tooltip = $("#body > div.ToolTipPortal > div > div:nth-child(2)");
|
||||||
|
if (miniprof_tooltip.length !== 0) {
|
||||||
|
if (tootipDict[miniprof_tooltip[0].firstChild.nodeValue]) {
|
||||||
|
miniprof_tooltip[0].firstChild.nodeValue = tootipDict[miniprof_tooltip[0].firstChild.nodeValue];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
//todo 通配符匹配
|
||||||
|
}
|
||||||
|
}).observe(tooltip, {attributes: true, childList: true, subtree: true});
|
||||||
|
}
|
||||||
|
}, 500);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 主页
|
* 主页
|
||||||
*/
|
*/
|
||||||
transSidebar();
|
if (window.location.href.indexOf('index.php') >= 0 &&
|
||||||
|
$('h4#skip-to-content').text().indexOf('Home') >= 0) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通知
|
||||||
|
*/
|
||||||
|
if (window.location.href.indexOf('events.php') >= 0) {
|
||||||
|
let events = $('span.mail-link');
|
||||||
|
|
||||||
|
//初始化中内容未加载
|
||||||
|
let eventInterval = setInterval(() => {
|
||||||
|
console.log('循环判断内容是否已加载')
|
||||||
|
if (events.length === 0) {
|
||||||
|
events = $('span.mail-link');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
clearInterval(eventInterval);
|
||||||
|
eventsTrans();
|
||||||
|
}, 1000);
|
||||||
|
|
||||||
|
function eventsTrans() {
|
||||||
|
events.each((i, e) => {
|
||||||
|
if ($(e).text().indexOf('finished') >= 0) { // 赛车
|
||||||
|
const isBestLap = $(e).text().indexOf('best lap') >= 0;
|
||||||
|
|
||||||
|
const isGainRacingPoint = $(e).text().indexOf('racing point') >= 0;
|
||||||
|
|
||||||
|
const pos = e.childNodes[1].firstChild.nodeValue
|
||||||
|
.split('')[0].match(/[0-9]+/)[0];
|
||||||
|
|
||||||
|
const splitList = e.childNodes[2].nodeValue.split(' ');
|
||||||
|
|
||||||
|
let map = splitList[3];
|
||||||
|
map = map === 'Two' ? 'Two Islands' : map;
|
||||||
|
map = map === 'Stone' ? 'Stone Park' : map;
|
||||||
|
e.firstChild.nodeValue = '你在 ' + map + ' 赛车比赛中获得了第 '//+pos+'名。';
|
||||||
|
e.childNodes[1].nodeValue = pos;
|
||||||
|
e.childNodes[2].nodeValue = '名。';
|
||||||
|
if (isGainRacingPoint) {
|
||||||
|
const racingPoint = splitList[-9];
|
||||||
|
e.childNodes[2].nodeValue += '你获得了' + racingPoint + '赛车点数。';
|
||||||
|
}
|
||||||
|
if (isBestLap) {
|
||||||
|
const bestLap = splitList[-2];
|
||||||
|
e.childNodes[2].nodeValue += '你的最好成绩是' + bestLap + '。';
|
||||||
|
}
|
||||||
|
e.childNodes[2].nodeValue += ' [';
|
||||||
|
e.childNodes[3].firstChild.nodeValue = '查看';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ($(e).text().indexOf('Loan Shark') >= 0) { // 还贷
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ($(e).text().indexOf('sent') >= 0) { // 收到钱物
|
||||||
|
if ($(e).text().indexOf('message') >= 0) { // 附带信息
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($(e).text().indexOf('bazaar') >= 0) { // bazaar
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ($(e).text().indexOf('trade') >= 0) { // 交易
|
||||||
|
if ($(e).text().indexOf('You must now accept') >= 0) { // 接受交易
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ($(e).text().indexOf('expired') >= 0) { // 交易过期
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ($(e).text().indexOf('initiated') >= 0) { // 交易发起
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ($(e).text().indexOf('mugged') >= 0) { // 被mug
|
||||||
|
if ($(e).text().indexOf('Someone') >= 0) { // 被匿名mug
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($(e).text().indexOf('attacked') >= 0) { // 被打
|
||||||
|
if ($(e).text().indexOf('Someone') >= 0) { // 被匿名
|
||||||
|
if ($(e).text().indexOf('hospitalized') >= 0) { // 被打住院
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ($(e).text().indexOf('but lost') >= 0) { // 收lost
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ($(e).text().indexOf('hospitalized') >= 0) { // 被实名打住院
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($(e).text().indexOf('lottery') >= 0) { // 每日彩票
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ($(e).text().indexOf('organized crime') >= 0) { // oc开启
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ($(e).text().indexOf('You and your team') >= 0) { // oc结束
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ($(e).text().indexOf('successfully busted') >= 0) { // 劫狱成功
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ($(e).text().indexOf('trying to bust') >= 0 ||
|
||||||
|
$(e).text().indexOf('failed to bust') >= 0) { // 劫狱失败
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ($(e).text().indexOf('Loan Shark') >= 0) { // 还贷
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ($(e).text().indexOf('doorstep') >= 0) { // 蓝星奖励
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// $('body').find("*").each(function(i,elem){
|
|
||||||
// if($(elem).text()===$(elem).html()){console.log(i);
|
|
||||||
// console.log($(elem).text());}})
|
|
||||||
|
|
||||||
//$('ul.user-info-list-wrap span.reason').each(function(i,e){
|
|
||||||
// console.log($(e).text(123))})
|
|
||||||
|
|
||||||
// $('ul.user-info-list-wrap span.reason').each(function(i,e){
|
|
||||||
// console.log($(e).html($(e).html().replace('Hospitalized by', '被此人送往医院:')))})
|
|
||||||
// $("#text_test").contents().filter(function(){
|
|
||||||
// return this.nodeType === 3;
|
|
||||||
// }).text(123);
|
|
||||||
|
|
||||||
|
|
||||||
// 设计一个读取元素包含文本的通用方法
|
|
||||||
// http://c.biancheng.net/view/5908.html
|
|
||||||
//获取指定元素包含的文本
|
|
||||||
//参数:e 表示指定元素
|
|
||||||
//返回包含的所有文本,包括子元素中包含的文本
|
|
||||||
// function text(e) {
|
|
||||||
// let s = "";
|
|
||||||
// e = e.childNodes || e; //判断元素是否包含子节点
|
|
||||||
// for (let i = 0; i < e.length; i ++) { //遍历所有子节点
|
|
||||||
// //通过递归遍历所有元素的子节点
|
|
||||||
// s += e[i].nodeType !== 1 ? e[i].nodeValue : text(e[i].childNodes);
|
|
||||||
// }
|
|
||||||
// return s;
|
|
||||||
// }
|
|
||||||
Loading…
x
Reference in New Issue
Block a user