Greasy Fork

来自缓存

Anti Peep Screen 防窥屏

当你发现有人窥屏,就按 F2。按 ESC 消除。

目前为 2019-09-17 提交的版本。查看 最新版本

// ==UserScript==
// @name         Anti Peep Screen 防窥屏
// @namespace    https://greasyfork.org/zh-CN/scripts/389727
// @version      0.2
// @description  当你发现有人窥屏,就按 F2。按 ESC 消除。
// @author       Phuker
// @match        *://*/*
// @grant        none
// @run-at       document-start

// ==/UserScript==

/*
Forked from jinyu121/ShameEyesdroper.user.js
https://gist.github.com/jinyu121/9e028686f35f330b52f60a30e7ef8ba3 
*/

(function() {
    'use strict';
    function AntiPeepScreen(){
        var textArray = [
            '有沙雕正在窥屏',
            // '沙雕窥屏中'
        ];
        var randomNumber = Math.floor(Math.random()*textArray.length);
        var svg='<svg width="600" height="400" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">\
        <rect width="100%" height="100%" fill="white" style="opacity:0.6" />\
        <text style="font-weight:bold;opacity:0.4;font-size:72" transform="matrix(.70710678 -.70710678 .70710678 .70710678 -52.549041 262.010392)" x="26.015705" y="220.4375">'+textArray[randomNumber]+'</text>\
        </svg>';
        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 === "F2"){
            AntiPeepScreen();
            document.phuker_anti_peep_level = (document.phuker_anti_peep_level | 0) + 1;
        }
        if(e.key === 'Escape'){
            if(document.phuker_anti_peep_level){
                ClearAntiPeepScreen();
                e.preventDefault();
                document.phuker_anti_peep_level -= 1;
            }
        }
    });
})();