11// ==UserScript==
22// @name Hide Bot Comments
33// @namespace https://theusaf.org
4- // @version 1.12.1
4+ // @version 1.14.0
55// @description Removes comments made by bots on websites such as YouTube.
66// @author theusaf
77// @match https://www.youtube.com/**
@@ -23,11 +23,11 @@ const SITES = Object.freeze({
2323 // all caps and a link
2424 / ^ ( \s * @ .+ ) ? \s * [ A - Z \s \r \n ! ] * h t t p s : \/ \/ [ ^ \s ] + [ A - Z \s \r \n ! ] * $ / ,
2525 // A link and a random message afterwards
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 \. | T h i s i s w h e r e ( t h e ) ? w o r l d ' ? s f i r s t " ? R i c k R o l l e d " s t a r t e 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 ) * ( H e r e ' ? s t h e f u l l v i d e o . * ? t h i s v i d e o | I t ' l l b l o w y o u r m i n d \. | T h i s i s w h e r e ( t h e ) ? w o r l d ' ? s f i r s t " ? R i c k R o l l e d " s t a r t e 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,
2727 // word + link
2828 / ^ ( \s * @ .+ ) ? \s * ( T h i s | [ W w ] o w ! ? | L a s t f i g h t | Y o ) \s * h t t p s : \/ \/ [ ^ \s ] + / ,
2929 // phrase + line + link
30- / ( L i n k t o t h e c l i p \. ? [ T t ] h a n k m e l a t e r | i s a b r a i n b u r n e r . * | ^ L i n k t o t h e c l i p p a r t 2 | 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 \. ? ( \s * Y E S ) ? | 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+ / ( ( H e r e ' ? s t h e c l i p t h a n k | ^ L i n k t o t h e c l i p | F i n a l l y . * ? t h e c l i p u a l l | i s a b r a i n b u r n e r | L e t ' ? s b e h o n e s t w e | I h a v e b e e n w a i t i n g s o l o n g | b y h a v i n g t h i s : | [ i I ] t .? s f i n a l l y h e r e | F i n a l l y . * i s f i n a l l y h e r e | i t i s f i n a l l y t h e r e | 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 | 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 ) . * | ( y e s \. ? | d e c e i v e s . * s u b s c r i b e r s : \. { 1 , } | F i n a l l y i t ' ? s h e r e \. ? ( \s * Y E S ) ? ) | ^ L i n k t o t h e c l i p p a r t 2 | 1 0 , 0 0 0 . * ? ! | T h i s i s t h e c l i p u a l l . * : | L i n k t o t h e c l i p \. ? [ T t ] h a n k m e l a t e r | ^ H e r e y o u g o | ^ y o \b | f u l l v i d - ) ( \n | \s ) ( \n | .) * h t t p s : \/ \/ [ ^ \s ] + / ,
3131 // various languages + line + link
3232 / ^ [ \p{ Script= Cyrillic} \s ! \. ] * ( \n | \s ) ( \n | .) * h t t p s : \/ \/ ( ( w w w | m ) \. ) ? y o u t u [ ^ \s ] + / iu,
3333 // link + random "word"
@@ -41,11 +41,11 @@ const SITES = Object.freeze({
4141 // too many "-"
4242 / - { 5 , } / ,
4343 // single, somewhat strange word
44- / ^ ( H i i | Y e | B r u h h | A a w w w ? | 🆁 🆄 🅷 \s ? ! * ) $ / ,
44+ / ^ ( [ Ĥ H h ] i i | Y e | [ B b ] r u h h | [ A a ] a w w w ? | 🆁 🆄 🅷 \s ? ! * ) $ / ,
4545 // common phrase
46- / I ' m n o t s c a r e d o f g h o s t s , ? a n d y o u \? | S C R E A M I N G I N H [ E 3 ] L L B E C A U S E M Y .* ?B E T T E R | I M A D E .* V I D S | i s b a d i m a k e b e t t e r c o n t e n t | о п м у с [ 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 / ,
46+ / S e n d ( . | \n ) * ? d i r e c t m e s s a g e ( . | \n ) * ? ( w o n a g i f t | y o u r p r i z e ) | B E C O M E T H E M O S T H A T E D | T h a n k s f o r w a t c h i n g .. ? m e s s a g e s | I ' m n o t s c a r e d o f g h o s t s , ? a n d y o u \? | S C R E A M I N G I N H [ E 3 ] L L B E C A U S E M Y .* ?B E T T E R | I M A D E .* V I D S | i s b a d i m a k e b e t t e r c o n t e n t | о п м у с [ 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 / ,
4747 // replies to bots/about bots
48- / 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 .{ 0 , 15 } 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,
48+ / a l r e a d y b o t s | 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 .{ 0 , 15 } 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,
4949 // upside down chars
5050 / [ ㄥ ϛ ㄣ Ɛ ᄅ Ɩ ⅄ Λ ∩ ┴ ɹ Ԁ ˥ ʞ ſ פ Ⅎ Ǝ Ɔ ∀ ʎ ʍ ʌ ʇ ɹ ɯ ʞ ɾ ᴉ ɥ ƃ ɟ ǝ ɔ ɐ ] / ,
5151 // just a single, weird character
@@ -54,24 +54,28 @@ const SITES = Object.freeze({
5454 / [ \u200e ] / u,
5555 ( text ) => {
5656 const matches = text . match ( / [ \u{0E80} - \u{0EFF} ] / gu) ?. length ?? 0 ;
57- 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 ) ) {
57+ if (
58+ matches / text . length > 0.5 &&
59+ / 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 )
60+ ) {
5861 return true ;
5962 }
6063 } ,
6164 ( text ) => {
6265 const charSets = [
6366 {
64- 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
65- matchPercent : 0.4
67+ regex :
68+ / [ \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
69+ matchPercent : 0.4 ,
6670 } ,
6771 {
6872 regex : / [ ᴀ ʙ ᴄ ᴅ ᴇ ғ ɢ ʜ ɪ ᴊ ᴋ ʟ ᴍ ɴ ᴏ ᴘ ᴏ ̨ ʀ s ᴛ ᴜ ᴠ ᴡ x ʏ ᴢ \s ] / g,
69- matchPercent : 0.5
73+ matchPercent : 0.5 ,
7074 } ,
7175 {
7276 regex : / [ \u{1D538} - \u{1D56B} \u{1D400} - \u{1D433} ] / gu, // math letter symbols
73- matchPercent : 0.3
74- }
77+ matchPercent : 0.3 ,
78+ } ,
7579 ] ;
7680 for ( const check of charSets ) {
7781 const { regex, matchPercent } = check ,
@@ -80,13 +84,37 @@ const SITES = Object.freeze({
8084 return true ;
8185 }
8286 }
83- }
87+ } ,
88+ // Username checks
89+ ( _ , node ) => {
90+ const usernameNode = node . querySelector ( "#author-text" ) ,
91+ userImage = node . querySelector ( "#img" ) ,
92+ username = usernameNode . textContent . trim ( ) ,
93+ BAD_NAMES = [
94+ // remove
95+ / ^ S U B F O R S U B $ / ,
96+ ] ,
97+ HIDE_NAMES = [
98+ // don't remove, just hide pic and name
99+ ] ;
100+ for ( const regex of BAD_NAMES ) {
101+ if ( regex . test ( username ) ) {
102+ return true ;
103+ }
104+ }
105+ for ( const regex of HIDE_NAMES ) {
106+ if ( regex . test ( username ) ) {
107+ userImage . src = "data:application/svg+xml,<svg></svg>" ;
108+ }
109+ }
110+ return false ;
111+ } ,
84112 ] ,
85113 getCommentText ( node ) {
86114 if ( node . nodeName === "YTD-COMMENT-RENDERER" ) {
87115 return node . querySelector ( "#content-text" ) . textContent ;
88116 }
89- }
117+ } ,
90118 } ,
91119 FACEBOOK_EMBED : {
92120 hostname : "www.facebook.com" ,
@@ -99,36 +127,32 @@ const SITES = Object.freeze({
99127 / ( 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 ] ) + $ / ,
100128 // Other weird comments/scams
101129 / 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 / ,
102- / ^ i l o v e s e x $ /
130+ / ^ i l o v e s e x $ / ,
103131 ] ,
104132 options : {
105133 initialScan : ( ) => {
106134 return document . querySelectorAll ( ".clearfix" ) ;
107- }
135+ } ,
108136 } ,
109137 getCommentText ( node ) {
110138 if ( node . classList ?. contains ( "clearfix" ) ) {
111139 try {
112- return node ?. lastElementChild
113- . lastElementChild
114- . lastElementChild
115- . firstElementChild
116- . children [ 1 ]
117- . textContent ;
140+ return node ?. lastElementChild . lastElementChild . lastElementChild
141+ . firstElementChild . children [ 1 ] . textContent ;
118142 } catch ( err ) {
119143 return null ;
120144 }
121145 }
122- }
123- }
146+ } ,
147+ } ,
124148 } ) ,
125149 site = getCurrentSite ( ) ,
126150 commentMutationListener = new MutationObserver ( ( mutations ) => {
127151 for ( const mutation of mutations ) {
128152 for ( const node of mutation . addedNodes ) {
129153 const text = site . getCommentText ( node ) ;
130154 if ( text ) {
131- if ( isCommentLikelyBotComment ( text , site ) ) {
155+ if ( isCommentLikelyBotComment ( text , site , node ) ) {
132156 node . style . display = "none" ;
133157 }
134158 }
@@ -138,20 +162,21 @@ const SITES = Object.freeze({
138162
139163commentMutationListener . observe ( document . body , {
140164 subtree : true ,
141- childList : true
165+ childList : true ,
142166} ) ;
143167
144168/**
145169 * Determines whether a comment is likely spam.
146170 *
147- * @param {String } text The comment's content
148- * @param {Object } site The website the comment is from
171+ * @param {string } text The comment's content
172+ * @param {object } site The website the comment is from
173+ * @param {Node } node
149174 * @return {Boolean }
150175 */
151- function isCommentLikelyBotComment ( text , site ) {
176+ function isCommentLikelyBotComment ( text , site , node ) {
152177 for ( const check of site . checks ) {
153178 if ( typeof check === "function" ) {
154- if ( check ( text ) ) {
179+ if ( check ( text , node ) ) {
155180 console . log ( "Filter Check Failed" ) ;
156181 console . log ( text ) ;
157182 return true ;
@@ -183,7 +208,7 @@ if (site.options?.initialScan) {
183208 for ( const node of items ) {
184209 const text = site . getCommentText ( node ) ;
185210 if ( text ) {
186- if ( isCommentLikelyBotComment ( text , site ) ) {
211+ if ( isCommentLikelyBotComment ( text , site , node ) ) {
187212 node . style . display = "none" ;
188213 }
189214 }
0 commit comments