Skip to content

Commit 4d6f0cd

Browse files
committed
fix
1 parent 8393f2c commit 4d6f0cd

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

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

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// @name:zh-CN 简繁自由切换
44
// @name:en Switch Traditional Chinese and Simplified Chinese
55
// @namespace hoothin
6-
// @version 0.5
6+
// @version 0.6
77
// @description 快速轉換整個網頁或者指定輸入框中的簡體中文與繁體中文
88
// @description:zh-CN 快速转换整个网页或者指定输入框中的简体中文与繁体中文
99
// @description:en Just Switch Traditional Chinese and Simplified Chinese
@@ -54,7 +54,7 @@
5454
child.alt=alt;
5555
}
5656
}
57-
if(child.tagName == "INPUT" && child.value !== "" && child.type != "text" && child.type != "hidden"){
57+
if(child.tagName == "INPUT" && child.value !== "" && child.type != "text" && child.type != "search" && child.type != "hidden"){
5858
let value=stranText(child.value);
5959
if(child.value != value){
6060
child.value=value;
@@ -129,14 +129,17 @@
129129
setTimeout(stranBody,50);
130130
}
131131

132+
var curLang=isSimple;
132133
document.addEventListener("keydown", function(e) {
133134
if(e.keyCode == shortcutKey && e.ctrlKey) {
134-
action=action==2?3:2;
135135
if("TEXTAREA"==document.activeElement.tagName){
136-
document.activeElement.innerHTML=stranText(document.activeElement.innerHTML);
136+
document.activeElement.innerHTML=curLang?traditionalized(document.activeElement.innerHTML):simplized(document.activeElement.innerHTML);
137+
curLang=!curLang;
137138
}else if("INPUT"==document.activeElement.tagName){
138-
document.activeElement.value=stranText(document.activeElement.value);
139+
document.activeElement.value=curLang?traditionalized(document.activeElement.value):simplized(document.activeElement.value);
140+
curLang=!curLang;
139141
}else{
142+
action=action==2?3:2;
140143
setLanguage();
141144
}
142145
}

0 commit comments

Comments
 (0)