TS重构
This commit is contained in:
parent
e7bece004f
commit
44d6c283c7
7
package-lock.json
generated
7
package-lock.json
generated
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "wuhu-torn-helper",
|
"name": "wuhu-torn-helper",
|
||||||
"version": "0.4.9",
|
"version": "0.5.1",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@ -25,6 +25,11 @@
|
|||||||
"integrity": "sha512-JYM8x9EGF163bEyhdJBpR2QX1R5naCJHC8ucJylJ3w9/CVBaskdQ8WqBf8MmQrd1kRvp/a4TS8HJ+bxzR7ZJYQ==",
|
"integrity": "sha512-JYM8x9EGF163bEyhdJBpR2QX1R5naCJHC8ucJylJ3w9/CVBaskdQ8WqBf8MmQrd1kRvp/a4TS8HJ+bxzR7ZJYQ==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"typescript": {
|
||||||
|
"version": "4.8.3",
|
||||||
|
"resolved": "https://registry.npmmirror.com/typescript/-/typescript-4.8.3.tgz",
|
||||||
|
"integrity": "sha512-goMHfm00nWPa8UvR/CPSvykqf6dVV8x/dp0c5mFTMTIu0u0FlGWRioyy7Nn0PGAdHxpJZnuO/ut+PpQ8UiHAig=="
|
||||||
|
},
|
||||||
"uglify-js": {
|
"uglify-js": {
|
||||||
"version": "3.16.1",
|
"version": "3.16.1",
|
||||||
"resolved": "https://registry.npmmirror.com/uglify-js/-/uglify-js-3.16.1.tgz",
|
"resolved": "https://registry.npmmirror.com/uglify-js/-/uglify-js-3.16.1.tgz",
|
||||||
|
|||||||
@ -2,7 +2,8 @@
|
|||||||
"name": "wuhu-torn-helper",
|
"name": "wuhu-torn-helper",
|
||||||
"version": "0.5.1",
|
"version": "0.5.1",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"uglify-js": "^3.16.1"
|
"uglify-js": "^3.16.1",
|
||||||
|
"typescript": "*"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"release": "npm run minify && node build.js",
|
"release": "npm run minify && node build.js",
|
||||||
|
|||||||
@ -179,7 +179,7 @@ z-index: 999999;}`);
|
|||||||
else {
|
else {
|
||||||
node_link.remove();
|
node_link.remove();
|
||||||
node_link = null;
|
node_link = null;
|
||||||
log('已移除GT助手');
|
log.info('已移除GT助手');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -24,11 +24,9 @@ export default async function travelHelper(glob: Global): Promise<null> {
|
|||||||
if (country === 'torn') {
|
if (country === 'torn') {
|
||||||
dest_cn = '回城';
|
dest_cn = '回城';
|
||||||
} else {
|
} else {
|
||||||
dest_cn = {
|
dest_cn = {'uk': "英国", 'switzerland': "瑞士", 'mexico': '墨西哥', 'canada': '加拿大', 'cayman': '开曼',
|
||||||
'uk': "英国", 'switzerland': "瑞士", 'mexico': '墨西哥', 'canada': '加拿大', 'cayman': '开曼',
|
'hawaii': '夏威夷', 'argentina': '阿根廷',
|
||||||
'hawaii': '夏威夷', 'argentina': '阿根廷',
|
'japan': '日本', 'china': '中国', 'uae': 'UAE', 'sa': '南非',}[country] || country;
|
||||||
'japan': '日本', 'china': '中国', 'uae': 'UAE', 'sa': '南非',
|
|
||||||
}[country] || country;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 剩余时间
|
// 剩余时间
|
||||||
|
|||||||
@ -775,7 +775,7 @@ export default function eventsTrans(events: JQuery = $('span.mail-link')) {
|
|||||||
prePos = node3Spl[0].slice(14, node3Spl[0].length);
|
prePos = node3Spl[0].slice(14, node3Spl[0].length);
|
||||||
curPos = node3Spl[1].slice(0, node3Spl[1].length - 2);
|
curPos = node3Spl[1].slice(0, node3Spl[1].length - 2);
|
||||||
} else {
|
} else {
|
||||||
log('职位出现" to "');// todo
|
log.info('职位出现" to "');// todo
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
e.firstChild.nodeValue = '你在 ';
|
e.firstChild.nodeValue = '你在 ';
|
||||||
|
|||||||
@ -279,15 +279,8 @@ export default function translateMain(href: string): void {
|
|||||||
// 飞行页面
|
// 飞行页面
|
||||||
if (href.includes('index.php') &&
|
if (href.includes('index.php') &&
|
||||||
!!document.querySelector('div.travelling h4')) {
|
!!document.querySelector('div.travelling h4')) {
|
||||||
const travelOB = new MutationObserver(travelOBInit);
|
|
||||||
|
|
||||||
function travelOBInit() {
|
let travelTrans = function travelTrans() {
|
||||||
travelOB.disconnect();
|
|
||||||
travelTrans();
|
|
||||||
travelOB.observe($('div.content-wrapper')[0], { childList: true, subtree: true });
|
|
||||||
}
|
|
||||||
|
|
||||||
function travelTrans() {
|
|
||||||
titleTrans();
|
titleTrans();
|
||||||
contentTitleLinksTrans();
|
contentTitleLinksTrans();
|
||||||
|
|
||||||
@ -308,7 +301,13 @@ export default function translateMain(href: string): void {
|
|||||||
node.text('于 ' + landingTime + ' 降落');
|
node.text('于 ' + landingTime + ' 降落');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
let travelOBInit = function travelOBInit() {
|
||||||
|
travelOB.disconnect();
|
||||||
|
travelTrans();
|
||||||
|
travelOB.observe($('div.content-wrapper')[0], { childList: true, subtree: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
const travelOB = new MutationObserver(travelOBInit);
|
||||||
travelTrans();
|
travelTrans();
|
||||||
travelOB.observe(document.querySelector('div.content-wrapper'), { childList: true, subtree: true });
|
travelOB.observe(document.querySelector('div.content-wrapper'), { childList: true, subtree: true });
|
||||||
}
|
}
|
||||||
@ -362,15 +361,8 @@ export default function translateMain(href: string): void {
|
|||||||
|
|
||||||
// city
|
// city
|
||||||
if (href.includes('city.php')) {
|
if (href.includes('city.php')) {
|
||||||
const cityOB = new MutationObserver(cityOBInit);
|
|
||||||
|
|
||||||
function cityOBInit() {
|
let cityTrans = function cityTrans() {
|
||||||
cityOB.disconnect();
|
|
||||||
cityTrans();
|
|
||||||
cityOB.observe($('div.content-wrapper')[0], { childList: true, subtree: true });
|
|
||||||
}
|
|
||||||
|
|
||||||
function cityTrans() {
|
|
||||||
titleTrans();
|
titleTrans();
|
||||||
contentTitleLinksTrans();
|
contentTitleLinksTrans();
|
||||||
|
|
||||||
@ -435,7 +427,13 @@ export default function translateMain(href: string): void {
|
|||||||
$(e).text(cityDict[$(e).text()]);
|
$(e).text(cityDict[$(e).text()]);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
let cityOBInit = function cityOBInit() {
|
||||||
|
cityOB.disconnect();
|
||||||
|
cityTrans();
|
||||||
|
cityOB.observe($('div.content-wrapper')[0], { childList: true, subtree: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
const cityOB = new MutationObserver(cityOBInit);
|
||||||
cityTrans();
|
cityTrans();
|
||||||
cityOB.observe(document.querySelector('div.content-wrapper'), { childList: true, subtree: true });
|
cityOB.observe(document.querySelector('div.content-wrapper'), { childList: true, subtree: true });
|
||||||
return;
|
return;
|
||||||
@ -443,15 +441,8 @@ export default function translateMain(href: string): void {
|
|||||||
|
|
||||||
// gym健身房页面
|
// gym健身房页面
|
||||||
if (href.includes('gym.php')) {
|
if (href.includes('gym.php')) {
|
||||||
const gymOB = new MutationObserver(gymOBInit);
|
|
||||||
|
|
||||||
function gymOBInit() {
|
let gymTrans = function gymTrans() {
|
||||||
gymOB.disconnect();
|
|
||||||
gymTrans();
|
|
||||||
gymOB.observe($('div.content-wrapper')[0], { childList: true, subtree: true, attributes: true });
|
|
||||||
}
|
|
||||||
|
|
||||||
function gymTrans() {
|
|
||||||
titleTrans();
|
titleTrans();
|
||||||
contentTitleLinksTrans();
|
contentTitleLinksTrans();
|
||||||
const gymName = $('div[class^="notificationText"] b').text();
|
const gymName = $('div[class^="notificationText"] b').text();
|
||||||
@ -550,7 +541,13 @@ export default function translateMain(href: string): void {
|
|||||||
$(e).text(gymDict[$(e).text().trim()]);
|
$(e).text(gymDict[$(e).text().trim()]);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
let gymOBInit = function gymOBInit() {
|
||||||
|
gymOB.disconnect();
|
||||||
|
gymTrans();
|
||||||
|
gymOB.observe($('div.content-wrapper')[0], { childList: true, subtree: true, attributes: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
const gymOB = new MutationObserver(gymOBInit);
|
||||||
gymTrans();
|
gymTrans();
|
||||||
gymOB.observe($('div.content-wrapper')[0], { childList: true, subtree: true, attributes: true });
|
gymOB.observe($('div.content-wrapper')[0], { childList: true, subtree: true, attributes: true });
|
||||||
return;
|
return;
|
||||||
@ -737,15 +734,16 @@ export default function translateMain(href: string): void {
|
|||||||
$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()]) {
|
let node = e as HTMLElement;
|
||||||
e.innerText = npcShopDict[e.innerText.trim()];
|
if (npcShopDict[node.innerText.trim()]) {
|
||||||
|
node.innerText = npcShopDict[node.innerText.trim()];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const spl = e.innerText.trim().split(' ');
|
const spl = node.innerText.trim().split(' ');
|
||||||
if (spl.length > 3) {
|
if (spl.length > 3) {
|
||||||
const shop_name = spl[2] === 'the' ? spl.slice(3).join(' ') : spl.slice(2).join(' ');
|
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;
|
const shop_name_trans = npcShopDict[shop_name] || titleDict[shop_name] || cityDict[shop_name] || null;
|
||||||
e.innerText = `物品给${ shop_name_trans || shop_name }`;
|
node.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()];
|
||||||
@ -915,15 +913,8 @@ export default function translateMain(href: string): void {
|
|||||||
|
|
||||||
// 教育页面
|
// 教育页面
|
||||||
if (href.indexOf('education.php') >= 0) {
|
if (href.indexOf('education.php') >= 0) {
|
||||||
const eduOB = new MutationObserver(eduOBInit);
|
|
||||||
|
|
||||||
function eduOBInit() {
|
let eduTrans = function eduTrans() {
|
||||||
eduOB.disconnect();
|
|
||||||
eduTrans();
|
|
||||||
eduOB.observe($('div.content-wrapper')[0], { childList: true, subtree: true });
|
|
||||||
}
|
|
||||||
|
|
||||||
function eduTrans() {
|
|
||||||
titleTrans();
|
titleTrans();
|
||||||
contentTitleLinksTrans();
|
contentTitleLinksTrans();
|
||||||
|
|
||||||
@ -1003,7 +994,13 @@ export default function translateMain(href: string): void {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
let eduOBInit = function eduOBInit() {
|
||||||
|
eduOB.disconnect();
|
||||||
|
eduTrans();
|
||||||
|
eduOB.observe($('div.content-wrapper')[0], { childList: true, subtree: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
const eduOB = new MutationObserver(eduOBInit);
|
||||||
eduTrans();
|
eduTrans();
|
||||||
eduOB.observe($('div.content-wrapper')[0], { childList: true, subtree: true });
|
eduOB.observe($('div.content-wrapper')[0], { childList: true, subtree: true });
|
||||||
return;
|
return;
|
||||||
@ -1096,7 +1093,7 @@ export default function translateMain(href: string): void {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ($('.wh-translated').length <= 0) {
|
if ($('.wh-translated').length <= 0) {
|
||||||
log(`未找到翻译: “${ action_desc.text().trim() }”`);
|
log.info(`未找到翻译: “${ action_desc.text().trim() }”`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 添加敌人或朋友的界面
|
// 添加敌人或朋友的界面
|
||||||
@ -1233,13 +1230,9 @@ export default function translateMain(href: string): void {
|
|||||||
|
|
||||||
// 报纸
|
// 报纸
|
||||||
if (href.contains(/(newspaper|joblist|freebies|newspaper_class|personals|bounties|comics)\.php/)) {
|
if (href.contains(/(newspaper|joblist|freebies|newspaper_class|personals|bounties|comics)\.php/)) {
|
||||||
const newspaperOB = new MutationObserver(() => {
|
|
||||||
newspaperOB.disconnect();
|
|
||||||
newspaperTrans();
|
|
||||||
newspaperOB.observe($('div.content-wrapper')[0], { childList: true, subtree: true });
|
|
||||||
});
|
|
||||||
|
|
||||||
function newspaperTrans() {
|
|
||||||
|
let newspaperTrans = function newspaperTrans() {
|
||||||
titleTrans();
|
titleTrans();
|
||||||
contentTitleLinksTrans();
|
contentTitleLinksTrans();
|
||||||
if ($('a.newspaper-link').length === 0) return;
|
if ($('a.newspaper-link').length === 0) return;
|
||||||
@ -1413,7 +1406,11 @@ export default function translateMain(href: string): void {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
const newspaperOB = new MutationObserver(() => {
|
||||||
|
newspaperOB.disconnect();
|
||||||
|
newspaperTrans();
|
||||||
|
newspaperOB.observe($('div.content-wrapper')[0], { childList: true, subtree: true });
|
||||||
|
});
|
||||||
newspaperTrans();
|
newspaperTrans();
|
||||||
newspaperOB.observe($('div.content-wrapper')[0], { childList: true, subtree: true });
|
newspaperOB.observe($('div.content-wrapper')[0], { childList: true, subtree: true });
|
||||||
return;
|
return;
|
||||||
@ -1838,7 +1835,7 @@ export default function translateMain(href: string): void {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
// 展开详细框
|
// 展开详细框
|
||||||
const $show_item_info = $display_cabinet.querySelector('.show-item-info');
|
const $show_item_info = $display_cabinet.querySelector('.show-item-info') as HTMLElement;
|
||||||
showItemInfoTrans($show_item_info);
|
showItemInfoTrans($show_item_info);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -1851,15 +1848,8 @@ export default function translateMain(href: string): void {
|
|||||||
|
|
||||||
// 医院页面
|
// 医院页面
|
||||||
if (href.includes("hospitalview.php")) {
|
if (href.includes("hospitalview.php")) {
|
||||||
const hospitalOB = new MutationObserver(hosOBInit);
|
|
||||||
|
|
||||||
function hosOBInit() {
|
let hospTrans = function hospTrans() {
|
||||||
hospitalOB.disconnect();
|
|
||||||
hospTrans();
|
|
||||||
hospitalOB.observe($('div.content-wrapper')[0], { childList: true, subtree: true });
|
|
||||||
}
|
|
||||||
|
|
||||||
function hospTrans() {
|
|
||||||
titleTrans();
|
titleTrans();
|
||||||
contentTitleLinksTrans();
|
contentTitleLinksTrans();
|
||||||
|
|
||||||
@ -1901,7 +1891,13 @@ export default function translateMain(href: string): void {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
let hosOBInit = function hosOBInit() {
|
||||||
|
hospitalOB.disconnect();
|
||||||
|
hospTrans();
|
||||||
|
hospitalOB.observe($('div.content-wrapper')[0], { childList: true, subtree: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
const hospitalOB = new MutationObserver(hosOBInit);
|
||||||
hospTrans();
|
hospTrans();
|
||||||
hospitalOB.observe($('div.content-wrapper')[0], { childList: true, subtree: true });
|
hospitalOB.observe($('div.content-wrapper')[0], { childList: true, subtree: true });
|
||||||
return;
|
return;
|
||||||
@ -1909,14 +1905,6 @@ export default function translateMain(href: string): void {
|
|||||||
|
|
||||||
// 帮派页面
|
// 帮派页面
|
||||||
if (href.includes("actions.php")) {
|
if (href.includes("actions.php")) {
|
||||||
const factionOB = new MutationObserver(factionOBInit);
|
|
||||||
|
|
||||||
function factionOBInit() {
|
|
||||||
factionOB.disconnect();
|
|
||||||
factionTrans();
|
|
||||||
factionOB.observe($('div.content-wrapper')[0], { childList: true, subtree: true });
|
|
||||||
}
|
|
||||||
|
|
||||||
const factionDict = {
|
const factionDict = {
|
||||||
"INFO": "信息",
|
"INFO": "信息",
|
||||||
"TERRITORY": "地盘",
|
"TERRITORY": "地盘",
|
||||||
@ -1951,8 +1939,7 @@ export default function translateMain(href: string): void {
|
|||||||
"Someone attacked": "有人攻击了 ",
|
"Someone attacked": "有人攻击了 ",
|
||||||
"Someone hospitalized": "有人暴打了 "
|
"Someone hospitalized": "有人暴打了 "
|
||||||
}
|
}
|
||||||
|
let factionTrans = function factionTrans() {
|
||||||
function factionTrans() {
|
|
||||||
titleTrans();
|
titleTrans();
|
||||||
contentTitleLinksTrans();
|
contentTitleLinksTrans();
|
||||||
|
|
||||||
@ -1987,7 +1974,7 @@ export default function translateMain(href: string): void {
|
|||||||
//帮派主要消息日志
|
//帮派主要消息日志
|
||||||
$('button[class^="tab"] ').each((i, e) => {
|
$('button[class^="tab"] ').each((i, e) => {
|
||||||
if ($(e).attr('class').indexOf("active") >= 0) {
|
if ($(e).attr('class').indexOf("active") >= 0) {
|
||||||
log($(e).text());
|
log.info($(e).text());
|
||||||
switch ($(e).text().trim()) {
|
switch ($(e).text().trim()) {
|
||||||
case "主要消息":
|
case "主要消息":
|
||||||
$('ul[class^="news-list"] span[class^="info"]').contents().each((i, u) => {
|
$('ul[class^="news-list"] span[class^="info"]').contents().each((i, u) => {
|
||||||
@ -1998,7 +1985,7 @@ export default function translateMain(href: string): void {
|
|||||||
break;
|
break;
|
||||||
case "攻击":
|
case "攻击":
|
||||||
$('ul[class^="news-list"] span[class^="info"]').find('*').contents().each((i, u) => {
|
$('ul[class^="news-list"] span[class^="info"]').find('*').contents().each((i, u) => {
|
||||||
log($(u).text().trim())
|
log.info($(u).text().trim())
|
||||||
if (factionDict[$(u).text().trim()]) {
|
if (factionDict[$(u).text().trim()]) {
|
||||||
u.nodeValue = factionDict[$(u).text().trim()];
|
u.nodeValue = factionDict[$(u).text().trim()];
|
||||||
}
|
}
|
||||||
@ -2022,7 +2009,13 @@ export default function translateMain(href: string): void {
|
|||||||
// })
|
// })
|
||||||
|
|
||||||
}
|
}
|
||||||
|
let factionOBInit = function factionOBInit() {
|
||||||
|
factionOB.disconnect();
|
||||||
|
factionTrans();
|
||||||
|
factionOB.observe($('div.content-wrapper')[0], { childList: true, subtree: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
const factionOB = new MutationObserver(factionOBInit);
|
||||||
factionTrans();
|
factionTrans();
|
||||||
factionOB.observe($('div.content-wrapper')[0], { childList: true, subtree: true });
|
factionOB.observe($('div.content-wrapper')[0], { childList: true, subtree: true });
|
||||||
return;
|
return;
|
||||||
|
|||||||
@ -9,7 +9,7 @@ export default function audioPlay(url: string = 'https://www.torn.com/js/chat/so
|
|||||||
const audio = new Audio(url);
|
const audio = new Audio(url);
|
||||||
audio.addEventListener("canplaythrough", () => {
|
audio.addEventListener("canplaythrough", () => {
|
||||||
audio.play()
|
audio.play()
|
||||||
.catch(err => log(err))
|
.catch(err => log.error(err))
|
||||||
.then();
|
.then();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -9,7 +9,7 @@ function autoFetchJSON(dest, time = 30) {
|
|||||||
let obj;
|
let obj;
|
||||||
const res = COFetch(dest);
|
const res = COFetch(dest);
|
||||||
setInterval(async () => {
|
setInterval(async () => {
|
||||||
if (!isWindowActive()) return;
|
if (!window.WHPARAMS.isWindowActive()) return;
|
||||||
const res = await COFetch(dest);
|
const res = await COFetch(dest);
|
||||||
obj = JSON.parse(res);
|
obj = JSON.parse(res);
|
||||||
}, time * 1000);
|
}, time * 1000);
|
||||||
|
|||||||
@ -48,7 +48,7 @@ async function priceWatcherPt(apikey, lower_price) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// 查询出错了
|
// 查询出错了
|
||||||
log('pt查询出错了')
|
log.error('pt查询出错了')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,6 +72,6 @@ async function priceWatcherXan(apikey, lower_price) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// 查询出错了
|
// 查询出错了
|
||||||
log('xan查询出错了')
|
log.info('xan查询出错了')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -8,7 +8,9 @@ import urlMatch from "./urlMatch";
|
|||||||
(function main() {
|
(function main() {
|
||||||
let started = new Date().getTime();
|
let started = new Date().getTime();
|
||||||
|
|
||||||
if (document.title.toLowerCase().includes('just a moment')) return;
|
if (document.title.toLowerCase().includes('just a moment') ||
|
||||||
|
document.querySelector('#skip-to-content').innerText.toLowerCase().includes('please validate')
|
||||||
|
) return;
|
||||||
|
|
||||||
let glob = init();
|
let glob = init();
|
||||||
|
|
||||||
|
|||||||
@ -158,19 +158,19 @@ function initIcon(settings: MenuItemConfig[]): MyHTMLElement {
|
|||||||
zhong_node.classList.toggle('wh-icon-expanded');
|
zhong_node.classList.toggle('wh-icon-expanded');
|
||||||
const click_func = e => {
|
const click_func = e => {
|
||||||
// e.stopImmediatePropagation();
|
// e.stopImmediatePropagation();
|
||||||
log(e.target);
|
log.info(e.target);
|
||||||
if (e.target === zhong_node.querySelector('#wh-trans-icon-btn')) return;
|
if (e.target === zhong_node.querySelector('#wh-trans-icon-btn')) return;
|
||||||
if (!zhong_node.contains(e.target)) {
|
if (!zhong_node.contains(e.target)) {
|
||||||
log('移除事件监听器');
|
log.info('移除事件监听器');
|
||||||
document.body.removeEventListener('click', click_func);
|
document.body.removeEventListener('click', click_func);
|
||||||
zhong_node.classList.remove('wh-icon-expanded');
|
zhong_node.classList.remove('wh-icon-expanded');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if (zhong_node.classList.contains('wh-icon-expanded')) {
|
if (zhong_node.classList.contains('wh-icon-expanded')) {
|
||||||
log('添加事件监听器');
|
log.info('添加事件监听器');
|
||||||
document.body.addEventListener('click', click_func);
|
document.body.addEventListener('click', click_func);
|
||||||
} else {
|
} else {
|
||||||
log('移除事件监听器');
|
log.info('移除事件监听器');
|
||||||
document.body.removeEventListener('click', click_func);
|
document.body.removeEventListener('click', click_func);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -751,7 +751,7 @@ background-size: 100% auto !important;
|
|||||||
`;
|
`;
|
||||||
const popup = popupMsg(html, '价格监视设置');
|
const popup = popupMsg(html, '价格监视设置');
|
||||||
popup.querySelector('button').onclick = () => {
|
popup.querySelector('button').onclick = () => {
|
||||||
const [pt_node, xan_node] = Array.from(popup.querySelectorAll('input[type="number"]'));
|
const [pt_node, xan_node] = Array.from(<NodeListOf<HTMLInputElement>>popup.querySelectorAll('input[type="number"]'));
|
||||||
watcher_conf.pt = (pt_node.value as any) | 0;
|
watcher_conf.pt = (pt_node.value as any) | 0;
|
||||||
watcher_conf.xan = (xan_node.value as any) | 0;
|
watcher_conf.xan = (xan_node.value as any) | 0;
|
||||||
if (JSON.stringify(watcher_conf) !== pre_str) setWhSetting('priceWatcher', watcher_conf);
|
if (JSON.stringify(watcher_conf) !== pre_str) setWhSetting('priceWatcher', watcher_conf);
|
||||||
|
|||||||
@ -6,6 +6,8 @@
|
|||||||
"es2015",
|
"es2015",
|
||||||
"ES2021.String"
|
"ES2021.String"
|
||||||
],
|
],
|
||||||
"target": "es5"
|
"target": "ES5",
|
||||||
|
"removeComments": true,
|
||||||
|
"sourceMap": false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user