mirror of
https://github.com/FranP-code/heart-save.git
synced 2025-10-13 00:13:54 +00:00
21 lines
667 B
JavaScript
21 lines
667 B
JavaScript
// 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);
|