forked from dodying/UserJs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchs2chtForInputbox.user.js
36 lines (36 loc) · 1.12 KB
/
chs2chtForInputbox.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// ==UserScript==
// @name chs2chtForInputbox
// @namespace https://github.com/dodying/Dodying-UserJs
// @name:zh-CN
// @description:zh-CN
// @include *
// @version 1.10
// @grant GM_registerMenuCommand
// @author dodying
// @namespace https://github.com/dodying/Dodying-UserJs
// @supportURL https://github.com/dodying/Dodying-UserJs/issues
// @icon https://gitee.com/dodying/userJs/raw/master/Logo.png
// @require https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.js
// @require https://greasyfork.org/scripts/21541/code/chs2cht.js?version=137286
// @run-at document-end
// ==/UserScript==
/*
document.onkeydown = function (e) {
if (e.target.onblur === null) {
e.target.onblur = function () {
this.value = tranStr(this.value, true);//true转为繁体,false转为简体
}
}
}
*/
GM_registerMenuCommand('转为繁体', () => {
tran(true);
}, 'T');
GM_registerMenuCommand('转为简体', () => {
tran(false);
}, 'S');
function tran(toBig5) {
jQuery('input:text,textarea,[contenteditable="true"]').val(function () {
return tranStr(this.value, toBig5);
});
}