🎉 欢迎访问GreasyFork.Org 镜像站!本镜像站由公众号【爱吃馍】搭建,用于分享脚本。联系邮箱📮

Greasy fork 爱吃馍镜像

Greasy Fork is available in English.

NewToki(Manatoki) Ad Blocker

Block ads on NewToki(Manatoki) sites

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(Tôi đã có Trình quản lý tập lệnh người dùng, hãy cài đặt nó!)

🚀 安装遇到问题?关注公众号获取帮助

公众号二维码

扫码关注【爱吃馍】

回复【脚本】获取最新教程和防失联地址

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

🚀 安装遇到问题?关注公众号获取帮助

公众号二维码

扫码关注【爱吃馍】

回复【脚本】获取最新教程和防失联地址

// ==UserScript==
// @name NewToki(Manatoki) Ad Blocker
// @namespace http://tampermonkey.net/
// @version 0.4
// @description Block ads on NewToki(Manatoki) sites
// @author Zerglrisk
// @include *://*.manatoki*/*
// @include *://*.newtoki*/*
// @include *://manatoki*/*
// @include *://newtoki*/*
// @include *://funbe*.com/*
// @grant none
// @run-at document-start
// @license MIT
// ==/UserScript==

(function() {
    'use strict';
    
    function removeAds() {
        // manatoki or newtoki
        if (window.location.href.indexOf('manatoki') > -1 || window.location.href.indexOf('newtoki') > -1) {
            const adLinks = document.querySelectorAll('a[href*="bbs/linkbn.php"]');
            const count = adLinks.length;
            adLinks.forEach(link => {
                if (link.parentNode) {
                    link.parentNode.removeChild(link);
                }
            });
            console.log('newtoki(manatoki) ' + count + ' ads removed');
        }
        
        // funbe
        if (window.location.href.indexOf('funbe') > -1) {
            document.querySelector('div.mobile-banner:not(.section)')?.remove(); // top banner
            document.querySelectorAll('[id^=banner]')?.forEach((e) => e.remove()); // inside banner
            
            // ad-provider.js 스크립트를 포함하는 상위 div 삭제
            const adProviderScripts = document.querySelectorAll('script[src*="ad-provider.js"]');
            adProviderScripts.forEach(script => {
                const parentDiv = script.closest('div');
                if (parentDiv) {
                    parentDiv.remove();
                    console.log('ad-provider.js container div removed');
                }
            });
            
            console.log('funbe ads removed');
        }
    }
    
    console.log('Start NewToki(Manatoki) Ad Blocker');
    
    if (document.readyState === 'loading') {
        document.addEventListener('DOMContentLoaded', removeAds);
    } else {
        removeAds();
    }
    
    const observer = new MutationObserver(removeAds);
    
    function startObserver() {
        if (document.body) {
            observer.observe(document.body, { childList: true, subtree: true });
        } else {
            setTimeout(startObserver, 10);
        }
    }
    
    startObserver();
    // setInterval(removeAds, 1000);
    
})();