Skip to content

Commit a17609e

Browse files
committed
Update Highlight Every Code.user.js
1 parent fe360f9 commit a17609e

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

Highlight Every Code/Highlight Every Code.user.js

Lines changed: 7 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.3
6+
// @version 1.5
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;cursor: pointer;";
25+
codeIcon.style.cssText="position:fixed;z-index:99999;cursor:pointer;transition:opacity 0.5s ease-in-out 0s;opacity:0;border:5px solid rgba(0, 0, 0, 0.2);border-radius:10px;";
2626
codeIcon.title="Show this code snippet";
2727
codeIcon.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABYAAAAYAgMAAACD0OXYAAAACVBMVEX7+/swMDBTU1MLxgsCAAAAJElEQVQI12MIBYEAGLUKBBbAqAUMQICgAoAqoBQ95JaCnASjAAgXMdk3d5HTAAAAAElFTkSuQmCC";
2828
codeIcon.onmousedown=function(){
@@ -56,6 +56,7 @@
5656
};
5757

5858
document.addEventListener('mousedown', function(o) {
59+
codeIcon.style.opacity=0;
5960
if(codeIcon.parentNode)codeIcon.parentNode.removeChild(codeIcon);
6061
});
6162
document.addEventListener('mouseup', function(o) {
@@ -68,12 +69,13 @@
6869
let pos=getMousePos(o);
6970
let left, top;
7071
if(isChrome){
71-
top=pos.y>document.documentElement.clientHeight-50?(pos.y-25):(pos.y+15);
72-
left=pos.x>document.documentElement.clientWidth-50?(pos.x-25):(pos.x+15);
72+
top=pos.y>document.documentElement.clientHeight-50?(pos.y-30):(pos.y+20);
73+
left=pos.x>document.documentElement.clientWidth-50?(pos.x-30):(pos.x+20);
7374
}else{
74-
top=pos.y-25;
75+
top=pos.y-30;
7576
left=pos.x+15;
7677
}
78+
codeIcon.style.opacity=0.9;
7779
codeIcon.style.top=top+"px";
7880
codeIcon.style.left=left+"px";
7981
}

0 commit comments

Comments
 (0)