N
N
Nadim Zakirov2020-06-30 12:50:38
JavaScript
Nadim Zakirov, 2020-06-30 12:50:38

How to insert your JavaScript code into a website page in an Apache Cordova application?

In regular browsers, injecting your code into sites is easy by creating an extension, but what about Apache Cordova? Are there tools for this? The documentation is porridge, I just can’t read it, but there are no normal guides. In general, it is not clear where to dig. In theory, normal chromium works inside the same place, is it possible to hang real extensions from Chrome on it?

PS The option with a proxy is not suitable, you need to keep a separate server for substituting content, and this is a so-so solution.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nadim Zakirov, 2020-06-30
@zkrvndm

Found the answer . You need to connect the InAppBrowser plugin, after which, you can inject the code into certain pages as follows:

var ref = window.open('http://apache.org', '_blank', 'location=yes');
ref.addEventListener('loadstop', function() {
    ref.executeScript({file: "myscript.js"});
});

If Phone Gap Build is used for the build, then in theory, to connect the plugin, it is enough to specify in the configs:
<plugin name="cordova-plugin-inappbrowser" source="npm" />

But this is not accurate, because I did not check.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question