Greasy Fork is available in English.
一键切换图片显示隐藏
当前为
// ==UserScript==
// @name 隐藏图片
// @namespace http://greasyfork.icu/
// @version 0.1.1
// @description 一键切换图片显示隐藏
// @author JMRY
// @include *://*
// @grant none
// ==/UserScript==
(function() {
'use strict';
var show=true;
var imgStyle;
var style=document.createElement('style');
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='';
show=true;
}else{
document.getElementById('toggleImg').innerHTML='□PIC SHIFT+`';
document.getElementById('toggleImg').style='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){
if (e.shiftKey==true && e.code=='Backquote'){
showImg();
}
}
toggleBu.innerHTML='■PIC SHIFT+`';
body.appendChild(toggleBu);
window.onload=()=>{
setTimeout(()=>{
console.log('Auto init status');
for(var i=0; i<10; i++){
showImg();
}
},1000);
}
})();