修复通知

This commit is contained in:
woohoo 2021-11-18 12:30:19 +08:00
parent a513c90e14
commit 222e84b2ea

View File

@ -1,8 +1,8 @@
// ==UserScript== // ==UserScript==
// @name Torn翻译 // @name Torn翻译
// @namespace WOOH // @namespace WOOH
// @version 0.1.1117a // @version 0.1.1118a
// @description 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/*
// @grant none // @grant none
@ -961,6 +961,19 @@
.replace('second', '秒钟'); .replace('second', '秒钟');
}; };
/**
* regexp test
*/
String.prototype.contains = function contains(keywords) {
if (typeof keywords === 'string') {
if (keywords.contains(/\*/))
keywords = keywords.replace("*", '.+');
return new RegExp(keywords).test(this);
}
if (keywords.test)
return keywords.test(this);
};
/** /**
* 边栏 * 边栏
* 目前默认所有页面调用边栏翻译 * 目前默认所有页面调用边栏翻译
@ -2705,9 +2718,9 @@
* <span class="mail-link" id="event-855834754">You have successfully purchased membership in Deep Burn.</span> * <span class="mail-link" id="event-855834754">You have successfully purchased membership in Deep Burn.</span>
* 你已成功购买Deep Burn的健身房会员卡 * 你已成功购买Deep Burn的健身房会员卡
*/ */
if ($(e).text().indexOf('membership') >= 0) { if ($(e).text().contains('You have successfully purchased membership in')) {
const gymName = e.firstChild.nodeValue.slice(46, -2); const gymName = e.firstChild.nodeValue.trim().slice(46, -1);
e.firstChild.nodeValue = '你已成功购买 ' + gymName + ' 的健身房会员卡。'; e.firstChild.nodeValue = '你已成功购买 ' + gymList[gymName] + ' 的健身房会员卡。';
return; return;
} }