Skip to content

Commit a2c32da

Browse files
committed
fix
1 parent 7f6141d commit a2c32da

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

Highlight Every Code/Highlight Every Code.user.js

Lines changed: 5 additions & 5 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 1.2
6+
// @version 1.3
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 選擇程式碼片段後點選圖示彈出新視窗顯示語法高亮美化與格式化後的程式碼與字數統計
@@ -22,7 +22,7 @@
2222
var isChrome=unsafeWindow.chrome;
2323
var codeIcon=document.createElement("img");
2424
var codes, selStr, scrollX, scrollY;
25-
codeIcon.style.cssText="position:fixed;z-index:99999;display:none;cursor: pointer;";
25+
codeIcon.style.cssText="position:fixed;z-index:99999;cursor: pointer;";
2626
codeIcon.title="Show this code snippet";
2727
codeIcon.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABYAAAAYAgMAAACD0OXYAAAACVBMVEX7+/swMDBTU1MLxgsCAAAAJElEQVQI12MIBYEAGLUKBBbAqAUMQICgAoAqoBQ95JaCnASjAAgXMdk3d5HTAAAAAElFTkSuQmCC";
2828
codeIcon.onmousedown=function(){
@@ -54,17 +54,17 @@
5454
GM_openInTab('data:text/html;charset=utf-8,' + encodeURIComponent(html));
5555
}
5656
};
57-
document.body.appendChild(codeIcon);
57+
5858
document.addEventListener('mousedown', function(o) {
59-
codeIcon.style.display="none";
59+
document.body.removeChild(codeIcon);
6060
});
6161
document.addEventListener('mouseup', function(o) {
6262
if (o.button === 0 && (o.ctrlKey || o.altKey || o.metaKey || o.shiftKey)) {
6363
setTimeout(function(){
6464
selStr=document.getSelection().toString();
6565
codes=selStr.replace(/&/g, "&amp;").replace(/\</g,"&lt;").replace(/\>/g,"&gt;");
6666
if(codes){
67-
codeIcon.style.display="block";
67+
document.body.appendChild(codeIcon);
6868
let pos=getMousePos(o);
6969
let left, top;
7070
if(isChrome){

0 commit comments

Comments
 (0)