Created
January 5, 2020 20:05
-
-
Save sayhicoelho/5ab06a108bfceda3651e85ab65c0d9e6 to your computer and use it in GitHub Desktop.
Remove useless comments from Facebook automatically using Tampermonkey.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Fuck you useless comments! | |
// @namespace http://tampermonkey.net/ | |
// @version 0.0.1 | |
// @description Remove useless comments from Facebook. | |
// @author Renan Coelho <sayhicoelho@gmail.com> | |
// @match https://www.facebook.com/* | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
const interval = 3000 | |
const matches = [ | |
'o naruto é duro as vezes', | |
'comentário teste', | |
'nunca ganhou uma guerra mas nunca perdeu', | |
'quando winston churchill soube do ataque a pearl harbor', | |
'o naruto pode ser meio duro as vezes', | |
'mano troca só a vga e seja feliz o resto ta safe', | |
] | |
function normalize(str) { | |
return str.normalize("NFD").replace(/[\u0300-\u036f]/g, "") | |
} | |
function isUselessComment(str) { | |
for (let m of matches) { | |
if (normalize(str).toLowerCase().includes(normalize(m).toLowerCase())) { | |
return true | |
} | |
} | |
} | |
function searchComments() { | |
const comments = document.querySelectorAll('._7791 li') | |
for (let c of comments) { | |
const textElement = c.querySelector('._3l3x') | |
if (textElement && isUselessComment(textElement.textContent)) { | |
c.remove() | |
} | |
} | |
} | |
setInterval(searchComments, interval) | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment