diff --git a/Sources/MultiRuntime/TabView.swift b/Sources/MultiRuntime/TabView.swift index 16dccbc..08ac87f 100644 --- a/Sources/MultiRuntime/TabView.swift +++ b/Sources/MultiRuntime/TabView.swift @@ -12,6 +12,14 @@ struct TabView: View { let delegate: TabViewDelegate let onPresent: (NSWindow) -> Void + var notificationPolyfill: [WKUserScript] { + guard let url = SettingsView.url(forResource: "notification.js"), + let js = try? String(contentsOf: url) else { + return [] + } + return [WKUserScript(source: js, injectionTime: .atDocumentStart, forMainFrameOnly: false)] + } + var customCss: [WKUserScript] { delegate.tab.customCss.compactMap({ try? Data(contentsOf: $0).base64EncodedString() }).map { css in WKUserScript( @@ -32,14 +40,6 @@ struct TabView: View { } } - var notificationPolyfill: [WKUserScript] { - guard let url = SettingsView.url(forResource: "notification.js"), - let js = try? String(contentsOf: url) else { - return [] - } - return [WKUserScript(source: js, injectionTime: .atDocumentStart, forMainFrameOnly: false)] - } - var cookies: [HTTPCookie] { delegate.tab.customCookies.compactMap { cookie in let properties: [HTTPCookiePropertyKey: Any?] = [ @@ -70,7 +70,7 @@ struct TabView: View { userAgent: delegate.tab.userAgent, ui: delegate.appDelegate, navigation: delegate, - scripts: customCss + customJs + notificationPolyfill, + scripts: notificationPolyfill + customCss + customJs, cookies: cookies, handlers: [ "notificationRequest": notificationRequest,