开发者

Finding all the URL requests from a firefox extension

开发者 https://www.devze.com 2022-12-24 05:16 出处:网络
I am building a firefox extension. In this extension, I want to see the URLs of any new webpage that the user visits. The webpage can be in a different tab or window than the current tab that the user

I am building a firefox extension. In this extension, I want to see the URLs of any new webpage that the user visits. The webpage can be in a different tab or window than the current tab that the user is viewin开发者_如何学编程g (this should also catch the URL of pop-ups). Is there a way to find when firefox makes a GET or POST request and grab the URL?

An alternative that I am trying to avoid is going through all the tabs and manually check to see if they have loaded a new page.

Thanks


Add the permissions "webRequest", "webRequestBlocking", "< all_urls>" in your manifest.json.

In your background.js do this:

chrome.webRequest.onBeforeSendHeaders.addListener(function(details){
    console.log(details.url);
},
{
    urls: ["<all_urls>"]
}, 
["requestHeaders", "blocking"]);


This documentation should help you out.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号