-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
38 lines (33 loc) · 1.25 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
const scriptElement = document.createElement("script");
// // serving with webpack-dev-server
// scriptElement.src = "http://localhost:3000/bundle.js";
// serving with Vite
scriptElement.src =
"http://localhost:4173/packages/gmail-button-vite-app/assets/extension-helper-SgvZFFyk.js";
(document.head || document.documentElement).appendChild(scriptElement);
// Create a link element
const linkElement = document.createElement("link");
// Set the link element attributes
linkElement.rel = "stylesheet";
linkElement.href =
"http://localhost:4173/packages/gmail-button-vite-app/assets/extension-helper-DWIPkW60.css";
// Append the link element to the document head
document.head.appendChild(linkElement);
// Create a MutationObserver instance
const observer = new MutationObserver((mutationsList, observer) => {
for (let mutation of mutationsList) {
if (mutation.type === "childList") {
var s = document.createElement("script");
s.src = chrome.runtime.getURL("addbutton_script.js");
(document.head || document.documentElement).appendChild(s);
s.onload = function () {
s.remove();
};
}
}
});
// Start observing the document with the configured parameters
observer.observe(document.body, {
childList: true,
subtree: true,
});