Reddit Promotion Blocker

Blocks all of the promoted advertisements on Reddit.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Reddit Promotion Blocker
// @namespace    http://tampermonkey.net/
// @version      0.5.3
// @description  Blocks all of the promoted advertisements on Reddit.
// @author       Aiden Charles
// @match        http://reddit.com/*
// @match        https://reddit.com/*
// @match        http://www.reddit.com/*
// @match        https://www.reddit.com/*
// @match        http://old.reddit.com/*
// @match        https://old.reddit.com/*
// @require      https://code.jquery.com/jquery-3.4.1.slim.min.js
// @grant        none
// ==/UserScript==

(function() {
    console.log("Reddit promotion blocker script is running!");

    var observer = new MutationObserver(function() {
        if (window.location.hostname == "old.reddit.com") {
            $("span:contains('promoted')").parent().parent().parent().parent().parent().hide();
            $("div").find(".ad-container").parent().hide();
            $("span").find(".promoted-tag").parent().parent().hide();
        }
        else {
            $("shreddit-ad-post").hide();
            $("shreddit-comments-page-ad").hide();
            $("shreddit-comment-tree-ad").hide();
            $("shreddit-async-loader[bundlename='sidebar_ad']").hide();
            $("shreddit-async-loader[bundlename='feed_announcement']").hide();
            $("div[data-before-content='advertisement']").parent().parent().parent().hide();
            $("div").find(".adsense-ad").parent().parent().hide();
            $("span").find(".promoted-tag").parent().parent().hide();
            $("div").find(".promotedlink").hide();
        }
    });

    observer.observe(document, { childList: true, subtree: true });
})();