增加适配npc pt商店及卖出框的标题
This commit is contained in:
parent
5bb8ada426
commit
d0f1d2b325
@ -1,8 +1,8 @@
|
|||||||
// ==UserScript==
|
// ==UserScript==
|
||||||
// @lastmodified 202112111613
|
// @lastmodified 202112111702
|
||||||
// @name Torn翻译
|
// @name Torn翻译
|
||||||
// @namespace WOOH
|
// @namespace WOOH
|
||||||
// @version 0.1.1211b
|
// @version 0.1.1211c
|
||||||
// @description Torn UI翻译
|
// @description Torn UI翻译
|
||||||
// @author Woohoo-[2687093] sabrina_devil[2696209]
|
// @author Woohoo-[2687093] sabrina_devil[2696209]
|
||||||
// @match https://www.torn.com/*
|
// @match https://www.torn.com/*
|
||||||
@ -23,6 +23,11 @@
|
|||||||
todo: true,
|
todo: true,
|
||||||
cont: `baza npc商店 imarket及imarket搜索结果`,
|
cont: `baza npc商店 imarket及imarket搜索结果`,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
ver: '0.1.1211c',
|
||||||
|
date: '20211211',
|
||||||
|
cont: `增加适配npc pt商店及卖出框的标题`,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
ver: '0.1.1211b',
|
ver: '0.1.1211b',
|
||||||
date: '20211211',
|
date: '20211211',
|
||||||
@ -79,6 +84,10 @@
|
|||||||
'Items': '物品仓库',
|
'Items': '物品仓库',
|
||||||
'Travel Agency': '旅行社',
|
'Travel Agency': '旅行社',
|
||||||
'Display Cabinet': '展示柜',
|
'Display Cabinet': '展示柜',
|
||||||
|
'Torn Docks': '码头车行',
|
||||||
|
'Nikeh Sports Shop': '耐克哈运动专卖',
|
||||||
|
'Torn City Super Store': '电器商店',
|
||||||
|
"Sally's Sweet Shop": '莎莉的糖果店',
|
||||||
};
|
};
|
||||||
const titleLinksDict = {
|
const titleLinksDict = {
|
||||||
'Personal stats': '个人统计信息',
|
'Personal stats': '个人统计信息',
|
||||||
@ -2712,6 +2721,7 @@
|
|||||||
"Yes": '是',
|
"Yes": '是',
|
||||||
"No": '否',
|
"No": '否',
|
||||||
"Are you sure you would like to buy": '你是否想买',
|
"Are you sure you would like to buy": '你是否想买',
|
||||||
|
"Sell your points": '出售你的PT',
|
||||||
};
|
};
|
||||||
|
|
||||||
// 默认开启通知翻译
|
// 默认开启通知翻译
|
||||||
@ -3563,7 +3573,7 @@
|
|||||||
/*
|
/*
|
||||||
npc商店
|
npc商店
|
||||||
*/
|
*/
|
||||||
if (window.location.href.contains(/shops\.php/)) {
|
if (window.location.href.contains(/(shops|bigalgunshop)\.php/)) {
|
||||||
// 标题和右边的链接
|
// 标题和右边的链接
|
||||||
const $cont_title = document.querySelector('.content-title');
|
const $cont_title = document.querySelector('.content-title');
|
||||||
initOB($cont_title, {childList: true, subtree: true},
|
initOB($cont_title, {childList: true, subtree: true},
|
||||||
@ -3574,9 +3584,10 @@
|
|||||||
const $wrapper = document.querySelector('.content-wrapper');
|
const $wrapper = document.querySelector('.content-wrapper');
|
||||||
// [购买部分]
|
// [购买部分]
|
||||||
const $buy_items_wrapper = $wrapper.querySelector('.buy-items-wrap');
|
const $buy_items_wrapper = $wrapper.querySelector('.buy-items-wrap');
|
||||||
|
if ($buy_items_wrapper) {
|
||||||
// 黑框标题
|
// 黑框标题
|
||||||
const $buy_black_title = $buy_items_wrapper.querySelector('.title-black');
|
const $buy_black_title = $buy_items_wrapper.querySelector('.title-black');
|
||||||
if ($buy_black_title.firstChild.nodeValue && npcShopDict[$buy_black_title.firstChild.nodeValue.trim()]) {
|
if ($buy_black_title && npcShopDict[$buy_black_title.firstChild.nodeValue.trim()]) {
|
||||||
$buy_black_title.firstChild.nodeValue = npcShopDict[$buy_black_title.firstChild.nodeValue.trim()];
|
$buy_black_title.firstChild.nodeValue = npcShopDict[$buy_black_title.firstChild.nodeValue.trim()];
|
||||||
}
|
}
|
||||||
// 各个物品
|
// 各个物品
|
||||||
@ -3623,14 +3634,25 @@
|
|||||||
const $item_desc = $wrapper.querySelector('.show-item-info') || $wrapper.querySelector('.view-item-info');
|
const $item_desc = $wrapper.querySelector('.show-item-info') || $wrapper.querySelector('.view-item-info');
|
||||||
showItemInfoTrans($item_desc);
|
showItemInfoTrans($item_desc);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
// [卖出部分]
|
// [卖出部分]
|
||||||
const $sell_items_wrapper = $wrapper.querySelector('.sell-items-wrap');
|
const $sell_items_wrapper = $wrapper.querySelector('.sell-items-wrap');
|
||||||
|
if ($sell_items_wrapper) {
|
||||||
// 黑框标题
|
// 黑框标题
|
||||||
const $title = $sell_items_wrapper.querySelectorAll('ul.title li');
|
const $title = $sell_items_wrapper.querySelectorAll('ul.title li');
|
||||||
$title.forEach(el => {
|
$title.forEach(el => {
|
||||||
el.childNodes.forEach(e => {
|
el.childNodes.forEach(e => {
|
||||||
if (e.nodeType === 1) {
|
if (e.nodeType === 1) {
|
||||||
if (npcShopDict[e.innerText.trim()]) e.innerText = npcShopDict[e.innerText.trim()];
|
if (npcShopDict[e.innerText.trim()]) {
|
||||||
|
e.innerText = npcShopDict[e.innerText.trim()];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const spl = e.innerText.trim().split(' ');
|
||||||
|
if (spl.length > 3) {
|
||||||
|
const shop_name = spl[2] === 'the' ? spl.slice(3).join(' ') : spl.slice(2).join(' ');
|
||||||
|
const shop_name_trans = npcShopDict[shop_name] || titleDict[shop_name] || cityDict[shop_name] || null;
|
||||||
|
e.innerText = `物品给${shop_name_trans || shop_name}`;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (npcShopDict[e.nodeValue.trim()]) e.nodeValue = npcShopDict[e.nodeValue.trim()];
|
if (npcShopDict[e.nodeValue.trim()]) e.nodeValue = npcShopDict[e.nodeValue.trim()];
|
||||||
}
|
}
|
||||||
@ -3669,6 +3691,16 @@
|
|||||||
const $total_value = $sell_confirm.querySelector('span.profit').childNodes[0];
|
const $total_value = $sell_confirm.querySelector('span.profit').childNodes[0];
|
||||||
if (npcShopDict[$total_value.nodeValue.trim()]) $total_value.nodeValue = npcShopDict[$total_value.nodeValue.trim()];
|
if (npcShopDict[$total_value.nodeValue.trim()]) $total_value.nodeValue = npcShopDict[$total_value.nodeValue.trim()];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
// [出售PT部分]
|
||||||
|
const $sell_pt_wrapper = $wrapper.querySelector('.sell-points-wrap');
|
||||||
|
if ($sell_pt_wrapper) {
|
||||||
|
// 黑框
|
||||||
|
const $title_black = $sell_pt_wrapper.querySelector('.title-black');
|
||||||
|
if (npcShopDict[$title_black.innerText.trim()]) {
|
||||||
|
$title_black.innerText = npcShopDict[$title_black.innerText.trim()];
|
||||||
|
}
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user