TruckMovers / cordova-plugin-remote-injection

DEPRECATED: Cordova plugin to allow a remote site to interact with cordova's javascript APIs when loaded within a cordova app.
Apache License 2.0
91 stars 95 forks source link

Injectable URLs and check window to ensure Cordova is not already defined #42

Open mattlisiv opened 6 years ago

mattlisiv commented 6 years ago

I made a few changes to assist in Cordova-wrapping an SPA, and I thought the changes may be beneficial to someone else.

  1. Add an CRIInjectableSites preference that accepts wildcard URLs. This prevents the javascript from being injected on every request. It seems like a preventive measure to ensure JS is not injected where it is not wanted.

  2. Add a window.cordova == null check to prevent Cordova from being injected multiple times. I have found this occurs when making asynchronous web calls from the initial page.

Let me know what you think. Thanks!