Greasy Fork

No "9GAGGER"

Remove 9gag's terrible promoted posts and some spam

当前为 2023-06-04 提交的版本,查看 最新版本

// ==UserScript==
// @name         No "9GAGGER"
// @namespace    http://tampermonkey.net/
// @version      0.7
// @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];
                let text = post.innerText;
                let author = post.getElementsByClassName("ui-post-creator")[0].innerText.replaceAll("\n", " ").trim();
                console.log(forbiddenAuthorRegExp);
                console.log(author);

                if (author.match(forbiddenAuthorRegExp) != null) {
                    removePost(post);
                } else if (text.match(forbiddenRegExp) != null) {
                    removePost(post);
                }
            } catch (e) {
                console.warn(e);
            }
        }
    }, 100);
    // Your code here...
})();