|
1 | | -// https://stackoverflow.com/a/70949953 |
2 | | -// https://stackoverflow.com/a/9517879 |
3 | | -// https://stackoverflow.com/a/2920207/11898496 |
4 | | - |
5 | 1 | (async () => { |
6 | | - // https://stackoverflow.com/a/8578840/11898496 |
7 | | - function injectScript( |
8 | | - src, |
9 | | - onload, |
10 | | - type = "text/javascript", |
11 | | - async = false, |
12 | | - defer = false |
13 | | - ) { |
14 | | - let s = document.createElement("script"); |
15 | | - s.type = type; |
16 | | - s.async = async; |
17 | | - s.defer = defer; |
18 | | - s.addEventListener("load", () => { |
19 | | - console.log("Useful-scripts injected " + src); |
20 | | - onload?.(); |
21 | | - s.remove(); |
22 | | - }); |
23 | | - s.src = src; |
24 | | - let head = |
25 | | - document.head || |
26 | | - document.getElementsByTagName("head")[0] || |
27 | | - document.documentElement; |
28 | | - head.insertBefore(s, head.firstChild); |
29 | | - // (document.head || document.documentElement).prepend(s); |
30 | | - } |
31 | | - |
32 | 2 | injectScript( |
33 | 3 | chrome.runtime.getURL( |
34 | 4 | "/scripts/content-scripts/scripts/ufs_global_webpage_context.js" |
|
81 | 51 | console.log("ERROR: ", e); |
82 | 52 | } |
83 | 53 | })(); |
| 54 | + |
| 55 | +// https://stackoverflow.com/a/70949953 |
| 56 | +// https://stackoverflow.com/a/9517879 |
| 57 | +// https://stackoverflow.com/a/2920207/11898496 |
| 58 | + |
| 59 | +// https://stackoverflow.com/a/8578840/11898496 |
| 60 | +function injectScript( |
| 61 | + src, |
| 62 | + onload, |
| 63 | + type = "text/javascript", |
| 64 | + async = false, |
| 65 | + defer = false |
| 66 | +) { |
| 67 | + let s = document.createElement("script"); |
| 68 | + s.type = type; |
| 69 | + s.async = async; |
| 70 | + s.defer = defer; |
| 71 | + s.addEventListener("load", () => { |
| 72 | + console.log("Useful-scripts injected " + src); |
| 73 | + onload?.(); |
| 74 | + s.remove(); |
| 75 | + }); |
| 76 | + s.src = src; |
| 77 | + let head = |
| 78 | + document.head || |
| 79 | + document.getElementsByTagName("head")[0] || |
| 80 | + document.documentElement; |
| 81 | + head.insertBefore(s, head.firstChild); |
| 82 | + // (document.head || document.documentElement).prepend(s); |
| 83 | +} |
0 commit comments