Просмотр исходного кода

fix bootstrap call with MV3 (fix #1557)

Gildas 1 год назад
Родитель
Сommit
244654e765
1 измененных файлов с 1 добавлено и 7 удалено
  1. 1 7
      src/core/content/content-bootstrap.js

+ 1 - 7
src/core/content/content-bootstrap.js

@@ -111,13 +111,7 @@ function getContent() {
 }
 
 function executeBootstrap(data) {
-	const scriptElement = document.createElement("script");
-	scriptElement.textContent = "(()=>{" +
-		"document.currentScript.remove();" +
-		"if (document.readyState=='complete') {run()} else {globalThis.addEventListener('load', run)}" +
-		"function run() {this.bootstrap([" + (new Uint8Array(data)).toString() + "])}" +
-		"})()";
-	document.body.appendChild(scriptElement);
+	document.dispatchEvent(new CustomEvent("single-file-bootstrap", { detail: { data } }));
 }
 
 async function onMessage(message) {