Skip to content

Commit 58f559f

Browse files
committed
perf(1.10.4): update
1 parent cebe5a6 commit 58f559f

File tree

1 file changed

+52
-48
lines changed

1 file changed

+52
-48
lines changed

removebots.user.js

Lines changed: 52 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// ==UserScript==
22
// @name Hide Bot Comments
33
// @namespace https://theusaf.org
4-
// @version 1.7.5
4+
// @version 1.10.4
55
// @description Removes comments made by bots on websites such as YouTube.
66
// @author theusaf
77
// @match https://www.youtube.com/**
@@ -14,6 +14,7 @@
1414

1515
const SITES = Object.freeze({
1616
YOUTUBE: {
17+
hostname: "www.youtube.com",
1718
checks: [
1819
// starts with too much whitespace
1920
/^\s{2,}/,
@@ -22,33 +23,39 @@ const SITES = Object.freeze({
2223
// all caps and a link
2324
/^(\s*@.+)?\s*[A-Z\s\r\n!]*https:\/\/[^\s]+[A-Z\s\r\n!]*$/,
2425
// A link and a random message afterwards
25-
/^(\s*@.+)?\s*https:\/\/[^\s]+(\n|.|\s)*(It'll blow your mind\.|[dD]on'?t [mM]iss|Bots for u|Finally|💜|fax|only until|Bots are|:]|\.\.?\.$|I found it :|Do not miss this|:\)|Ye[sp] ¤? (true|exactly)/i,
26+
/^(\s*@.+)?\s*https:\/\/[^\s]+(\n|.|\s)*(It'll blow your mind\.|[dD]on'?t [mM]iss|Bots for u|Finally|💜|fax|only until|Bots are|:]|\.\.?\.$|I found it :|Do not miss this|:)|Ye[sp] ¤? (true|exactly)/i,
2627
// word + link
27-
/^(\s*@.+)?\s*(This|[Ww]ow!?)\s*https:\/\/[^\s]+/,
28+
/^(\s*@.+)?\s*(This|[Ww]ow!?|Yo)\s*https:\/\/[^\s]+/,
2829
// phrase + line + link
29-
/(is a brain burner.*|Finally it's here\.?|deceives.*subscribers:\.{1,}|you .*will never love.*|[\u0401\u0451\u0410-\u044f,.:]{15,}.*|HOW STRONG IS KETTLE\?!|EXPOSED:|IS FREAK!|IS GARBAGE!{1,}|shocking truth.*|his subscribers.*|will stop watching.*|yes\.?|THE GAME.*|After watching this video you will never love.*)(\n|\s)(\n|.)*https:\/\/[^\s]+/,
30+
/(is a brain burner.*|10,000.*?!|by having this:|it.?s finally here|Finally it's here\.?|deceives.*subscribers:\.{1,}|you .*will never love.*|[\u0401\u0451\u0410-\u044f,.:]{15,}.*|HOW STRONG IS KETTLE\?!|EXPOSED:|IS FREAK!|IS GARBAGE!{1,}|shocking truth.*|his subscribers.*|will stop watching.*|yes\.?|THE GAME.*|After watching this video you will never love.*)(\n|\s)(\n|.)*https:\/\/[^\s]+/,
3031
// link + random "word"
3132
/^(\s*@.+)?\s*https:\/\/[^\s]+\s*[a-z]+\s*$/,
3233
// link with a star at the end??
3334
/https:\/\/youtu.be\/\w+\*/,
3435
// ...
35-
/SWEET-GIRL|HOTGIRL|PRIVATE S\*X|over 18|Anna is a beautiful girl/i,
36+
/SWEET-GIRL|xvideos|specialdate|HOTGIRL|PRIVATE S\*X|over 18|Anna is a beautiful girl/i,
3637
// suspicious websites
37-
/beautyzone\.\w+|\.cam|lust\.\w+|\.host|\.uno|\.fun|asian\w*\.\w+|\w*teen\.\w+/i,
38+
/beautyzone\.\w+|\.cam|lust\.\w+|[A-Za-z]+\.monster|\.host|\.uno|\.fun|asian\w*\.\w+|she.*\.online|\w*teen\.\w+/i,
3839
// too many "-"
3940
/-{5,}/,
4041
// single, somewhat strange word
41-
/^(Hii|Ye|Bruhh|Aawww?)$/,
42+
/^(Hii|Ye|Bruhh|Aawww?|🆁🆄🅷)$/,
4243
// common phrase
43-
/ ( ´ω ) 💕|I can read you mind brother|SPECIAL FOR YOU|l1ke my v1deo|small channel trying to grow| YouT\*ber|MY CONTENT|MY NAME|at my profile|My video|pedophile😱|MY WORLD RECORD|(^Yes.{0,5}$)|said this to a fan|Read my name|[Mm]y mom.*subscribers|literally begging|MY VIDEOS?|my playlist|fucking cringe|[Dd][Oo][Nn]'?[Tt] read my name/,
44-
// replies to bots
45-
/@Don'?t read my|^(ro)?bot+$/i,
44+
/I MADE.*VIDS|оп му с[hН]аппе[ІlL]|I MAKE.*CONTENT|my videos are better|^I.m better than|I UPLOAD.*VIDEO|I (make|made).*(video|content)| ( ´ω ) 💕|[Oo]mg.*it.?s finally here|I POST [A-Z\s]*?VIDEOS|HATE COMMENT|I can read you mind brother|SPECIAL FOR YOU|l1ke my v1deo|small channel trying to grow| YouT\*ber|MY CONTENT|MY NAME|at my profile|My video|pedophile😱|MY WORLD RECORD|(^Yes.{0,5}$)|said this to a fan|Read my name|[Mm]y mom.*subscribers|r[\.\s]e[\.\s]a[\.\s]d[\.\s]? m[\.\s]y[\.\s]? n[\.\s]a[\.\s]m[\.\s]e|literally begging|MY VIDEOS?|my playlist|fucking cringe|[Dd][Oo][Nn].?[Tt] read my name/,
45+
// replies to bots/about bots
46+
/When the bots|@.*a bot|@Don'?t read my|@.*ok.*[Ii].*wont|remove bots|^(ro)?bot+$|with bots|hi bot|bots.*get worse|why are.*bots|bots.*everywhere|bot repl.*row|there are.*bots|oh god.*bots|report.*bots|so many.*?bots|holy bots|do nothing about bots|bots.*common/i,
4647
// upside down chars
4748
/[ϛƐƖΛɹԀ˥ʞſפƎƆʎʍʌʇɹɯʞɾɥƃɟǝɔɐ]/,
4849
// just a single, weird character
49-
/^.$/,
50+
/^.$/s,
5051
// invisible characters
5152
/[\u200e]/u,
53+
(text) => {
54+
const matches = text.match(/[\u{0E80}-\u{0EFF}]/gu)?.length ?? 0;
55+
if (matches / text.length > 0.5 && /Don.?t tran?slate|Do not tran?slate/i.test(text)) {
56+
return true;
57+
}
58+
},
5259
(text) => {
5360
const charSets = [
5461
{
@@ -72,27 +79,52 @@ const SITES = Object.freeze({
7279
}
7380
}
7481
}
75-
]
82+
],
83+
getCommentText(node) {
84+
if (node.nodeName === "YTD-COMMENT-RENDERER") {
85+
return node.querySelector("#content-text").textContent;
86+
}
87+
}
7688
},
7789
FACEBOOK_EMBED: {
90+
hostname: "www.facebook.com",
7891
checks: [
7992
// "Easy cash" scams
80-
/easy cash|work online|real passive income/,
93+
/easy cash|earning money is very easy.*https?:\/\/|work online|real passive income|(making|paid|get) over \$?\d+k?|salary from home/s,
8194
// Scammy manga sites
82-
/(must check this out|read more:|300 or more chapters|\*{1,} SPOILER ALERT \*{1,}|FREE (TO|FOR) READ).*(\n\s)*(https?:\/\/[^\s]+|\n.\s])+/
95+
/(I liked it.*?recommend|try this manga.*?https?s:\/\/|you should try:|[Ss]hare a cartoon website|top [a-z]*?(comic|website)|there is no cost|try this one out|[Jj]ust read this|you [a-z\s]*?want [a-z\s]*?manga|(tons|a lot) of [a-z\s]*?man[gh][wu]?a|You can find the last part here|looking forward to seeing where this goes|YET ANOTHER RECOMMENDATION|enjoy another manga|I prefer this type of comic|hottest comics|Google led me|will love this one|I like this one: |FEE IS FREE|another [a-z\s]*?manga|WEBSITE[A-Z\s]*FREE|good read|must check this out|read more:|300 or more chapters|comics for free|website [a-z\s]*?manga:|favorite mange which I have read|\*{1,} SPOILER ALERT \*{1,}|FREE ACCESS|FREE (TO|FOR) READ).*(\n\s)*(https?:\/\/[^\s]+|\n.\s])+/,
96+
/geoagiphy\.com|.giphy\.com/,
97+
/(manga|story|site|website).*?:\s?(https?:\/\/[^\s]+|\n.\s])+$/,
98+
// Other weird comments/scams
99+
/look at a website|very popular .*?website|Amazon gift card/,
100+
/^i love sex$/
83101
],
84102
options: {
85103
initialScan: () => {
86104
return document.querySelectorAll(".clearfix");
87105
}
106+
},
107+
getCommentText(node) {
108+
if (node.classList?.contains("clearfix")) {
109+
try {
110+
return node?.lastElementChild
111+
.lastElementChild
112+
.lastElementChild
113+
.firstElementChild
114+
.children[1]
115+
.textContent;
116+
} catch (err) {
117+
return null;
118+
}
119+
}
88120
}
89121
}
90122
}),
91123
site = getCurrentSite(),
92124
commentMutationListener = new MutationObserver((mutations) => {
93125
for (const mutation of mutations) {
94126
for (const node of mutation.addedNodes) {
95-
const text = getCommentText(node, site);
127+
const text = site.getCommentText(node);
96128
if (text) {
97129
if (isCommentLikelyBotComment(text, site)) {
98130
node.style.display = "none";
@@ -135,47 +167,19 @@ function isCommentLikelyBotComment(text, site) {
135167
return false;
136168
}
137169

138-
function getCommentText(node, site) {
139-
switch (site) {
140-
case SITES.YOUTUBE: {
141-
if (node.nodeName === "YTD-COMMENT-RENDERER") {
142-
return node.querySelector("#content-text").textContent;
143-
}
144-
break;
145-
}
146-
case SITES.FACEBOOK_EMBED: {
147-
if (node.classList?.contains("clearfix")) {
148-
try {
149-
return node?.lastElementChild
150-
.lastElementChild
151-
.lastElementChild
152-
.firstElementChild
153-
.children[1]
154-
.textContent;
155-
} catch (err) {
156-
return null;
157-
}
158-
}
159-
}
160-
}
161-
return null;
162-
}
163-
164170
function getCurrentSite() {
165-
switch (location.hostname) {
166-
case "www.youtube.com": {
167-
return SITES.YOUTUBE;
168-
}
169-
case "www.facebook.com": {
170-
return SITES.FACEBOOK_EMBED;
171+
for (let key in SITES) {
172+
const site = SITES[key];
173+
if (location.hostname === site.hostname) {
174+
return site;
171175
}
172176
}
173177
}
174178

175179
if (site.options?.initialScan) {
176180
const items = site.options.initialScan();
177181
for (const node of items) {
178-
const text = getCommentText(node, site);
182+
const text = site.getCommentText(node);
179183
if (text) {
180184
if (isCommentLikelyBotComment(text, site)) {
181185
node.style.display = "none";

0 commit comments

Comments
 (0)