Greasy Fork

Greasy Fork is available in English.

3DGame去广告

3DGame去广告,自用的,广告类型不全

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         3DGame去广告
// @namespace    http://tampermonkey.net/
// @version      2024-07-30
// @description  3DGame去广告,自用的,广告类型不全
// @author      gemail1024
// @license      CC-BY-NC-SA-4.0
// @match        *://*.3dmgame.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=3dmgame.com
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // 定义一个函数,用于移除广告元素
    function removeAds() {
        // 选择常见的广告元素,通过类名、ID或其他选择器
        var adSelectors = [
            '[id*="yxj_fmt_gg"]',// 右下角广告
            '[id*="index_bg_box"]',// 背景广告
            '.Tonglan_785',      // 顶部广告类名Content_R
            '.Content_R',        // 热门
            '.header_wrap',      // 表头
            '.news_warp_c',      // 底部
            '.news_warp_f',      // 底部
            '.commentswrap',     // 底部
            '.fotter.fottertheme',// 底部综合
            'div.content > div:nth-child(2) > a:last-of-type'// 底部推广
        ];

        // 循环所有选择器,选择并移除匹配的元素
        adSelectors.forEach(function(selector) {
            var ads = document.querySelectorAll(selector);
            ads.forEach(function(ad) {
                ad.remove();
            });
        });
    }

    // 可选:每隔一段时间检查并移除动态加载的广告
        setInterval(removeAds, 3000);

})();