init(source:injectionTime:forMainFrameOnly:)
Creates a user script object that contains the specified source code and attributes.
Declaration
init(source: String, injectionTime: WKUserScriptInjectionTime, forMainFrameOnly: Bool)Parameters
- source:
The script’s source code.
- injectionTime:
The time at which to inject the script into the webpage. For a list of possible values, see Wkuserscriptinjectiontime.
- forMainFrameOnly:
A Boolean value that indicates whether to inject the script into the main frame. Specify True to inject the script only into the main frame, or False to inject it into all frames.
Return Value
An initialized user script, or nil if initialization failed.
Discussion
This method sets the script’s content world to the object in the page property of WKContentWorld.