YouTube Comment Blacklist

Removes unoriginal YouTube comments.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name            YouTube Comment Blacklist
// @namespace       https://github.com/NatoBoram/youtube-comment-blacklist
// @version         0.0.7
// @license         GPL-3.0-or-later
// @description     Removes unoriginal YouTube comments.
// @author          NatoBoram
// @supportURL      https://github.com/NatoBoram/youtube-comment-blacklist/issues
// @contributionURL https://paypal.me/NatoBoram/5
// @include         https://www.youtube.com/watch*
// @grant           none
// ==/UserScript==

(() => {
	"use strict";

	/** Remove the whole thread, including replies. */
	const removeThread = true;

	/** Turn this on if you want to see which comment has been removed in the console. */
	const debug = false;

	const bannedWords = [
		"always has been",
		"anyone ?",
		"anyone?",
		"can't hurt you",
		"for the likes",
		"funniest shit i've ever seen",
		"he turned himself into a",
		"i felt that",
		"let's be honest",
		"let that sink in",
		"liker",
		"modern problems",
		"no likes",
		"nobody's going to mention",
		"of likes",
		"require modern solutions",
		"speaking the language of gods",
		"this blew up",
		"this comment blew up",
		"tik tok",
		"tiktok",
		"underrated comment",
		"watching this in",
	];

	const bannedRegexes = [
		/\d.? (likes|views)/i, // 3k likes / views
		/\n\n\n/, // More than 2 newlines
		/^(@(\w\s?)+\s)?\d+\s(minute|hour|day|week|year)s?\sago$/i, // 1 week ago
		/^(\w ?)+:(\n| )/im, // someone:
		/^\d+% (\w ?)+\n/im, // 3% useful
		/simp\b/i, // Simp
	];

	// Wait for the comment section to load.
	const interval = setInterval(() => {
		const comments = document.querySelector("ytd-comments");
		if (!comments) { return; }
		clearInterval(interval);

		new MutationObserver(() => {
			comments.querySelectorAll("ytd-comment-thread-renderer").forEach(thread => {
				thread.querySelectorAll("ytd-comment-renderer").forEach(comment => {
					const textContent = comment.querySelector("ytd-expander yt-formatted-string#content-text").textContent
						.toLowerCase()
						.replace("’", "'");

					const found = bannedWords.find(word =>
						textContent.includes(word)) || bannedRegexes.find(regex => textContent.match(regex)
					);

					if (found) {
						if (debug) console.log(`Removing "${found}" : ${textContent}`);

						if (removeThread && comment.parentNode === thread) return thread.remove();
						else return comment.remove();
					}
				});
			});
		}).observe(comments, { childList: true, subtree: true });
	}, 1000);

})();