Last active
July 31, 2023 18:15
-
-
Save rafalimaz/a4a6f9b1f967b3533d74de5931bad0f8 to your computer and use it in GitHub Desktop.
Verificador de Fake News Whatzapp web
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
const div = document.querySelector('div[role="application"]'); | |
const observer = new MutationObserver(function(mutations) { | |
//console.log(mutations) | |
let found = false; | |
mutations.forEach(function(mutation) { | |
console.log(1) | |
console.log(found) | |
if (found) return true; | |
const spans = mutation.target.querySelectorAll('span'); | |
spans.forEach(function(span) { | |
console.log(2) | |
console.log(found) | |
if (found) return true; | |
if (span && span.textContent === "Encaminhada") { | |
console.log("Encaminhada") | |
alert("Mensagem encaminhada. Verifique fake news") | |
found = true; | |
return true; | |
} | |
}); | |
}); | |
}); | |
observer.observe(div, { childList: true, subtree: true }); | |
// Evento para detectar mensagens encaminhadas quando muda de chat | |
const div = document.querySelector('div.two') | |
console.log(div) | |
const titleObserver = new MutationObserver(function(mutations) { | |
let found = false | |
//console.log(mutations) | |
mutations.forEach(function(mutation){ | |
//console.log(1) | |
//console.log(found) | |
//console.log(mutation) | |
if (found) return true | |
mutation.addedNodes.forEach(function(node) { | |
//console.log(2) | |
//console.log(node) | |
if (node.nodeName === "DIV" && node.id === "main") { | |
//console.log(3) | |
//console.log(node) | |
const divMessages = node.querySelector('div[data-testid="conversation-panel-messages"]') | |
//console.log(3.1) | |
//console.log(divMessages) | |
if (divMessages) { | |
divMessages.addEventListener('scroll', function() { | |
//console.log(3.2) | |
//console.log(divMessages.scrollTop) | |
}) | |
} | |
const spans = divMessages.querySelectorAll('span[data-testid="highly-forwarded-v2"]') | |
console.log(spans) | |
spans.forEach(function(span) { | |
//console.log(3.3) | |
//console.log(found) | |
console.log(3.4) | |
console.log(span) | |
if (found) return true; | |
const spanInternal = span.querySelector('span:contains("Encaminhada")') | |
console.log(3.41) | |
console.log(spanInternal) | |
if (span && (span.textContent === "Encaminhada" || span.textContent === "Encaminhada com frequência")) { | |
console.log(3.5) | |
console.log("Encaminhada") | |
//alert("Mensagem encaminhada. Verifique fake news") | |
found = true; | |
return true; | |
} | |
}); | |
const span = node.querySelector('span[data-testid="conversation-info-header-chat-title"]') | |
if (span) { | |
console.log(4) | |
console.log(span) | |
} | |
} | |
}) | |
}) | |
}) | |
titleObserver.observe(div, { childList: true, subtree: true }) | |
/* | |
1) Ao clicar em um usuário: | |
a) Registrar o evento de verificação de mutation Encaminhada (mostrar alerta se tiver nova) | |
b) Analisar mensagens enviadas anteriormente que não estão salvas no storage (mostrar alerta se tiver nova) | |
c) Desregistrar evento ligado à outro usuário (não precisa, o evento é desregistrado automaticamente) | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment