No "9GAGGER"

Remove 9gag's terrible promoted posts and some spam

目前為 2023-06-04 提交的版本,檢視 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         No "9GAGGER"
// @namespace    http://tampermonkey.net/
// @version      0.9
// @description  Remove 9gag's terrible promoted posts and some spam
// @author       You
// @match        https://9gag.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=9gag.com
// @grant        none
// @license MIT
// ==/UserScript==

(function() {
    'use strict';
    let forbiddenAuthors = ["^$", "9gagger", "\\spro"];

    let forbiddenText = [
    "velma", "woke", "lgbt", "rowling", "wahmen", "wahman",
    "dark humor", "dark humour", "joe rog", "rogan", "generation",
    "politics", "climate", "election", "vote", "lula", "bozo", "bolso",
       "news", "modern", "true", "truth",
    "qatar", "world cup",
    "russia", "ukraine", "latest news", "german", "brazil", "brasil", "usa",
        "war", "russo",
    "marvel", "mcu", "ariel", "mermaid",
    "lord of the rings", "rings of power", "lotr",
    "whame", "relationship", "rekt", "black", "white", "opress",
    "nazi", "not funny",
    "religion", "lgb", "gay", "patriarchy", "netflix",
    "politic", "liberal", "democrat", "libs", "groom",
    "diversity", "male", "sigma", "alpha", "beta", "based",
    "politics", "sjw", "trump", "jordan", "peterson", "women", "woman",
    "girl", "alphabet", "lgbt", "latest news", "alt right", "altright",
    "leftist", "socialism", "communism", "china",
    "russia", "ukraine", "covid", "corona", "rona",
    "she-", "groomer", "sex", "censure", "trans",
    "cancel", "elon", "musk", "triggered", "trigger",
    "woke", "repost", "troon", "clown", "tranny",
    "leftard", "netflix", "feminism", "nazi",
    "censored", "censor", "cesored", "racis",
    "gender", "pronoun",
        "savage",
]
    let forbiddenRegExp = new RegExp("(" + forbiddenText.join(")|(") + ")", "gi");
    let forbiddenAuthorRegExp = new RegExp("(" + forbiddenAuthors.join(")|(") + ")", "gi");

        function removePost (post) {
            console.log("Removing bad post: ", post, post.innerText);
            post.parentElement.removeChild(post);
        }

    setInterval(() => {
        let posts = document.getElementsByTagName("article");

        for (let i = 0; i < posts.length; i++) {
            try {
                let post = posts[i];
                if (post.dataset.checkedForShit == "1") {
                    continue; // this is a clean post
                }
                let text = post.innerText;
                let author = post.getElementsByClassName("ui-post-creator")[0].innerText.replaceAll("\n", " ").trim();

                if (author.match(forbiddenAuthorRegExp) != null) {
                    removePost(post);
                } else if (text.match(forbiddenRegExp) != null) {
                    removePost(post);
                }

                post.dataset.checkedForShit = "1";
            } catch (e) {
                console.warn(e);
            }
        }
    }, 100);
    // Your code here...
})();