帮派页面优化

This commit is contained in:
刘昱彤 2021-11-13 18:13:55 +08:00
parent 38cbe786f4
commit 7247ec213c

View File

@ -34,6 +34,7 @@
'Received Events': '收到的通知',
'Saved Events': '保存的通知',
'Awards': '勋章',
'Faction': '帮派',
};
const titleLinksDict = {
'Personal stats': '个人统计信息',
@ -56,7 +57,9 @@
'Hospital': '医院',
'Everyone': '所有人',
'Nobody': '仅自己',
'Friends & faction': '好友 & 帮派成员'
'Friends & faction': '好友 & 帮派成员',
'Forum': '论坛',
'Leave Faction': '离开帮派',
};
const sidebarDict = { // todo 从json加载
'Money': '现金',
@ -1574,7 +1577,7 @@
if (window.location.href.indexOf('level2.php') >= 0) {
}
/* 医院页面 */
/** 医院页面 **/
if (window.location.href.indexOf("hospitalview.php") >= 0) {
const hospitalOB = new MutationObserver(hosOBInit);
@ -1635,6 +1638,91 @@
return;
}
/** 帮派页面 **/
if (window.location.href.indexOf("actions.php") >= 0) {
const factionOB = new MutationObserver(factionOBInit);
function factionOBInit() {
factionOB.disconnect();
factionTrans();
factionOB.observe($('div.content-wrapper')[0], {childList: true, subtree: true});
}
const factionDict = {
"INFO": "信息",
"TERRITORY": "领地",
"RANK": "名次",
"CRIMES": "组织犯罪",
"UPGRADES": "升级",
"ARMORY": "军械库",
"CONTROLS": "控制面板",
"FACTION": "帮派",
"YOUR FACTION IS NOT IN A WAR": "你的帮派没有处于战争状态",
"TIER": "级别",
"RESPECT": "声望",
"No active chain": "暂无攻击链",
"Main News": "主要消息",
"Attacking": "攻击",
"Funds": "资金流动",
"Armory": "军械库",
"Crimes": "组织犯罪",
"Membership": "成员资格",
"has claimed sovereignty of": "",
"has abandoned": "弃用了",
"Achieved a chain of": "达成了连击链值",
"and": "和",
"respect [": "点声望",
"deposited ${$1}": "存放了${$1}",
"Leadership was transferred to": "帮派领导权被移交给了 "
}
function factionTrans() {
titleTrans();
contentTitleLinksTrans();
//帮派大标题
$('span[class^="tab-name"]').each((i, e) => {
if (factionDict[$(e).text().trim()]) {
$(e).text(factionDict[$(e).text().trim()]);
}
})
//帮派战争状态
$('div[class^="f-msg"]').contents().each((i, e) => {
let word2Trans = $(e).text().trim().split(":")[0];
if (word2Trans && factionDict[word2Trans]) {
$(e).text($(e).text().replace(word2Trans, factionDict[word2Trans]));
}
})
//攻击链盒
$('div[class^="chain-box"]').contents().each((i, e) => {
if (factionDict[$(e).text().trim()]) {
$(e).text(factionDict[$(e).text().trim()]);
}
})
//帮派消息类别
$('div[class^="newsHeader"]').contents().each((i, e) => {
if (factionDict[$(e).text().trim()]) {
$(e).text(factionDict[$(e).text().trim()]);
}
})
//帮派主要消息日志
$('ul[class^="news-list"] span[class^="info"]').contents().each((i, e) => {
if (factionDict[$(e).text().trim()]) {
e.nodeValue = e.nodeValue.replace($(e).text().trim(), factionDict[$(e).text().trim()]);
}
})
}
factionTrans();
factionOB.observe($('div.content-wrapper')[0], {childList: true, subtree: true});
return;
}
/**
* 通知翻译函数
* @param events