Skip to content

Commit cfbbf89

Browse files
committed
Update Highlight Every Code.user.js
1 parent e38e4a0 commit cfbbf89

1 file changed

Lines changed: 9 additions & 11 deletions

File tree

Highlight Every Code/Highlight Every Code.user.js

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// @name:zh-CN 代码片段高亮
44
// @name:zh-TW 程式碼片斷高亮
55
// @namespace hoothin
6-
// @version 2.1
6+
// @version 2.2
77
// @description Add a icon to popup a window that allows syntax highlighting and beautify and word count of source code snippets on current page
88
// @description:zh-CN 选择代码片段后点击图标弹出新窗口显示语法高亮美化与格式化后的代码与字数统计
99
// @description:zh-TW 選擇程式碼片段後點選圖示彈出新視窗顯示語法高亮美化與格式化後的程式碼與字數統計
@@ -128,14 +128,10 @@
128128
return { 'x': x, 'y': y };
129129
}
130130

131-
var _GM_getValue,_GM_setValue,_GM_registerMenuCommand;
132-
if(typeof GM_getValue!='undefined'){
133-
_GM_getValue=GM_getValue;
134-
_GM_setValue=GM_setValue;
131+
var _GM_registerMenuCommand;
132+
if(typeof GM_registerMenuCommand!='undefined'){
135133
_GM_registerMenuCommand=GM_registerMenuCommand;
136-
}else if(typeof GM!='undefined' && typeof GM.getValue!='undefined'){
137-
_GM_getValue=GM.getValue;
138-
_GM_setValue=GM.setValue;
134+
}else if(typeof GM!='undefined' && typeof GM.registerMenuCommand!='undefined'){
139135
_GM_registerMenuCommand=GM.registerMenuCommand;
140136
}
141137
if(typeof _GM_registerMenuCommand=='undefined')_GM_registerMenuCommand=(s,f)=>{};
@@ -159,8 +155,10 @@
159155
this.operaUJSStorage.setItem(key,value);
160156
}else if(this.mxAppStorage){
161157
this.mxAppStorage.setConfig(key,value);
162-
}else if(this.supportGM || this.supportGMPromise){
163-
_GM_setValue(key,value);
158+
}else if(this.supportGM){
159+
GM_setValue(key,value);
160+
}else if(this.supportGMPromise){
161+
GM.setValue(key,value);
164162
}else if(window.localStorage){
165163
window.localStorage.setItem(key,value);
166164
};
@@ -232,7 +230,7 @@
232230
}
233231
});
234232

235-
_GM_registerMenuCommand("Highlight", ()=>{
233+
_GM_registerMenuCommand("Custom input to highlight", ()=>{
236234
selStr=document.getSelection().toString();
237235
codes=selStr.replace(/&/g, "&amp;").replace(/\</g,"&lt;").replace(/\>/g,"&gt;");
238236
if(!codes){

0 commit comments

Comments
 (0)