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/**
1414
1515const 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 ! ] * h t t p s : \/ \/ [ ^ \s ] + [ A - Z \s \r \n ! ] * $ / ,
2425 // A link and a random message afterwards
25- / ^ ( \s * @ .+ ) ? \s * h t t p s : \/ \/ [ ^ \s ] + ( \n | .| \s ) * ( I t ' l l b l o w y o u r m i n d \. | [ d D ] o n ' ? t [ m M ] i s s | B o t s f o r u | F i n a l l y | 💜 | f a x | o n l y u n t i l | B o t s a r e | : ] | \. \. ? \. $ | I f o u n d i t : | D o n o t m i s s t h i s | : \ )| Y e [ s p ] ¤ ? ( t r u e | e x a c t l y ) / i,
26+ / ^ ( \s * @ .+ ) ? \s * h t t p s : \/ \/ [ ^ \s ] + ( \n | .| \s ) * ( I t ' l l b l o w y o u r m i n d \. | [ d D ] o n ' ? t [ m M ] i s s | B o t s f o r u | F i n a l l y | 💜 | f a x | o n l y u n t i l | B o t s a r e | : ] | \. \. ? \. $ | I f o u n d i t : | D o n o t m i s s t h i s | : ) | Y e [ s p ] ¤ ? ( t r u e | e x a c t l y ) / i,
2627 // word + link
27- / ^ ( \s * @ .+ ) ? \s * ( T h i s | [ W w ] o w ! ? ) \s * h t t p s : \/ \/ [ ^ \s ] + / ,
28+ / ^ ( \s * @ .+ ) ? \s * ( T h i s | [ W w ] o w ! ? | Y o ) \s * h t t p s : \/ \/ [ ^ \s ] + / ,
2829 // phrase + line + link
29- / ( i s a b r a i n b u r n e r .* | F i n a l l y i t ' s h e r e \. ? | d e c e i v e s .* s u b s c r i b e r s : \. { 1 , } | y o u .* w i l l n e v e r l o v e .* | [ \u0401 \u0451 \u0410 - \u044f , . : ] { 15 , } .* | H O W S T R O N G I S K E T T L E \? ! | E X P O S E D : | I S F R E A K ! | I S G A R B A G E ! { 1 , } | s h o c k i n g t r u t h .* | h i s s u b s c r i b e r s .* | w i l l s t o p w a t c h i n g .* | y e s \. ? | T H E G A M E .* | A f t e r w a t c h i n g t h i s v i d e o y o u w i l l n e v e r l o v e .* ) ( \n | \s ) ( \n | .) * h t t p s : \/ \/ [ ^ \s ] + / ,
30+ / ( i s a b r a i n b u r n e r .* | 1 0 , 0 0 0 . * ? ! | b y h a v i n g t h i s : | i t . ? s f i n a l l y h e r e | F i n a l l y i t ' s h e r e \. ? | d e c e i v e s .* s u b s c r i b e r s : \. { 1 , } | y o u .* w i l l n e v e r l o v e .* | [ \u0401 \u0451 \u0410 - \u044f , . : ] { 15 , } .* | H O W S T R O N G I S K E T T L E \? ! | E X P O S E D : | I S F R E A K ! | I S G A R B A G E ! { 1 , } | s h o c k i n g t r u t h .* | h i s s u b s c r i b e r s .* | w i l l s t o p w a t c h i n g .* | y e s \. ? | T H E G A M E .* | A f t e r w a t c h i n g t h i s v i d e o y o u w i l l n e v e r l o v e .* ) ( \n | \s ) ( \n | .) * h t t p s : \/ \/ [ ^ \s ] + / ,
3031 // link + random "word"
3132 / ^ ( \s * @ .+ ) ? \s * h t t p s : \/ \/ [ ^ \s ] + \s * [ a - z ] + \s * $ / ,
3233 // link with a star at the end??
3334 / h t t p s : \/ \/ y o u t u .b e \/ \w + \* / ,
3435 // ...
35- / S W E E T - G I R L | H O T G I R L | P R I V A T E S \* X | o v e r 1 8 | A n n a i s a b e a u t i f u l g i r l / i,
36+ / S W E E T - G I R L | x v i d e o s | s p e c i a l d a t e | H O T G I R L | P R I V A T E S \* X | o v e r 1 8 | A n n a i s a b e a u t i f u l g i r l / i,
3637 // suspicious websites
37- / b e a u t y z o n e \. \w + | \. c a m | l u s t \. \w + | \. h o s t | \. u n o | \. f u n | a s i a n \w * \. \w + | \w * t e e n \. \w + / i,
38+ / b e a u t y z o n e \. \w + | \. c a m | l u s t \. \w + | [ A - Z a - z ] + \. m o n s t e r | \. h o s t | \. u n o | \. f u n | a s i a n \w * \. \w + | s h e . * \. o n l i n e | \w * t e e n \. \w + / i,
3839 // too many "-"
3940 / - { 5 , } / ,
4041 // single, somewhat strange word
41- / ^ ( H i i | Y e | B r u h h | A a w w w ? ) $ / ,
42+ / ^ ( H i i | Y e | B r u h h | A a w w w ? | 🆁 🆄 🅷 ) $ / ,
4243 // common phrase
43- / ( ● ´ ω ` ● ) ✨ 💕 | I c a n r e a d y o u m i n d b r o t h e r | S P E C I A L F O R Y O U | l 1 k e m y v 1 d e o | s m a l l c h a n n e l t r y i n g t o g r o w | Y o u T \* b e r | M Y C O N T E N T | M Y N A M E | a t m y p r o f i l e | M y v i d e o | p e d o p h i l e 😱 | M Y W O R L D R E C O R D | ( ^ Y e s .{ 0 , 5 } $ ) | s a i d t h i s t o a f a n | R e a d m y n a m e | [ M m ] y m o m .* s u b s c r i b e r s | l i t e r a l l y b e g g i n g | M Y V I D E O S ? | m y p l a y l i s t | f u c k i n g c r i n g e | [ D d ] [ O o ] [ N n ] ' ? [ T t ] r e a d m y n a m e / ,
44- // replies to bots
45- / @ D o n ' ? t r e a d m y | ^ ( r o ) ? b o t + $ / i,
44+ / I M A D E . * V I D S | о п м у с [ h Н ] а п п е [ І l L ] | I M A K E . * C O N T E N T | m y v i d e o s a r e b e t t e r | ^ I . m b e t t e r t h a n | I U P L O A D . * V I D E O | I ( m a k e | m a d e ) . * ( v i d e o | c o n t e n t ) | ( ● ´ ω ` ● ) ✨ 💕 | [ O o ] m g . * i t . ? s f i n a l l y h e r e | I P O S T [ A - Z \s ] * ? V I D E O S | H A T E C O M M E N T | I c a n r e a d y o u m i n d b r o t h e r | S P E C I A L F O R Y O U | l 1 k e m y v 1 d e o | s m a l l c h a n n e l t r y i n g t o g r o w | Y o u T \* b e r | M Y C O N T E N T | M Y N A M E | a t m y p r o f i l e | M y v i d e o | p e d o p h i l e 😱 | M Y W O R L D R E C O R D | ( ^ Y e s .{ 0 , 5 } $ ) | s a i d t h i s t o a f a n | R e a d m y n a m e | [ M m ] y m o m .* s u b s c r i b e r s | r [ \. \s ] e [ \. \s ] a [ \. \s ] d [ \. \s ] ? m [ \. \s ] y [ \. \s ] ? n [ \. \s ] a [ \. \s ] m [ \. \s ] e | l i t e r a l l y b e g g i n g | M Y V I D E O S ? | m y p l a y l i s t | f u c k i n g c r i n g e | [ D d ] [ O o ] [ N n ] . ? [ T t ] r e a d m y n a m e / ,
45+ // replies to bots/about bots
46+ / W h e n t h e b o t s | @ . * a b o t | @ D o n ' ? t r e a d m y | @ . * o k . * [ I i ] . * w o n t | r e m o v e b o t s | ^ ( r o ) ? b o t + $ | w i t h b o t s | h i b o t | b o t s . * g e t w o r s e | w h y a r e . * b o t s | b o t s . * e v e r y w h e r e | b o t r e p l . * r o w | t h e r e a r e . * b o t s | o h g o d . * b o t s | r e p o r t . * b o t s | s o m a n y . * ? b o t s | h o l y b o t s | d o n o t h i n g a b o u t b o t s | b o t s . * c o m m o n / 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 && / D o n .? t t r a n ? s l a t e | D o n o t t r a n ? s l a t e / 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- / e a s y c a s h | w o r k o n l i n e | r e a l p a s s i v e i n c o m e / ,
93+ / e a s y c a s h | e a r n i n g m o n e y i s v e r y e a s y . * h t t p s ? : \/ \/ | w o r k o n l i n e | r e a l p a s s i v e i n c o m e | ( m a k i n g | p a i d | g e t ) o v e r \$ ? \d + k ? | s a l a r y f r o m h o m e / s ,
8194 // Scammy manga sites
82- / ( m u s t c h e c k t h i s o u t | r e a d m o r e : | 3 0 0 o r m o r e c h a p t e r s | \* { 1 , } S P O I L E R A L E R T \* { 1 , } | F R E E ( T O | F O R ) R E A D ) .* ( \n \s ) * ( h t t p s ? : \/ \/ [ ^ \s ] + | \n .\s ] ) + /
95+ / ( I l i k e d i t .* ?r e c o m m e n d | t r y t h i s m a n g a .* ?h t t p s ? s : \/ \/ | y o u s h o u l d t r y : | [ S s ] h a r e a c a r t o o n w e b s i t e | t o p [ a - z ] * ?( c o m i c | w e b s i t e ) | t h e r e i s n o c o s t | t r y t h i s o n e o u t | [ J j ] u s t r e a d t h i s | y o u [ a - z \s ] * ?w a n t [ a - z \s ] * ?m a n g a | ( t o n s | a l o t ) o f [ a - z \s ] * ?m a n [ g h ] [ w u ] ? a | Y o u c a n f i n d t h e l a s t p a r t h e r e | l o o k i n g f o r w a r d t o s e e i n g w h e r e t h i s g o e s | Y E T A N O T H E R R E C O M M E N D A T I O N | e n j o y a n o t h e r m a n g a | I p r e f e r t h i s t y p e o f c o m i c | h o t t e s t c o m i c s | G o o g l e l e d m e | w i l l l o v e t h i s o n e | I l i k e t h i s o n e : | F E E I S F R E E | a n o t h e r [ a - z \s ] * ?m a n g a | W E B S I T E [ A - Z \s ] * F R E E | g o o d r e a d | m u s t c h e c k t h i s o u t | r e a d m o r e : | 3 0 0 o r m o r e c h a p t e r s | c o m i c s f o r f r e e | w e b s i t e [ a - z \s ] * ?m a n g a : | f a v o r i t e m a n g e w h i c h I h a v e r e a d | \* { 1 , } S P O I L E R A L E R T \* { 1 , } | F R E E A C C E S S | F R E E ( T O | F O R ) R E A D ) .* ( \n \s ) * ( h t t p s ? : \/ \/ [ ^ \s ] + | \n .\s ] ) + / ,
96+ / g e o a g i p h y \. c o m | .g i p h y \. c o m / ,
97+ / ( m a n g a | s t o r y | s i t e | w e b s i t e ) .* ?: \s ? ( h t t p s ? : \/ \/ [ ^ \s ] + | \n .\s ] ) + $ / ,
98+ // Other weird comments/scams
99+ / l o o k a t a w e b s i t e | v e r y p o p u l a r .* ?w e b s i t e | A m a z o n g i f t c a r d / ,
100+ / ^ i l o v e s e x $ /
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-
164170function 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
175179if ( 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