initialUserScripts property

  1. @SupportedPlatforms.new(platforms: [AndroidPlatform(), IOSPlatform(note: """This property will be ignored if the [PlatformWebViewCreationParams.windowId] has been set. There isn't any way to add/remove user scripts specific to iOS window WebViews. This is a limitation of the native WebKit APIs."""), MacOSPlatform(note: """This property will be ignored if the [PlatformWebViewCreationParams.windowId] has been set. There isn't any way to add/remove user scripts specific to iOS window WebViews. This is a limitation of the native WebKit APIs."""), WebPlatform(), WindowsPlatform(), LinuxPlatform(apiName: 'WebKitUserContentManager', apiUrl: 'https://wpewebkit.org/reference/stable/wpe-webkit-2.0/class.UserContentManager.html')])
UnmodifiableListView<UserScript>? initialUserScripts
final

Initial list of user scripts to be loaded at start or end of a page loading. To add or remove user scripts, you have to use the InAppWebViewController's methods such as InAppWebViewController.addUserScript, InAppWebViewController.removeUserScript, InAppWebViewController.removeAllUserScripts, etc.

Officially Supported Platforms/Implementations:

  • Android WebView
  • iOS WKWebView:
    • This property will be ignored if the PlatformWebViewCreationParams.windowId has been set. There isn't any way to add/remove user scripts specific to iOS window WebViews. This is a limitation of the native WebKit APIs.
  • macOS WKWebView:
    • This property will be ignored if the PlatformWebViewCreationParams.windowId has been set. There isn't any way to add/remove user scripts specific to iOS window WebViews. This is a limitation of the native WebKit APIs.
  • Web <iframe> but requires same origin
  • Windows WebView2
  • Linux WPE WebKit (Official API - WebKitUserContentManager)

Use the PlatformWebViewCreationParams.isPropertySupported method to check if this property is supported at runtime.

Implementation

@SupportedPlatforms(
  platforms: [
    AndroidPlatform(),
    IOSPlatform(
      note:
          """This property will be ignored if the [PlatformWebViewCreationParams.windowId] has been set.
There isn't any way to add/remove user scripts specific to iOS window WebViews.
This is a limitation of the native WebKit APIs.""",
    ),
    MacOSPlatform(
      note:
          """This property will be ignored if the [PlatformWebViewCreationParams.windowId] has been set.
There isn't any way to add/remove user scripts specific to iOS window WebViews.
This is a limitation of the native WebKit APIs.""",
    ),
    WebPlatform(),
    WindowsPlatform(),
    LinuxPlatform(
      apiName: 'WebKitUserContentManager',
      apiUrl:
          'https://wpewebkit.org/reference/stable/wpe-webkit-2.0/class.UserContentManager.html',
    ),
  ],
)
final UnmodifiableListView<UserScript>? initialUserScripts;