forked from open-webui/extension
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontent.js
26 lines (23 loc) · 827 Bytes
/
content.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
// Create a div to host the React app
const appDiv = document.createElement("div");
appDiv.id = "extension-app";
document.body.appendChild(appDiv);
// Function to inject a script
function injectScript(file, node) {
const th = document.getElementsByTagName(node)[0];
const s = document.createElement("script");
s.setAttribute("type", "text/javascript");
s.setAttribute("src", file);
th.appendChild(s);
}
// Function to inject a CSS file
function injectCSS(file) {
const link = document.createElement("link");
link.href = file;
link.type = "text/css";
link.rel = "stylesheet";
document.getElementsByTagName("head")[0].appendChild(link);
}
// Inject the CSS and JS files
injectCSS(chrome.runtime.getURL("extension/dist/style.css"));
// injectScript(chrome.runtime.getURL("extension/dist/main.js"), "body");