瀏覽代碼

call document.appendChild instead of documentElement.appendChild

Gildas 7 年之前
父節點
當前提交
affba5c8f3
共有 3 個文件被更改,包括 3 次插入3 次删除
  1. 1 1
      lib/hooks/hooks-frame.js
  2. 1 1
      lib/hooks/hooks.js
  3. 1 1
      lib/lazy/content/content-lazy-loader.js

+ 1 - 1
lib/hooks/hooks-frame.js

@@ -28,7 +28,7 @@ this.hooksFrame = this.hooksFrame || (() => {
 	if (document instanceof HTMLDocument) {
 		const scriptElement = document.createElement("script");
 		scriptElement.textContent = `(${hook.toString()})()`;
-		document.documentElement.appendChild(scriptElement);
+		document.appendChild(scriptElement);
 		scriptElement.remove();
 		addEventListener(NEW_FONT_FACE_EVENT, event => fontFaces.push(event.detail));
 	}

+ 1 - 1
lib/hooks/hooks.js

@@ -25,7 +25,7 @@ this.hooks = this.hooks || (() => {
 	if (document instanceof HTMLDocument) {
 		const scriptElement = document.createElement("script");
 		scriptElement.textContent = `(${hookPushState.toString()})()`;
-		document.documentElement.appendChild(scriptElement);
+		document.appendChild(scriptElement);
 		scriptElement.remove();
 	}
 

+ 1 - 1
lib/lazy/content/content-lazy-loader.js

@@ -81,7 +81,7 @@ this.lazyLoader = this.lazyLoader || (() => {
 	function injectScript(path) {
 		const scriptElement = document.createElement(SCRIPT_TAG_NAME);
 		scriptElement.src = browser.runtime.getURL(path);
-		document.documentElement.appendChild(scriptElement);
+		document.appendChild(scriptElement);
 		scriptElement.onload = () => scriptElement.remove();
 	}