Skip to content

Commit 486f78c

Browse files
committed
Update Switch Traditional Chinese and Simplified Chinese.user.js
1 parent 147fde5 commit 486f78c

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

Switch Traditional Chinese and Simplified Chinese/Switch Traditional Chinese and Simplified Chinese.user.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// @namespace hoothin
77
// @supportURL https://github.com/hoothin/UserScripts
88
// @homepageURL https://github.com/hoothin/UserScripts
9-
// @version 1.2.7.11
9+
// @version 1.2.7.12
1010
// @description 任意轉換網頁中的簡體中文與正體中文(默認簡體→正體),顯示漢字對應漢語拼音,自訂任意替換文本
1111
// @description:zh-CN 任意转换网页中的简体中文与繁体中文(默认繁体→简体),显示汉字对应汉语拼音,自定义任意替换文本
1212
// @description:ja ウェブページ上の簡体字中国語と繁体字中国語を自由に変換し、中国語の文字にひらがなを表示し、任意の文字を置き換えることができます。
@@ -1122,6 +1122,17 @@
11221122
_unsafeWindow.tc2sc = simplized;
11231123
_unsafeWindow.sc2tc = traditionalized;
11241124

1125+
window.addEventListener("message", function(event) {
1126+
if (event.data && event.data.type === "switchChineseRequest") {
1127+
const receivedData = event.data.payload;
1128+
const result = receivedData.target === 'sc' ? simplized(receivedData.str) : traditionalized(receivedData.str);
1129+
window.postMessage({
1130+
type: "switchChineseResult",
1131+
payload: result
1132+
}, "*");
1133+
}
1134+
});
1135+
11251136
var storage = {
11261137
supportGM: typeof GM_getValue == 'function' && typeof GM_getValue('a', 'b') != 'undefined',
11271138
supportGMPromise: typeof GM != 'undefined' && typeof GM.getValue == 'function' && typeof GM.getValue('a','b') != 'undefined',

0 commit comments

Comments
 (0)