initial script

This commit is contained in:
Matias Carpintini
2025-03-20 16:16:04 -03:00
commit 2edb9a45d3
5 changed files with 156 additions and 0 deletions

20
content-script.js Normal file
View File

@@ -0,0 +1,20 @@
// This script runs in the context of the web page
function injectScript(filePath) {
const script = document.createElement("script");
script.setAttribute("type", "text/javascript");
script.setAttribute("src", chrome.runtime.getURL(filePath));
document.documentElement.appendChild(script);
script.remove();
}
// Check if WhatsApp Web is loaded
function checkWhatsAppLoaded() {
if (document.querySelector("h1")) {
clearInterval(checkInterval);
injectScript("injected.js");
console.log("WhatsApp Heart Favorites extension loaded");
}
}
// Check periodically if WhatsApp is loaded
const checkInterval = setInterval(checkWhatsAppLoaded, 1000);