您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Hide pics so that don't be seen by leaders.
当前为
// ==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 // ==/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<imgList.length; i++){ var img=imgList[i]; if(show==false){ img.classList.add('hideImg'); //$('img').addClass('hideImg'); }else{ img.classList.remove('hideImg'); //$('img').removeClass('hideImg'); } }// },500);*/ var head=document.getElementsByTagName('head')[0]; var body=document.getElementsByTagName('body')[0]; style.innerHTML=`.toggleImg{ position:fixed;left:0px;bottom:0px;z-index:999999;opacity:0; } .toggleImg:hover{ opacity:1; } .toggleImg:active{ opacity:1; } .hideImg{ opacity:0.05; }`; head.appendChild(style); function showImg(){ if(show==false){ document.getElementById('toggleImg').innerHTML='■PIC SHIFT+`'; document.getElementById('toggleImg').style=''; //$('#toggleImg').html('■PIC SHIFT+`'); //$('#toggleImg').css('opacity',''); show=true; }else{ document.getElementById('toggleImg').innerHTML='□PIC SHIFT+`'; document.getElementById('toggleImg').style='opacity:1;'; //$('#toggleImg').html('□PIC SHIFT+`'); //$('#toggleImg').css('opacity',1); show=false; } if(show==false){ imgStyle=`img, video{ opacity:0.05 !important; } body{ opacity:0.5 !important; } *{ font-weight:lighter !important; } .VideoCard{ opacity:0.05 !important; }`; }else{ imgStyle=`img, video{ } body{ } *{ } .VideoCard{ }`; } style.innerHTML=`.toggleImg{ position:fixed;left:0px;bottom:0px;z-index:999999;opacity:0; } .toggleImg:hover{ opacity:1; } .toggleImg:active{ opacity:1; } ${imgStyle}`; } var toggleBu=document.createElement('button'); toggleBu.id='toggleImg'; toggleBu.classList.add('toggleImg'); toggleBu.onclick=function(){ showImg(); }; window.onkeypress=function(e){ //console.log(e); if (e.shiftKey==true && e.code=='Backquote'){ showImg(); } } toggleBu.innerHTML='■PIC SHIFT+`'; body.appendChild(toggleBu); setTimeout(()=>{ 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('<button id="toggleImg" style="">■PIC</button>'); //$('#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); } })();