// ==UserScript== // @name Hide pics // @namespace https://greasyfork.org/ // @version 1.0 // @description Hide pics so that don't be seen by leaders. Refactor version. // @author JMRY // @include *://* // @exclude *://*.google.* // @exclude *://*.conoha.* // @exclude *://*.alipay.* // @grant none // @downloadURL none // ==/UserScript== /* 1.0 20240425 - 重构自Hide Pics 0.3. - 加入background-image的处理。 - 加入网站级别的图片显示/隐藏网站记忆功能。 */ const buttonStyle=` .toggleImg{ position:fixed;left:0px;bottom:0px;z-index:999999;opacity:0; } .toggleImg:hover{ opacity:1; } .toggleImg:active{ opacity:1; } `; const hideStyle=` img, video, .VideoCard{ opacity:0.05 !important; } body{ opacity:0.75 !important; } *{ background-image:none !important; font-weight:lighter !important; } `; let show=getShow(); if(show==undefined || show==null){ show=true; } function getShow(){ return JSON.parse(localStorage.getItem(`hidePicBool`)); } function setShow(bool){ return localStorage.setItem(`hidePicBool`,JSON.stringify(bool)); } function applyNoPic(){ setShow(show); let noPicStyle=document.getElementById(`hideStyleEl`); let toggleBu=document.getElementById(`toggleImg`); if(noPicStyle){ if(show==true){ noPicStyle.innerHTML=``; toggleBu.innerHTML=`☑PIC ↑+\``; toggleBu.style=''; }else{ noPicStyle.innerHTML=hideStyle; toggleBu.innerHTML=`☒PIC ↑+\``; toggleBu.style='opacity:1;'; } } return show; } function toggleShowImg(){ show=!show; applyNoPic(); } function insertNoPic(){ let hideStyleEl=document.createElement('style'); hideStyleEl.id=`hideStyleEl`; hideStyleEl.innerHTML=``; document.head.appendChild(hideStyleEl); let buttonStyleEl=document.createElement('style'); buttonStyleEl.id=`buttonStyleEl`; buttonStyleEl.innerHTML=buttonStyle; document.head.appendChild(buttonStyleEl); let toggleBu=document.createElement('button'); toggleBu.id='toggleImg'; toggleBu.classList.add('toggleImg'); toggleBu.onclick=function(){ toggleShowImg(); }; window.onkeypress=function(e){ if (e.shiftKey==true && e.code=='Backquote'){ toggleShowImg(); } } document.body.appendChild(toggleBu); } (function() { 'use strict'; insertNoPic(); applyNoPic(); })();