diff --git a/Sources/BrowserServicesKit/ContentScopeScript/ContentScopeUserScript.swift b/Sources/BrowserServicesKit/ContentScopeScript/ContentScopeUserScript.swift index a7c311336..69f058183 100644 --- a/Sources/BrowserServicesKit/ContentScopeScript/ContentScopeUserScript.swift +++ b/Sources/BrowserServicesKit/ContentScopeScript/ContentScopeUserScript.swift @@ -163,20 +163,13 @@ public final class ContentScopeUserScript: NSObject, UserScript, UserScriptMessa config: WebkitMessagingConfig ) -> String { - guard var privacyConfigJson = String(data: privacyConfigurationManager.currentConfig, encoding: .utf8) else { - return "" - } - - if privacyConfigurationManager.internalUserDecider.isInternalUser { - privacyConfigJson = patchPrivacyConfigForDuckPlayerInternal(privacyConfigJson: privacyConfigJson) - } - - guard let userUnprotectedDomains = try? JSONEncoder().encode(privacyConfigurationManager.privacyConfig.userUnprotectedDomains), - let userUnprotectedDomainsString = String(data: userUnprotectedDomains, encoding: .utf8), - let jsonProperties = try? JSONEncoder().encode(properties), - let jsonPropertiesString = String(data: jsonProperties, encoding: .utf8), - let jsonConfig = try? JSONEncoder().encode(config), - let jsonConfigString = String(data: jsonConfig, encoding: .utf8) + guard let privacyConfigJson = String(data: privacyConfigurationManager.currentConfig, encoding: .utf8), + let userUnprotectedDomains = try? JSONEncoder().encode(privacyConfigurationManager.privacyConfig.userUnprotectedDomains), + let userUnprotectedDomainsString = String(data: userUnprotectedDomains, encoding: .utf8), + let jsonProperties = try? JSONEncoder().encode(properties), + let jsonPropertiesString = String(data: jsonProperties, encoding: .utf8), + let jsonConfig = try? JSONEncoder().encode(config), + let jsonConfigString = String(data: jsonConfig, encoding: .utf8) else { return "" } @@ -195,34 +188,6 @@ public final class ContentScopeUserScript: NSObject, UserScript, UserScriptMessa public let injectionTime: WKUserScriptInjectionTime = .atDocumentStart public let forMainFrameOnly: Bool = false public var requiresRunInPageContentWorld: Bool { !self.isIsolated } - - // The Frontend does not support "internal" state for features, so in order to release - // DuckPlayer to internal users, we need to patch the Privacy Config to replace "internal" with "enabled" - // This will be removed once DuckPlayer is released to the public - private static func patchPrivacyConfigForDuckPlayerInternal(privacyConfigJson: String) -> String { - do { - - guard let jsonData = privacyConfigJson.data(using: .utf8) else { return privacyConfigJson } - - guard var jsonObject = try JSONSerialization.jsonObject(with: jsonData, options: []) as? [String: Any] else { - return privacyConfigJson - } - - if var features = jsonObject["features"] as? [String: Any], - var duckPlayer = features["duckPlayer"] as? [String: Any] { - duckPlayer["state"] = "enabled" - features["duckPlayer"] = duckPlayer - jsonObject["features"] = features - } - - let modifiedData = try JSONSerialization.data(withJSONObject: jsonObject, options: .prettyPrinted) - return String(data: modifiedData, encoding: .utf8) ?? privacyConfigJson - - } catch { - return privacyConfigJson - } - } - } @available(macOS 11.0, iOS 14.0, *)