Revision f2cf9f12
Added by koszko about 1 year ago
| content/content.js | ||
|---|---|---|
| 143 | 143 |
for (const script_contents of scripts) {
|
| 144 | 144 |
const html_ns = "http://www.w3.org/1999/xhtml"; |
| 145 | 145 |
const script = document.createElementNS(html_ns, "script"); |
| 146 |
const load_prom = new Promise( |
|
| 147 |
(...cbs) => [script.onload, script.onerror] = cbs |
|
| 148 |
); |
|
| 146 | 149 |
|
| 147 | 150 |
const blobby_opts = {type: "text/javascript;charset=UTF-8"};
|
| 148 | 151 |
const blobby = new Blob([script_contents], blobby_opts); |
| 149 | 152 |
script.src = URL.createObjectURL(blobby); |
| 150 | 153 |
script.setAttribute("nonce", policy.nonce);
|
| 154 |
|
|
| 151 | 155 |
document.documentElement.append(script); |
| 156 |
await load_prom; |
|
| 152 | 157 |
script.remove(); |
| 153 | 158 |
} |
| 154 | 159 |
} |
Also available in: Unified diff
prevent injected scripts from executing out of order