Greasy Fork

Greasy Fork is available in English.

rmad

【使用前先看介绍/有问题可反馈】【欢迎一键三连(好评+打赏+收藏),你的支持是作者维护下去的最大动力!】rmad(网页去广告神器):移除常用页面广告,包括动态广告,主要支持:百度搜索、百度文库、百度知道、百度翻译、知乎、哔哩哔哩、C语言中文网、廖雪峰的官方网站、CSDN、简书、博客园、脚本之家、IT屋、OSCHINA.NET在线工具、jsons在线工具等。

当前为 2020-10-29 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         rmad
// @name:en      rmad
// @namespace    http://tampermonkey.net/
// @version      1.4
// @description  【使用前先看介绍/有问题可反馈】【欢迎一键三连(好评+打赏+收藏),你的支持是作者维护下去的最大动力!】rmad(网页去广告神器):移除常用页面广告,包括动态广告,主要支持:百度搜索、百度文库、百度知道、百度翻译、知乎、哔哩哔哩、C语言中文网、廖雪峰的官方网站、CSDN、简书、博客园、脚本之家、IT屋、OSCHINA.NET在线工具、jsons在线工具等。
// @description:en  【使用前先看介绍/有问题可反馈】【欢迎一键三连(好评+打赏+收藏),你的支持是作者维护下去的最大动力!】rmad(网页去广告神器):移除常用页面广告,包括动态广告,主要支持:百度搜索、百度文库、百度知道、百度翻译、知乎、哔哩哔哩、C语言中文网、廖雪峰的官方网站、CSDN、简书、博客园、脚本之家、IT屋、OSCHINA.NET在线工具、jsons在线工具等。
// @author       cc
// @include      *
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    const RECURSION_DURATION = 250;
    if (location.host == 'tool.oschina.net') {
        console.log('ready to remove tool.oschina.net ads...');
        (function recursive () {
            if (document.readyState == 'complete') {
                document.querySelectorAll('div.ad-wrap').forEach(e => e.remove());
            }; // end if
            setTimeout(recursive, RECURSION_DURATION);
        })();
    } else if (location.host == 'www.jsons.cn') {
        console.log('ready to remove www.jsons.cn ads...');
        (function recursive () {
            if (1 || document.readyState == 'complete') {
                document.querySelectorAll('div.google-auto-placed, div.accordion-group ins').forEach(e => e.remove());
            }; // end if
            setTimeout(recursive, RECURSION_DURATION);
        })();
    } else if (location.host.slice(location.host.indexOf('.') + 1) == 'csdn.net') {
        console.log('ready to remove *.csdn.net ads...');
        let head = document.querySelector('head');
        let jq = document.createElement('script');
        jq.src = '//code.jquery.com/jquery-3.5.1.min.js';
        head.insertBefore(jq, head.children.item(0));
        $(document).off('scroll');
        $(window).off('scroll');
        (function recursive () {
            if (1 || document.readyState == 'complete') {
                document.querySelectorAll('.toolbar-advert').forEach(e => e.remove());
                let div_to_remove = [];
                for (let div of document.querySelector('#recommend-right').children) {
                    if (div.classList[0].includes('programmer')) {
                        div_to_remove.push(div);
                    };
                };
                div_to_remove.forEach(e => e.remove());
                document.querySelectorAll('.hot-brand, .google-auto-placed').forEach(e => e.remove());
                let home_wrap = document.querySelector('div.home_wrap');
                if (home_wrap) {
                    let ads = [];
                    for (let child of home_wrap.children) {
                        if (child.id.slice(6, 8) == 'ad') {
                            ads.push(child);
                        };
                    };
                    ads.forEach(e => e.remove());
                };
                document.querySelectorAll('div.top_content div.activity').forEach(e => e.remove());
                document.querySelectorAll('div#footerRightAds, div#recommendAdBox').forEach(e => e.remove());
            }; // end if
            setTimeout(recursive, RECURSION_DURATION);
        })();
    } else if (location.host == 'www.liaoxuefeng.com') {
        console.log('ready to remove www.liaoxuefeng.com ads...');
        (function recursive () {
            if (1 || document.readyState == 'complete') {
                document.querySelectorAll('div#x-sidebar-left-bottom').forEach(e => e.remove());
                document.querySelectorAll('div#x-sidebar-right-bottom').forEach(e => e.remove());
                document.querySelectorAll('div#sponsor-a, div#sponsor-b').forEach(e => e.remove());
            }; // end if
            setTimeout(recursive, RECURSION_DURATION);
        })();
    } else if (location.host.slice(location.host.indexOf('.') + 1) == 'biancheng.net') {
        console.log('ready to remove *.biancheng.net ads...');
        (function recursive () {
            if (1 || document.readyState == 'complete') {
                document.querySelectorAll('div#main > div[style]').forEach(e => e.remove());
                document.querySelectorAll('div#weixin-sidebar').forEach(e => e.remove());
                document.querySelectorAll('div#qq-qun-float').forEach(e => e.remove());
                document.querySelectorAll('div#ad-position-bottom, div#ad-bottom-weixin').forEach(e => e.remove());
                document.querySelectorAll('div#ad-arc-top, div#ad-arc-bottom').forEach(e => e.remove());
            }; // end if
            setTimeout(recursive, RECURSION_DURATION);
        })();
    } else if (location.host == 'www.cnblogs.com') {
        console.log('ready to remove www.cnblogs.com ads...');
        (function recursive () {
            if (document.readyState == 'complete') {
                document.querySelectorAll('#sidebar_ad, #cnblogs_c1, #cnblogs_c2, #cnblogs_b1, #cnblogs_b2, #cnblogs_b3, #cnblogs_b4').forEach(e => e.remove());
            }; // end if
            setTimeout(recursive, RECURSION_DURATION);
        })();
    } else if (location.host == 'www.jianshu.com') {
        console.log('ready to remove www.jianshu.com ads...');
        (function recursive () {
            if (1 || document.readyState == 'complete') {
                document.querySelectorAll('iframe').forEach(e => e.remove());
            }; // end if
            setTimeout(recursive, RECURSION_DURATION);
        })();
    } else if (location.host == 'www.jb51.net') {
        console.log('ready to remove www.jb51.net ads...');
        (function () {
            if (1 || document.readyState == 'complete') {
                document.querySelectorAll('.lbd.clearfix, div.lbd_bot.clearfix, div.pt10.clearfix, div.tonglan, div.softsfwtl, li.da-download').forEach(e => e.remove());
                document.querySelectorAll('div.logom, div.logor, div.main-right, div#con_all, iframe').forEach(e => e.remove());
                document.querySelectorAll('#container .main.clearfix+.main.clearfix, #slider, ul.list.itnews li.first, div.mainlr, .ir').forEach(e => e.remove());
                document.querySelectorAll('#container .main.bgf > .clearfix').forEach(e => e.remove());
                document.querySelectorAll('#container .ithree .clearfix a').forEach(e => e.remove());
            }; // end if
            setTimeout(recursive, RECURSION_DURATION);
        })();
    } else if (location.host == 'www.it1352.com') {
        console.log('ready to remove www.it1352.com ads...');
        (function () {
            if (1 || document.readyState == 'complete') {
                document.querySelectorAll('.google-auto-placed, .adsbygoogle').forEach(e => e.remove());
                document.querySelectorAll('#cs_CFdivdlST_B_0, #cs_CFdivdlST_B_1').forEach(e => e.remove());
                document.querySelectorAll('.content-wrap>.row.hidden-sm.hidden-xs, #content_div1>div.row').forEach(e => e.remove());
                document.querySelectorAll('.contentCenter').forEach(e => e.remove());
                document.querySelectorAll('.container-fluid>.row-fluid>.col-sm-12').forEach(e => e.parentNode.remove());
            }; // end if
            setTimeout(recursive, RECURSION_DURATION);
        })();
    } else if (location.host == 'www.zhihu.com') {
        console.log('ready to remove www.zhihu.com ads...');
        (function recursive () {
            if (1 || document.readyState == 'complete') {
                document.querySelectorAll('div.Pc-feedAd-container').forEach(e => e.parentNode.remove());
                document.querySelectorAll('div.Pc-card.Card, div.Card.AppBanner + div.Card').forEach(e => e.remove());
            }; // end if
            setTimeout(recursive, RECURSION_DURATION);
        })();
    } else if (location.host == 'www.bilibili.com') {
        console.log('ready to remove www.bilibili.com ads...');
        (function recursive () {
            if (document.readyState == 'complete') {
                document.querySelectorAll('div#bili_anime > a').forEach(e => e.remove());
                document.querySelectorAll('div#bili_live > a').forEach(e => e.remove());
                document.querySelectorAll('div#bili_manga > a').forEach(e => e.remove());
                document.querySelectorAll('#activity_vote, #slide_ad, #bannerAd, div.Pc-word').forEach(e => e.remove());
                let reco_list = document.querySelector('#reco_list');
                if (reco_list) {
                    let ads = [];
                    let ad = reco_list.nextElementSibling;
                    while (ad) {
                        ads.push(ad);
                        ad = ad.nextElementSibling;
                    }
                    ads.forEach(e => e.remove());
                }
            }; // end if
            setTimeout(recursive, RECURSION_DURATION);
        })();
    } else if (location.host == 'www.baidu.com') {
        console.log('ready to remove www.baidu.com ads...');
        (function recursive () {
            if (1 || document.readyState == 'complete') {
                document.querySelectorAll('head title').forEach(e => e.text = "谷歌一下,你就知道");
                document.querySelectorAll('img#s_lg_img, img#s_lg_img_new').forEach(e => {
                    if (e.src != 'http://pngimg.com/uploads/google/google_PNG19631.png') {
                        e.src = 'http://pngimg.com/uploads/google/google_PNG19631.png';
                        e.height = 90;
                    };
                });
                document.querySelectorAll('#result_logo > img').forEach(e => {
                    if (e.src != 'http://pngimg.com/uploads/google/google_PNG19631.png') {
                        e.src = 'http://pngimg.com/uploads/google/google_PNG19631.png';
                        e.style.width = '100px';
                        e.style.height = '34px';
                    };
                });
                document.querySelectorAll('#su').forEach(e => e.value = '谷歌一下');
                let content_left = null;
                let ads = [];
                content_left = document.querySelector('div#content_left');
                if (content_left) {
                    for (let div of content_left.children) {
                        if (div.tagName.toLowerCase() == 'div') {
                            if ((div.querySelector('div:last-of-type > font:last-of-type > a > span') || {}).innerText == '广告') {
                                ads.push(div);
                            } else if ((div.querySelector('div:last-of-type span') || {}).innerText == '广告') {
                                ads.push(div);
                            };
                        };
                    };
                    ads.forEach(e => e.remove());
                };
                document.querySelectorAll('div#content_right > div.cr-content').forEach(e => e.remove());
                document.querySelectorAll('#content_right').forEach(e => e.remove());
                document.querySelectorAll('div#s-hotsearch-wrapper').forEach(e => e.remove());
                document.querySelectorAll('#s-top-left, #u1, #s_side_wrapper, #bottom_layer').forEach(e => e.remove());
            }; // end if
            setTimeout(recursive, RECURSION_DURATION);
        })();
    } else if (location.host == 'wenku.baidu.com'){
        console.log('ready to remove wenku.baidu.com ads...');
        (function recursive () {
            if (1 || document.readyState == 'complete') {
                document.querySelectorAll('a.zsj-topbar.mini, div.voucher-pop-tip, div.box.top-search-box>a.page-banner.page-banner-new.log-xsend').forEach(e => e.remove());
                document.querySelectorAll('div.box.top-search-box > a.page-banner.page-banner-new.log-xsend').forEach(e => e.remove());
                document.querySelectorAll('div#fixed-box div.service-entry, div#doc_bottom_wrap').forEach(e => e.remove());
                document.querySelectorAll('div.center div.centerRight').forEach(e => e.remove());
                document.querySelectorAll('div.reader-back2top-wrap a.reader-extensin').forEach(e => e.remove());
                document.querySelectorAll('div.top-ads-banner-wrap.super-vip, div#wkgg, div.convert-tip, div#relative-videos-wrap').forEach(e => e.remove());
                document.querySelectorAll('div.guess-u-like div.structure-info-block.EC_result').forEach(e => e.remove());
                document.querySelectorAll('div.ft > div.kgrecommend-wrap').forEach(e => e.previousElementSibling.remove());
                document.querySelectorAll('div.ft > script+div, div.ft > div.kgrecommend-wrap, div.vip-card').forEach(e => e.remove());
                document.querySelectorAll('div.yuedu-recommend-wrap, div.zsj-toppos, div.search-form-header-content > a, div.doc-aside-border > a').forEach(e => e.remove());
                let container = document.querySelector('div.reader-container-inner');
                if (container) {
                    let ads = [];
                    for (let child of container.children) {
                        if (child.id.slice(0, 11) == 'html-reader') {
                            ads.push(child);
                        };
                    };
                    ads.forEach(e => e.remove());
                };
            }; // end if
            setTimeout(recursive, RECURSION_DURATION);
        })();
    } else if (location.host == 'baike.baidu.com'){
        console.log('ready to remove baike.baidu.com ads...');
        (function recursive () {
            if (1 || document.readyState == 'complete') {
                document.querySelectorAll('div#side_box_unionAd, div.right-ad, div.lemmaWgt-promotion-vbaike').forEach(e => e.remove());
            }; // end if
            setTimeout(recursive, RECURSION_DURATION);
        })();
    } else if (location.host == 'fanyi.baidu.com'){
        console.log('ready to remove fanyi.baidu.com ads...');
        (function recursive () {
            if (1 || document.readyState == 'complete') {
                document.querySelectorAll('div#transOtherRight, div.inner.clearfix').forEach(e => e.remove());
            }; // end if
            setTimeout(recursive, RECURSION_DURATION);
        })();
    } else if (location.host == 'zhidao.baidu.com'){
        console.log('ready to remove zhidao.baidu.com ads...');
        (function recursive () {
            if (1 || document.readyState == 'complete') {
                document.querySelectorAll('div.line.wgt-replyer-line, div.wgt-ads, div.wgt-bottom-union, div.menu-right-section').forEach(e => e.remove());
                document.querySelectorAll('aside#qb-side, button.task-list-button, div.jump-top-box, div.question-number-text-chain').forEach(e => e.remove());
            }; // end if
            setTimeout(recursive, RECURSION_DURATION);
        })();
    }
})();