Skip to content

Commit ef7efbd

Browse files
committed
🐛 修复xml文档无法加载脚本的问题 #211
1 parent e4bd5d4 commit ef7efbd

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/runtime/background/runtime.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -436,11 +436,11 @@ export default class Runtime extends Manager {
436436
chrome.tabs.executeScript(sender.tabId, {
437437
frameId: sender.frameId,
438438
code: `(function(){
439-
let temp = document.createElement('script');
439+
let temp = document.createElementNS("http://www.w3.org/1999/xhtml", "script");
440440
temp.setAttribute('type', 'text/javascript');
441441
temp.innerHTML = "${injectedSource}";
442442
temp.className = "injected-js";
443-
document.documentElement.appendChild(temp)
443+
document.documentElement.appendChild(temp);
444444
temp.remove();
445445
}())`,
446446
runAt: "document_start",
@@ -475,11 +475,11 @@ export default class Runtime extends Manager {
475475
chrome.tabs.executeScript(sender.tabId!, {
476476
frameId: sender.frameId,
477477
code: `(function(){
478-
let temp = document.createElement('script');
478+
let temp = document.createElementNS("http://www.w3.org/1999/xhtml", "script");
479479
temp.setAttribute('type', 'text/javascript');
480480
temp.innerHTML = "${script.code}";
481481
temp.className = "injected-js";
482-
document.documentElement.appendChild(temp)
482+
document.documentElement.appendChild(temp);
483483
temp.remove();
484484
}())`,
485485
runAt,

0 commit comments

Comments
 (0)