mirror of
https://github.com/FranP-code/heart-save.git
synced 2025-10-13 00:13:54 +00:00
initial script
This commit is contained in:
20
content-script.js
Normal file
20
content-script.js
Normal 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);
|
||||
Reference in New Issue
Block a user