From 2381b2ff6e912f3a8910f5b43f8b7859d719a7b7 Mon Sep 17 00:00:00 2001 From: Marcos Gurgel Date: Fri, 8 Nov 2024 18:54:37 +0000 Subject: [PATCH 1/2] webView inspectable --- Sources/PrivacyDashboard/PrivacyDashboardController.swift | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Sources/PrivacyDashboard/PrivacyDashboardController.swift b/Sources/PrivacyDashboard/PrivacyDashboardController.swift index 9113b0a24..96008cbdf 100644 --- a/Sources/PrivacyDashboard/PrivacyDashboardController.swift +++ b/Sources/PrivacyDashboard/PrivacyDashboardController.swift @@ -95,6 +95,12 @@ public protocol PrivacyDashboardControllerDelegate: AnyObject { public func setup(for webView: WKWebView) { self.webView = webView webView.navigationDelegate = self + + if #available(iOS 16.4, macOS 13.3, *) { + webView.isInspectable = true + } else { + // Fallback on earlier versions + } setupPrivacyDashboardUserScript() loadStartScreen() From 657ede10ef428ecdded23750a0c032660c74632b Mon Sep 17 00:00:00 2001 From: Marcos Gurgel Date: Fri, 8 Nov 2024 19:45:15 +0000 Subject: [PATCH 2/2] Not creating a global json variable --- Sources/PrivacyDashboard/PrivacyDashboardUserScript.swift | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Sources/PrivacyDashboard/PrivacyDashboardUserScript.swift b/Sources/PrivacyDashboard/PrivacyDashboardUserScript.swift index 5adf9e646..7cc484ce9 100644 --- a/Sources/PrivacyDashboard/PrivacyDashboardUserScript.swift +++ b/Sources/PrivacyDashboard/PrivacyDashboardUserScript.swift @@ -332,7 +332,7 @@ final class PrivacyDashboardUserScript: NSObject, StaticUserScript { atbEntry = "" #endif let js = """ - const json = { + window.onGetToggleReportOptionsResponse({ "data": [ { "id": "siteUrl", @@ -356,8 +356,7 @@ final class PrivacyDashboardUserScript: NSObject, StaticUserScript { {"id": "openerContext"}, {"id": "userRefreshCount"}, ] - } - window.onGetToggleReportOptionsResponse(json); + }); """ evaluate(js: js, in: webView) }