Skip to content

Commit f8d7bc7

Browse files
committed
refactor: remove redundant wrapper
1 parent 5ac3e42 commit f8d7bc7

1 file changed

Lines changed: 3 additions & 6 deletions

File tree

  • extension/Userscripts Extension/Resources

extension/Userscripts Extension/Resources/content.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,9 @@ function injectCSS(name, code) {
108108
// browser.runtime.sendMessage({name: "API_ADD_STYLE_SYNC", css: code});
109109

110110
// write the css code to head of the document
111-
let wrapper = "const tag = document.createElement(\"style\");\n";
112-
wrapper += `tag.textContent = \`${code}\`;`;
113-
wrapper += "\ndocument.head.appendChild(tag);";
114-
// execute the code directly into the context of the content script (not page context)
115-
// wrapper += "console.log(window.browser)"; // this validates the execution env
116-
return Function(wrapper)();
111+
const tag = document.createElement("style");
112+
tag.textContent = code;
113+
document.head.appendChild(tag);
117114
}
118115

119116
function cspFallback(e) {

0 commit comments

Comments
 (0)