移除导流公众号

去除网页中的“导流公众号”

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         移除导流公众号
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  去除网页中的“导流公众号”
// @author       mio
// @icon         https://openwrite.cn/favicon.ico
// @homepage     https://github.com/findmio/UserScript
// @homepageURL  https://github.com/findmio/UserScript
// @include      http*://*
// @grant        none
// @license      MIT
// ==/UserScript==


(function () {
    "use strict";
    let remove = false;
    let btwTimer = null;

    destroyBTWPlugin();

    function destroyBTWPlugin() {
        // 判断是否有插件
        const hasBTWPlugin = typeof BTWPlugin == "function";

        if (!hasBTWPlugin) {
            return;
        }

        if (!btwTimer) {
            btwTimer = setInterval(() => {
                destroyBTWPlugin();
            }, 1000);
        }

        if (remove) {
            clearInterval(btwTimer);
        }

        const blogId = window.btw?.options?.blogId;

        if (blogId) {
            const tokenKey = `TOKEN_${blogId}`;
            const token = localStorage.getItem(tokenKey);
            if (!token) {
                localStorage.setItem(tokenKey, blogId);
                window.location.reload();
            }
            remove = true;
        }
    }
})();