Initializer

init(source:injectionTime:forMainFrameOnly:)

Returns an initialized user script that can be added to a user content controller.

Declaration

init(source: String, injectionTime: WKUserScriptInjectionTime, forMainFrameOnly: Bool)

Parameters

source

The script’s source code.

injectionTime

The time when the script should be injected into the webpage. The value must be one of the constants of the enumerated type WKUserScriptInjectionTime.

forMainFrameOnly

A Boolean value indicating whether the script should be injected only into the main frame (true) or into all frames (false).

Return Value

An initialized user script, or nil if the object could not be initialized.