Skip to content

Commit f874633

Browse files
committed
fix
1 parent 4d431c2 commit f874633

1 file changed

Lines changed: 30 additions & 5 deletions

File tree

Easy offline/Easy offline.user.js

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// @namespace http://tampermonkey.net/
99
// @require https://cdn.jsdelivr.net/jquery/1.7.2/jquery.min.js
1010
// @require https://cdn.jsdelivr.net/hi-base64/0.2.0/base64.min.js
11-
// @version 1.3.0
11+
// @version 1.3.1
1212
// @author Hoothin
1313
// @mail rixixi@gmail.com
1414
// @include http*://*/*
@@ -214,16 +214,28 @@
214214
offNode.click(function(e){
215215
if(!siteConfig.directUrl)GM_setValue("eoUrl",getRightUrl(offUrl));
216216
e.stopPropagation();
217+
hideIcons();
217218
});
218219
if(siteConfig.bgImg)offNode.css("background-image","url(\""+siteConfig.bgImg+"\")");
219220
if(siteConfig.hide || GM_getValue("eoHide"+siteConfig.name))continue;
220221
offNodes.push(offNode);
221222
parentDiv.prepend(offNode);
222223
}
223-
parentDiv.mouseover(function(e){
224-
e.stopPropagation();
225-
});
226-
document.addEventListener("mouseover", function(e){
224+
if(typeof(HTMLElement)!="undefined"){
225+
HTMLElement.prototype.contains=function(obj) {
226+
while(obj){
227+
if(obj==this)
228+
return true;
229+
obj=obj.parentNode;
230+
}
231+
return false;
232+
};
233+
}
234+
var marginTop=offNodes.length*25;
235+
parentDiv.prepend($('<div style="position:absolute;width:25px;height:'+marginTop+'px;margin-top:-'+(marginTop-25)+'px;background-color:white;opacity:0.001;"></div>'));
236+
parentDiv.mouseout(function(e){
237+
var relatedTarget=(e.relatedTarget||e.fromElement);
238+
if(relatedTarget && !parentDiv[0].contains(relatedTarget))
227239
hideIcons();
228240
});
229241
var preNode;
@@ -467,6 +479,19 @@
467479
if(siteConfig.bgImg)icon.css("background-image","url(\""+siteConfig.bgImg+"\")");
468480
icon.on("click", function(){
469481
var eoHide=GM_getValue("eoHide"+siteConfig.name);
482+
if(!eoHide){
483+
var allHide=true;
484+
$("#icons>div").each(function(){
485+
if(this!=icon[0] && $(this).css("opacity")!="0.2"){
486+
allHide=false;
487+
return false;
488+
}
489+
});
490+
if(allHide){
491+
alert("不能全部禁用!");
492+
return;
493+
}
494+
}
470495
GM_setValue("eoHide"+siteConfig.name, !eoHide);
471496
icon.css("opacity",eoHide?"1":"0.2");
472497
icon.attr("title",(eoHide?i18n.disable:i18n.enable)+i18n[siteConfig.name] );

0 commit comments

Comments
 (0)