I am building Firefox addon am trying to detect inline installation of the Firefox extensions. To be clear, installations on the places that are not on the Mozilla
domain. So, when I am on some website, and when I trigger the extension installation (the .xpi
file), I want to redirect the user to some website.
Before that dialog box appears, and if that is not possible, very soon after that, the one for 'installation confirmation', I want to redirect the user.
I am not very familiar with the download
API, and I really don't know where to start. I have tried adding the listener for the downloads, but no result from it.
background.js (and included downloads
in manifest.json
)
function handleCreated(item) {
console.log(item);
}
browser.downloads.onCreated.addListener(handleCreated);
My expectations are to make my addon to recognize that the user is downloading a .xpi
file, and perform redirection on some page when that happens.
Edit: Of the redirection is not possible, then replacing websites .xpi
with another one would do the job also.
Adding to the list of what I have tried.
I have tried to convert the page into the text format using .text()
fro jQuery
, and then search for the URL that has .xpi
at the end. However, this did not work for some cases. Sometimes, some websites are pulling the .xpi
from their own server, using their own API. So it is not a golden solution to my problem.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.