diff --git a/ios/Classes/Types/UserScript.swift b/ios/Classes/Types/UserScript.swift index c843e2b..fe5a051 100644 --- a/ios/Classes/Types/UserScript.swift +++ b/ios/Classes/Types/UserScript.swift @@ -10,8 +10,19 @@ import WebKit public class UserScript : WKUserScript { var groupName: String? + + var contentWorldWrapper: Any? @available(iOS 14.0, *) - lazy var contentWorld: WKContentWorld = WKContentWorld.page + var contentWorld: WKContentWorld { + get { + if let value = contentWorldWrapper as? WKContentWorld { + return value + } + return .page + } + set { contentWorldWrapper = newValue } + } + public override init(source: String, injectionTime: WKUserScriptInjectionTime, forMainFrameOnly: Bool) { super.init(source: source, injectionTime: injectionTime, forMainFrameOnly: forMainFrameOnly)