// ==UserScript== // @name Hide pics // @namespace https://greasyfork.org/ // @version 0.2 // @description Hide pics so that don't be seen by leaders. // @author JMRY // @include *://* // @exclude *://*.google.* // @exclude *://*.conoha.* // @exclude *://*.alipay.* // @grant none // @downloadURL none // ==/UserScript== /* v0.2 - 优化代码结构,提升性能。 - 优化特殊框架下,隐藏图片按钮会被删除的问题。 */ function applyNoPic(){ var show=true; var imgStyle; var style=document.createElement('style'); /*var imgShowListener=setInterval(function(){ if(show==false){ imgStyle=`img{ opacity:0.05; }`; }else{ imgStyle=`img{ }`; } style.innerHTML=`#toggleImg{ position:fixed;left:0px;bottom:0px;z-index:999999;opacity:0; } #toggleImg:hover{ opacity:1; } #toggleImg:active{ opacity:1; } ${imgStyle}`; // var imgList=document.getElementsByTagName('img'); for(var i=0; i{ console.log('Auto init status'); for(var i=0; i<10; i++){ showImg(); } },1000); /*window.onload=()=>{ setTimeout(()=>{ console.log('Auto init status'); for(var i=0; i<10; i++){ showImg(); } },1000); }*/ //$('body').prepend(''); //$('#toggleImg').bind('click',function(){ //showImg(); //}); } (function() { 'use strict'; window.onload=function(){ applyNoPic(); //检测页面中是否存在按钮,如果不存在,则重新插入 var npIntervalCount=0; var npInterval=setInterval(()=>{ if(!document.getElementById(`toggleImg`)){ applyNoPic(); } npIntervalCount++; if(npIntervalCount>=80){ //250*80=20000,即20秒后如果仍然插入不成功,就停止,以提升性能 clearInterval(npInterval); } },250); } })();