⚡️域名封锁⚡️🔥🔥🔥🔥Bilibili and other entreatment website blocker🔥🔥🔥🔥

Custom redirect script with customization options

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         ⚡️域名封锁⚡️🔥🔥🔥🔥Bilibili and other entreatment website blocker🔥🔥🔥🔥
// @namespace    http://tampermonkey.net/
// @version      3.4.1.1
// @description  Custom redirect script with customization options
// @author       You
// @match        *://*/*
// @grant        GM_setValue
// @grant        GM_getValue
// @run-at       document-start
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    let isRedirectEnabled = GM_getValue('isRedirectEnabled', true);
    let blockURLs = GM_getValue('blockURLs', ['https://www.bilibili.com']);
    let redirectURL = GM_getValue('redirectURL', 'https://www.google.com');
    let isLightFlowEnabled = GM_getValue('isLightFlowEnabled', true);

    function blockPage(url) {
        if (window.location.href.includes(url) && isRedirectEnabled && !window.location.href.includes(redirectURL)) {
            document.documentElement.innerHTML = '';
            document.documentElement.style.background = 'white';
            window.stop();
            window.location.replace(redirectURL);
        }
    }

    blockURLs.forEach(blockPage);

    function restoreDefaults() {
        GM_setValue('blockURLs', ['https://www.bilibili.com']);
        GM_setValue('redirectURL', 'https://www.google.com');
        alert('已恢复到默认设置');
    }

    window.addEventListener('DOMContentLoaded', () => {
        if (window.location.href !== 'https://www.google.com/') return;

        const addButton = document.createElement('div');
        addButton.style.position = 'fixed';
        addButton.style.bottom = '10px';
        addButton.style.right = '10px';
        addButton.style.width = '50px';
        addButton.style.height = '50px';
        addButton.style.backgroundColor = '#FFC0CB'; // 默认颜色为粉色
        addButton.style.borderRadius = '50%';
        addButton.style.cursor = 'pointer';
        addButton.style.zIndex = '9999';
        addButton.style.display = 'flex';
        addButton.style.alignItems = 'center';
        addButton.style.justifyContent = 'center';
        addButton.style.fontSize = '24px';
        addButton.textContent = '♾️';

        // 光流效果
        if (isLightFlowEnabled) {
            addButton.style.animation = 'lightflow 5s infinite alternate';
        }

        addButton.addEventListener('click', () => {
            toggleContainer.style.display = toggleContainer.style.display === 'none' ? 'block' : 'none';
        });

        const toggleContainer = document.createElement('div');
        toggleContainer.style.position = 'fixed';
        toggleContainer.style.bottom = '70px';
        toggleContainer.style.right = '10px';
        toggleContainer.style.backgroundColor = 'white';
        toggleContainer.style.border = '1px solid black';
        toggleContainer.style.padding = '10px';
        toggleContainer.style.borderRadius = '10px';
        toggleContainer.style.zIndex = '9999';
        toggleContainer.style.display = 'none';

        const toggleSwitch = document.createElement('input');
        toggleSwitch.type = 'checkbox';
        toggleSwitch.id = 'redirectToggle';
        toggleSwitch.checked = isRedirectEnabled;

        toggleSwitch.addEventListener('change', () => {
            isRedirectEnabled = toggleSwitch.checked;
            GM_setValue('isRedirectEnabled', toggleSwitch.checked);
        });

        const label = document.createElement('label');
        label.htmlFor = 'redirectToggle';
        label.textContent = 'Enable Custom Redirect';

        const urlTable = document.createElement('table');

        blockURLs.forEach((url, index) => {
            const row = document.createElement('tr');
            const cell = document.createElement('td');
            const input = document.createElement('input');
            input.type = 'text';
            input.value = url;
            input.style.marginTop = '5px';
            input.addEventListener('change', () => {
                blockURLs[index] = input.value;
                GM_setValue('blockURLs', blockURLs);
            });
            cell.appendChild(input);
            row.appendChild(cell);
            urlTable.appendChild(row);
        });

        const addRowButton = document.createElement('button');
        addRowButton.textContent = 'Add New Row';
        addRowButton.style.marginTop = '10px';
        addRowButton.addEventListener('click', () => {
            blockURLs.push('');
            GM_setValue('blockURLs', blockURLs);

            const newRow = document.createElement('tr');
            const newCell = document.createElement('td');
            const newInput = document.createElement('input');
            newInput.type = 'text';
            newInput.style.marginTop = '5px';
            newInput.addEventListener('change', () => {
                blockURLs[blockURLs.length - 1] = newInput.value;
                GM_setValue('blockURLs', blockURLs);
            });
            newCell.appendChild(newInput);
            newRow.appendChild(newCell);
            urlTable.appendChild(newRow);
        });

        // 创建恢复默认设置按钮
        let restoreDefaultsButton = document.createElement('button');
        restoreDefaultsButton.innerText = '恢复默认设置';
        restoreDefaultsButton.addEventListener('click', restoreDefaults);

        const lightFlowToggle = document.createElement('input');
        lightFlowToggle.type = 'checkbox';
        lightFlowToggle.id = 'lightFlowToggle';
        lightFlowToggle.checked = isLightFlowEnabled;

        lightFlowToggle.addEventListener('change', () => {
            isLightFlowEnabled = lightFlowToggle.checked;
            GM_setValue('isLightFlowEnabled', lightFlowToggle.checked);

            if (lightFlowToggle.checked) {
                addButton.style.animation = 'lightflow 5s infinite alternate';
            } else {
                addButton.style.animation = '';
            }
        });

        const lightFlowLabel = document.createElement('label');
        lightFlowLabel.htmlFor = 'lightFlowToggle';
        lightFlowLabel.textContent = 'Enable Light Flow Effect';

        toggleContainer.appendChild(toggleSwitch);
        toggleContainer.appendChild(label);
        toggleContainer.appendChild(urlTable);
        toggleContainer.appendChild(addRowButton);
        toggleContainer.appendChild(restoreDefaultsButton);
        toggleContainer.appendChild(lightFlowToggle);
        toggleContainer.appendChild(lightFlowLabel);
        addButton.textContent = '🤡';

        // 添加光流效果的CSS
        const style = document.createElement('style');
        style.type = 'text/css';
        style.innerHTML = `
            @keyframes lightflow {
                0% { background-color: #FFC0CB; }
                25% { background-color: #FF4500; }
                50% { background-color: #8A2BE2; }
                75% { background-color: #E6A2D2; }
                100% { background-color: #FFC0CB; }
            }
        `;
        document.head.appendChild(style);

        document.body.appendChild(addButton);
        document.body.appendChild(toggleContainer);
    });
})();