From 6cf6eb04f2715bffc132892676da5f8d94de01aa Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Fri, 25 Mar 2022 15:25:25 +0100 Subject: [PATCH] Avoid polluting the global namespace Closes #6 --- main.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/main.ts b/main.ts index 29e4d5c..aa09838 100644 --- a/main.ts +++ b/main.ts @@ -100,9 +100,11 @@ class CustomFrameView extends ItemView { for (let other of require("electron").remote.getCurrentWebContents().mainFrame.frames) { if (frame.src.contains(new URL(other.url).host)) { other.executeJavaScript(` - let style = document.createElement("style"); - style.textContent = \`${this.frame.customCss}\`; - document.head.appendChild(style); + (() => { + let style = document.createElement("style"); + style.textContent = \`${this.frame.customCss}\`; + document.head.appendChild(style); + })(); `); } }