Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cordova-plugin-wkuserscript

Package Overview
Dependencies
Maintainers
3
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cordova-plugin-wkuserscript

Cordova WKUserScript Plugin

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
3
Created
Source

title: WKUserScript description: Plugin to add WKUserScripts in WKWebView (iOS).

cordova-plugin-wkuserscript

Plugin to add WKUserScripts in WKWebView (iOS). This can be used to inject JS code to all iframes of your app, for example to intercept window.open calls.

Please notice that this plugin requires you to use WKWebView.

Installation

You can install the plugin using the following command:

cordova plugin add cordova-plugin-wkuserscript

Methods

This plugin defines global WKUserScript object.

Although in the global scope, it is not available until after the deviceready event.

function onDeviceReady() {
    console.log(WKUserScript);
}

document.addEventListener("deviceready", onDeviceReady, false);

WKUserScript.addScript

Adds a user script that will be injected to all iframes of the app (and also to the WebView, be careful with that). You can either pass the JS code to inject or the path of a JS script to inject.

Supported Platforms

  • iOS 11+

Quick Example

WKUserScript.addScript({
    code: 'window.myGlobalVar = "Test";',
}).then(function() {
    // Success.
}).catch(function() {
    // Error.
});

Keywords

FAQs

Package last updated on 03 Aug 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc