addUserScript method

  1. @SupportedPlatforms.new(platforms: [AndroidPlatform(), IOSPlatform(apiName: 'WKUserContentController.addUserScript', apiUrl: 'https://developer.apple.com/documentation/webkit/wkusercontentcontroller/1537448-adduserscript', note: "This method will throw an error if the [PlatformWebViewCreationParams.windowId] has been set. There isn't any way to add/remove user scripts specific to window WebViews. This is a limitation of the native WebKit APIs."), LinuxPlatform(apiName: 'webkit_user_content_manager_add_script', apiUrl: 'https://wpewebkit.org/reference/stable/wpe-webkit-2.0/method.UserContentManager.add_script.html'), MacOSPlatform(apiName: 'WKUserContentController.addUserScript', apiUrl: 'https://developer.apple.com/documentation/webkit/wkusercontentcontroller/1537448-adduserscript', note: "This method will throw an error if the [PlatformWebViewCreationParams.windowId] has been set. There isn't any way to add/remove user scripts specific to window WebViews. This is a limitation of the native WebKit APIs."), WebPlatform(), WindowsPlatform()])
Future<void> addUserScript({
  1. required UserScript userScript,
})

Injects the specified userScript into the webpage’s content.

Officially Supported Platforms/Implementations:

Parameters - Officially Supported Platforms/Implementations:

  • userScript: all platforms

Use the PlatformInAppWebViewController.isMethodSupported method to check if this method is supported at runtime.

Implementation

@SupportedPlatforms(
  platforms: [
    AndroidPlatform(),
    IOSPlatform(
      apiName: 'WKUserContentController.addUserScript',
      apiUrl:
          'https://developer.apple.com/documentation/webkit/wkusercontentcontroller/1537448-adduserscript',
      note:
          "This method will throw an error if the [PlatformWebViewCreationParams.windowId] has been set. There isn't any way to add/remove user scripts specific to window WebViews. This is a limitation of the native WebKit APIs.",
    ),
    LinuxPlatform(
      apiName: 'webkit_user_content_manager_add_script',
      apiUrl:
          'https://wpewebkit.org/reference/stable/wpe-webkit-2.0/method.UserContentManager.add_script.html',
    ),
    MacOSPlatform(
      apiName: 'WKUserContentController.addUserScript',
      apiUrl:
          'https://developer.apple.com/documentation/webkit/wkusercontentcontroller/1537448-adduserscript',
      note:
          "This method will throw an error if the [PlatformWebViewCreationParams.windowId] has been set. There isn't any way to add/remove user scripts specific to window WebViews. This is a limitation of the native WebKit APIs.",
    ),
    WebPlatform(),
    WindowsPlatform(),
  ],
)
Future<void> addUserScript({required UserScript userScript}) {
  throw UnimplementedError(
    '${PlatformInAppWebViewControllerMethod.addUserScript.name} is not implemented on the current platform',
  );
}