隱藏巴哈原、鐵看板內鬼資訊

以眼不見為淨的方式隱藏巴哈姆特《原神》和《崩壞:星穹鐵道》看板內的內鬼相關文章

目前為 2024-03-01 提交的版本,檢視 最新版本

// ==UserScript==
// @name         隱藏巴哈原、鐵看板內鬼資訊
// @namespace    http://wysalan.com/
// @version      0.2
// @description  以眼不見為淨的方式隱藏巴哈姆特《原神》和《崩壞:星穹鐵道》看板內的內鬼相關文章
// @author       Wysalan
// @match        https://forum.gamer.com.tw/B.php?bsn=36730*
// @match        https://forum.gamer.com.tw/B.php?bsn=72822*
// @match        https://forum.gamer.com.tw/C.php?bsn=36730*
// @match        https://forum.gamer.com.tw/C.php?bsn=72822*
// @match        https://forum.gamer.com.tw/C.php?page=*
// @icon         data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant        none
// @run-at       document-body
// @license      MIT
// ==/UserScript==

(function() {
    "use strict";
    const HSRurl = "https://forum.gamer.com.tw/B.php?bsn=72822&subbsn=8";
    const GSurl = "https://forum.gamer.com.tw/B.php?bsn=36730&subbsn=10";
    let url = document.URL;

    // 延遲處理文章列表的時間(毫秒)
    let delayTime = 100;

    removePostContent();
    let delayMenu = window.setTimeout(( () => createIndicator() ), 100);
    let delayPost = window.setTimeout(( () => removePost() ), delayTime);

    function createIndicator()
    {
        const menuBar = document.querySelector('.BH-menuE');
        const indicator = document.createElement('li');
        const indicatorContent = document.createElement('a');
        indicatorContent.innerHTML = "防內鬼已啟用";
        indicator.appendChild(indicatorContent);
        menuBar.appendChild(indicator);
    }

    function removePost()
    {
        if(url == GSurl || url == HSRurl)
        {
            const table = document.querySelector('.b-list');
            if (table) {
                table.parentNode.removeChild(table);
            }
        }
    }

    function removePostContent()
    {
        const inPost = url.includes("C");
        const inGenshinForum = url.includes("&subbsn=10");
        const inStarRailForum = url.includes("&subbsn=8");

        if (inPost && (inGenshinForum || inStarRailForum))
        {
            warnWindowGenerate();
        }
    }

    function warnWindowGenerate()
    {
        // 警告:底部背景
        const div = document.createElement('div');
        div.className = "leakContentAlert";
        div.style.position = "fixed";
        div.style.top = 0;
        div.style.right = 0;
        div.style.width = "100%";
        div.style.height = "100%";
        div.style.zIndex = 9999;
        div.style.backgroundColor = "#ffffff";
        document.body.appendChild(div);

        // 警告:內容區域
        const contentDiv = document.createElement('div');
        contentDiv.style.position = "absolute";
        contentDiv.style.top = "50%";
        contentDiv.style.left = "50%";
        contentDiv.style.transform = "translate(-50%, -50%)";
        contentDiv.style.fontSize = "24px";
        div.appendChild(contentDiv);

        // 警告:文字區域
        const contentText = document.createElement("p");
        contentText.style.lineHeight = "1.5";
        contentText.innerHTML = "你即將要瀏覽<b>內鬼</b>分類裡的文章<br>如要繼續請選擇「仍要閱讀」<br>否則選擇「返回上一頁」離開或自行關閉此分頁。";

        // 警告:按鈕
        const returnButton = document.createElement("button");
        const allowButton = document.createElement("button");

        // Style for returnButton
        returnButton.style.width = "100px";
        returnButton.style.height = "40px";
        returnButton.style.margin = "10px";
        returnButton.style.backgroundColor = "#04AA6D";
        returnButton.textContent = "返回上一頁";

        // Evnet for returnButton
        returnButton.addEventListener("click", function() {
            window.history.back();
        });

        // Style for allowButton
        allowButton.style.width = "100px";
        allowButton.style.height = "40px";
        allowButton.style.margin = "10px";
        allowButton.style.backgroundColor = "#ff8787";
        allowButton.textContent = "仍要閱讀";

        // Evnet for allowButton
        allowButton.addEventListener("click", function() {
            let warnWindow = document.querySelector('.leakContentAlert');
            if(warnWindow)
            {
                if(window.confirm("確定要瀏覽嗎?這次允許之後還會出現提示。"))
                {
                    warnWindow.style.display = "none";
                }
            }
        });

        // 附加在 contentDiv 底下
        contentDiv.appendChild(contentText);
        contentDiv.appendChild(returnButton);
        contentDiv.appendChild(allowButton);
    }
})();

QingJ © 2025

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