Vote count:
0
I tried to replace by a local script the url of scripts loaded by websites.
I tried to channel.redirectTo with data.url and chrome, but doesn't work, so I compared a regex pattern, if true, it will cancel the XHR GET request.
For example
<script src="url/to/script.js"></script>
become
<script src="resource://url/to/new/script.js"></script>
or
<script src="chrome://url/to/new/script.js"></script>
Now I need to replace the url or inject my new script to the page
main.js
var listener = function (event) {
var channel = event.subject.QueryInterface(Ci.nsIHttpChannel);
var match = someFunctionToMatchRegex(channel.URI.spec);
if (match) {
channel.cancel(Cr.NS_BINDING_ABORTED);
}
};
events.on("http-on-modify-request", listener);
asked 1 min ago
Aucun commentaire:
Enregistrer un commentaire