// ==UserScript== // @name Anti Peep Screen 防窥屏 // @namespace https://greasyfork.org/zh-CN/scripts/389727 // @version 0.2.1 // @description 当你发现有人窥屏,就按 F2。按 ESC 消除。 // @author Phuker // @match *://*/* // @grant none // @run-at document-start // @downloadURL none // ==/UserScript== /* Forked from jinyu121/ShameEyesdroper.user.js https://gist.github.com/jinyu121/9e028686f35f330b52f60a30e7ef8ba3 */ (function() { 'use strict'; // - - - - - - - - - - Start User Config - - - - - - - - - - var option_text = '有沙雕正在窥屏'; var option_key_activate = 'F2'; var option_key_cancel = 'Escape'; // - - - - - - - - - - End User config - - - - - - - - - - function AntiPeepScreen(){ var svg='\ \ '+ option_text +'\ '; var bg_text="url(data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(svg)))+")"; var div = document.createElement('div'); div.className = 'phuker-anti-peep-screen'; div.style.cssText = '\ z-index:65535;\ position:fixed;\ top:0;\ left:0;\ bottom:0;\ right:0;\ opacity:0.5;\ background-image:' + bg_text + ';\ background-repeat:repeat;\ background-position:center;\ overflow":"hidden";\ '; document.body.appendChild(div); }; function ClearAntiPeepScreen(){ document.getElementsByClassName('phuker-anti-peep-screen')[0].remove(); } document.addEventListener("keydown", function(e){ if(e.key === option_key_activate){ AntiPeepScreen(); document.phuker_anti_peep_level = (document.phuker_anti_peep_level | 0) + 1; } if(e.key === option_key_cancel){ if(document.phuker_anti_peep_level){ ClearAntiPeepScreen(); e.preventDefault(); document.phuker_anti_peep_level -= 1; } } }); })();