Skip to content

Commit f0319cb

Browse files
committed
Prepare release 1.7.0
- Adds facebook.com plugin support
1 parent 9ac6b7e commit f0319cb

File tree

2 files changed

+109
-58
lines changed

2 files changed

+109
-58
lines changed

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
## Hide Bot Comments
2-
Hide comments made by annoying bots on various websites
2+
Hide comments made by annoying bots on various websites.
33

44
### Currently Supported Websites:
55
- youtube.com
6+
- facebook.com (comment plugin)<sup><a href="#fb-cp">*</a></sup>
67

78
### How it works:
89
It scans the content of comments for known patterns and phrases. If it finds a match, it will hide the comment. This could create some false positives but should hide most of the annoying ones.
10+
11+
### Issues with certain pages:
12+
<a name="fb-cp"></a>
13+
**facebook.com (comment plugin)**
14+
- Your script manager may prevent this from running on these pages. You may need to remove the Facebook blacklist in your script manager's settings.

removebots.user.js

Lines changed: 102 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,88 @@
11
// ==UserScript==
22
// @name Hide Bot Comments
33
// @namespace https://theusaf.org
4-
// @version 1.6.3
4+
// @version 1.7.0
55
// @description Removes comments made by bots on websites such as YouTube.
66
// @author theusaf
77
// @match https://www.youtube.com/**
8+
// @match https://www.facebook.com/plugins/comments.php*
9+
// @match https://www.facebook.com/plugins/feedback.php*
810
// @copyright 2022 theusaf
911
// @license MIT
1012
// @grant none
1113
// ==/UserScript==
1214

1315
const SITES = Object.freeze({
14-
YOUTUBE: [
15-
// starts with too much whitespace
16-
/^\s{2,}/,
17-
// only links and other punctuation
18-
/^(\s*@.+)?\s*(https:\/\/[^\s]+)(https:\/\/[^\s]+|\n.\s])+$/,
19-
// all caps and a link
20-
/^(\s*@.+)?\s*[A-Z\s\r\n!]*https:\/\/[^\s]+[A-Z\s\r\n!]*$/,
21-
// A link and a random message afterwards
22-
/^(\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,
23-
// word + link
24-
/^(\s*@.+)?\s*(This|[Ww]ow!?)\s*https:\/\/[^\s]+/,
25-
// phrase + line + link
26-
/(Finally it's here\.?|deceives.*subscribers:\.{1,}|[\u0401\u0451\u0410-\u044f,.:]{15,}.*|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]+/,
27-
// link + random "word"
28-
/^(\s*@.+)?\s*https:\/\/[^\s]+\s*[a-z]+\s*$/,
29-
// link with a star at the end??
30-
/https:\/\/youtu.be\/\w+\*/,
31-
// ...
32-
/PRIVATE S\*X|over 18|Anna is a beautiful girl/i,
33-
// suspicious websites
34-
/beautyzone\.\w+|\.cam|lust\.\w+|\.host|asian\w*\.\w+|\w*teen\.\w+/i,
35-
// too many "-"
36-
/-{5,}/,
37-
// single, somewhat strange word
38-
/^(Hii|Ye|Bruhh|Aawww?)$/,
39-
// common phrase
40-
/ ( ´ω ) 💕|I can read you mind brother|SPECIAL FOR YOU|l1ke my v1deo|small channel trying to grow| YouT\*ber|MY CONTENT|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/,
41-
// replies to bots
42-
/@Don'?t read my|^(ro)?bot+$/i,
43-
// upside down chars
44-
/[ϛƐƖΛɹԀ˥ʞſפƎƆʎʍʌʇɹɯʞɾɥƃɟǝɔɐ]/,
45-
// just a single, weird character
46-
/^.$/,
47-
(text) => {
48-
const charSets = [
49-
{
50-
regex: /[\u{fe27}-\u{fe2f}\u{1df5}-\u{1dff}\u{1dc0}-\u{1de6}\u{1ab0}-\u{1abe}\u{0300}-\u{0333}\u{0339}-\u{033f}\u{0346}-\u{034a}\u{034b}-\u{034e}\u{0350}-\u{0357}\u{0358}-\u{035b}]/gu, // weird combining characters
51-
matchPercent: 0.4
52-
},
53-
{
54-
regex: /[ʙғɢʜɪʟɴ̨ʀsxʏ\s]/g,
55-
matchPercent: 0.5
56-
},
57-
{
58-
regex: /[\u{1D538}-\u{1D56B}\u{1D400}-\u{1D433}]/gu, // math letter symbols
59-
matchPercent: 0.3
60-
},
61-
];
62-
for (const check of charSets) {
63-
const { regex, matchPercent } = check,
64-
matches = text.match(regex)?.length ?? 0;
65-
if (matches / text.length > matchPercent && text.length > 10) {
66-
return true;
16+
YOUTUBE: {
17+
checks: [
18+
// starts with too much whitespace
19+
/^\s{2,}/,
20+
// only links and other punctuation
21+
/^(\s*@.+)?\s*(https:\/\/[^\s]+)(https:\/\/[^\s]+|\n.\s])+$/,
22+
// all caps and a link
23+
/^(\s*@.+)?\s*[A-Z\s\r\n!]*https:\/\/[^\s]+[A-Z\s\r\n!]*$/,
24+
// 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+
// word + link
27+
/^(\s*@.+)?\s*(This|[Ww]ow!?)\s*https:\/\/[^\s]+/,
28+
// phrase + line + link
29+
/(Finally it's here\.?|deceives.*subscribers:\.{1,}|[\u0401\u0451\u0410-\u044f,.:]{15,}.*|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+
// link + random "word"
31+
/^(\s*@.+)?\s*https:\/\/[^\s]+\s*[a-z]+\s*$/,
32+
// link with a star at the end??
33+
/https:\/\/youtu.be\/\w+\*/,
34+
// ...
35+
/PRIVATE S\*X|over 18|Anna is a beautiful girl/i,
36+
// suspicious websites
37+
/beautyzone\.\w+|\.cam|lust\.\w+|\.host|asian\w*\.\w+|\w*teen\.\w+/i,
38+
// too many "-"
39+
/-{5,}/,
40+
// single, somewhat strange word
41+
/^(Hii|Ye|Bruhh|Aawww?)$/,
42+
// 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 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,
46+
// upside down chars
47+
/[ϛƐƖΛɹԀ˥ʞſפƎƆʎʍʌʇɹɯʞɾɥƃɟǝɔɐ]/,
48+
// just a single, weird character
49+
/^.$/,
50+
(text) => {
51+
const charSets = [
52+
{
53+
regex: /[\u{fe27}-\u{fe2f}\u{1df5}-\u{1dff}\u{1dc0}-\u{1de6}\u{1ab0}-\u{1abe}\u{0300}-\u{0333}\u{0339}-\u{033f}\u{0346}-\u{034a}\u{034b}-\u{034e}\u{0350}-\u{0357}\u{0358}-\u{035b}]/gu, // weird combining characters
54+
matchPercent: 0.4
55+
},
56+
{
57+
regex: /[ʙғɢʜɪʟɴ̨ʀsxʏ\s]/g,
58+
matchPercent: 0.5
59+
},
60+
{
61+
regex: /[\u{1D538}-\u{1D56B}\u{1D400}-\u{1D433}]/gu, // math letter symbols
62+
matchPercent: 0.3
63+
},
64+
];
65+
for (const check of charSets) {
66+
const { regex, matchPercent } = check,
67+
matches = text.match(regex)?.length ?? 0;
68+
if (matches / text.length > matchPercent && text.length > 10) {
69+
return true;
70+
}
6771
}
6872
}
73+
]
74+
},
75+
FACEBOOK_EMBED: {
76+
checks: [
77+
// "Easy cash" scams
78+
/easy cash|work online/
79+
],
80+
options: {
81+
initialScan: () => {
82+
return document.querySelectorAll(".clearfix");
83+
}
6984
}
70-
]
85+
}
7186
}),
7287
site = getCurrentSite(),
7388
commentMutationListener = new MutationObserver((mutations) => {
@@ -95,8 +110,8 @@ commentMutationListener.observe(document.body, {
95110
* @param {Object} site The website the comment is from
96111
* @return {Boolean}
97112
*/
98-
function isCommentLikelyBotComment(text, siteChecks) {
99-
for (const check of siteChecks) {
113+
function isCommentLikelyBotComment(text, site) {
114+
for (const check of site.checks) {
100115
if (typeof check === "function") {
101116
if (check(text)) {
102117
console.log("Filter Check Failed");
@@ -122,6 +137,21 @@ function getCommentText(node, site) {
122137
if (node.nodeName === "YTD-COMMENT-RENDERER") {
123138
return node.querySelector("#content-text").textContent;
124139
}
140+
break;
141+
}
142+
case SITES.FACEBOOK_EMBED: {
143+
if (node.classList?.contains("clearfix")) {
144+
try {
145+
return node?.lastElementChild
146+
.lastElementChild
147+
.lastElementChild
148+
.firstElementChild
149+
.children[1]
150+
.textContent;
151+
} catch (err) {
152+
return null;
153+
}
154+
}
125155
}
126156
}
127157
return null;
@@ -132,5 +162,20 @@ function getCurrentSite() {
132162
case "www.youtube.com": {
133163
return SITES.YOUTUBE;
134164
}
165+
case "www.facebook.com": {
166+
return SITES.FACEBOOK_EMBED;
167+
}
168+
}
169+
}
170+
171+
if (site.options?.initialScan) {
172+
const items = site.options.initialScan();
173+
for (const node of items) {
174+
const text = getCommentText(node, site);
175+
if (text) {
176+
if (isCommentLikelyBotComment(text, site)) {
177+
node.style.display = "none";
178+
}
179+
}
135180
}
136181
}

0 commit comments

Comments
 (0)