图寻防窥屏启动

启动后将看不见点击的位置和确定选择按钮,只能通过空格确定

当前为 2023-10-29 提交的版本,查看 最新版本

// ==UserScript==
// @name         图寻防窥屏启动
// @namespace    http://tampermonkey.net/
// @version      1.1
// @description  启动后将看不见点击的位置和确定选择按钮,只能通过空格确定
// @author       Yukejun
// @match        https://tuxun.fun/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    const selectors = [
        'img.leaflet-marker-icon[alt="Marker"][role="button"]',
        '#map > div.leaflet-pane.leaflet-map-pane > div.leaflet-pane.leaflet-shadow-pane > img',
        'div[id^="leaflet-tooltip-"]',
        '#tuxun > div > div > div.confirm'
    ];

    function hideElements() {
        for (const selector of selectors) {
            const elements = document.querySelectorAll(selector);
            elements.forEach(element => {
                if (element) {
                    element.style.display = 'none';
                }
            });
        }
    }

    function showElements() {
        for (const selector of selectors) {
            const elements = document.querySelectorAll(selector);
            elements.forEach(element => {
                if (element) {
                    element.style.display = 'block';
                }
            });
        }
    }

    function checkForTargetSelectorAndToggleElements() {
        const targetElement = document.querySelector('#tuxun > div > div > div.im-view > div.round_result > div.round_result_round_info > div');

        if (targetElement) {
            showElements();
        } else {
            hideElements();
        }
    }

    // Initially hide the elements
    hideElements();




    //防窥屏

    const buttonSelector = '#viewer > div > div:nth-child(14) > div.gmnoprint.gm-bundled-control.gm-bundled-control-on-bottom > div > div';

    const elts = {
        text1: document.createElement("div"),
        text2: document.createElement("div")
    };

    const texts = ["防窥屏启动!"];

    const morphTime = 1;
    const cooldownTime = 0.25;
    let animationDuration = texts.length * (morphTime + cooldownTime);

    let textIndex = texts.length - 1;
    let time = new Date();
    let morph = 0;
    let cooldown = cooldownTime;

    elts.text1.textContent = texts[textIndex % texts.length];
    elts.text2.textContent = texts[(textIndex + 1) % texts.length];

    function doMorph() {
        morph -= cooldown;
        cooldown = 0;

        let fraction = morph / morphTime;

        if (fraction > 1) {
            cooldown = cooldownTime;
            fraction = 1;
        }

        setMorph(fraction);
    }

    function setMorph(fraction) {
        elts.text2.style.filter = `blur(${Math.min(8 / fraction - 8, 100)}px)`;
        elts.text2.style.opacity = `${Math.pow(fraction, 0.4) * 100}%`;

        fraction = 1 - fraction;
        elts.text1.style.filter = `blur(${Math.min(8 / fraction - 8, 100)}px)`;
        elts.text1.style.opacity = `${Math.pow(fraction, 0.4) * 100}%`;

        elts.text1.textContent = texts[textIndex % texts.length];
        elts.text2.textContent = texts[(textIndex + 1) % texts.length];
    }

    function doCooldown() {
        morph = 0;

        elts.text2.style.filter = "";
        elts.text2.style.opacity = "100%";

        elts.text1.style.filter = "";
        elts.text1.style.opacity = "0%";
    }

    function animate() {
        requestAnimationFrame(animate);

        let newTime = new Date();
        let shouldIncrementIndex = cooldown > 0;
        let dt = (newTime - time) / 1000;
        time = newTime;

        cooldown -= dt;

        if (cooldown <= 0) {
            if (shouldIncrementIndex) {
                textIndex++;
            }

            doMorph();
        } else {
            doCooldown();
        }
    }

    // Add styles to animation elements
    Object.values(elts).forEach(elt => {
        elt.style.position = 'fixed';
        elt.style.top = '50%';
        elt.style.left = '50%';
        elt.style.transform = 'translate(-50%, -50%)';
        elt.style.fontSize = '8em';
        elt.style.fontWeight = 'bold';
        elt.style.color = 'white';
        elt.style.textAlign = 'center';
        elt.style.fontFamily = 'fantasy';  // 修改字体样式
        elt.style.zIndex = '9999';
        elt.style.display = 'none'; // Initially hidden
    });
    elts.text1.style.opacity = '0%';

    document.body.appendChild(elts.text1);
    document.body.appendChild(elts.text2);

    function setupButtonListener() {
        const buttonElement = document.querySelector(buttonSelector);
        if (buttonElement) {
            buttonElement.addEventListener('click', () => {
                // Reset the animation
                textIndex = texts.length - 1;
                cooldown = cooldownTime;
                morph = 0;
                elts.text1.textContent = texts[textIndex % texts.length];
                elts.text2.textContent = texts[(textIndex + 1) % texts.length];

                // Show the animation elements
                elts.text1.style.display = 'block';
                elts.text2.style.display = 'block';

                animate();

                // Hide the animation elements after the animation is done
                setTimeout(() => {
                    elts.text1.style.display = 'none';
                    elts.text2.style.display = 'none';
                }, animationDuration * 1000);
            });
        }
    }

    // Attempt to setup the button listener immediately
    setupButtonListener();

    // Use a MutationObserver to check if the button gets added later
    const observer = new MutationObserver(function(mutations) {
        mutations.forEach(function() {
            setupButtonListener();
            checkForTargetSelectorAndToggleElements();
        });
    });


    // Start observing the entire document
    observer.observe(document.body, { childList: true, subtree: true });
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址