Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

chrome.webrequest.onbeforerequest.addlistener for Firefox?

Google Chrome contains some functionality in its chrome.webrequest API (e.g., http://developer.chrome.com/extensions/samples.html#12a7bf1490a26359eadf10917e37c5b9 ) that can be used to redirect certain URLs to a specified web page. The Chrome extension uses a blocking event listener (chrome.webRequest.onBeforeRequest.addListener) and does a redirect for targeted URLs. How might I do something similar in a FireFox Add-on?

like image 827
Janka Avatar asked Jun 14 '13 16:06

Janka


1 Answers

This question was asked for a very long time. I'm not sure if there was solution for this at then. But now we can do such things using Firefox WebExtensions API.

It is compatible with Chrome in most APIs (though some of them are not supported, or not fully supported).

For this very specific question, Firefox WebExtensions support webRequest API, you can use it like the way in Chrome:

chrome.webRequest.onBeforeRequest.addListener(...);

Note: To use webRequest API, you must have the webRequest permission in your manifest.json.

like image 68
zhm Avatar answered Oct 21 '22 02:10

zhm