I want to get all the web request made by a tab and display it on the popup.html.
But the issue i am facing is.for eg. I opened a website in first tab and now I shift to second tab and open another site and shift back to first tab. So now when I shift back to first tab how can I get all the web request which was done by that website in the first tab previously before shifting the tab. So it will have to load again when I shift to the first tab.
I used below code to fetch the selected tab request
chrome.tabs.getSelected(null, function(tab){
chrome.webRequest.onBeforeSendHeaders.addListener(function(details) {
console.log(details);
}, {
urls: ["<all_urls>"]
});
tabs.getSelected is deprecated since Chrome 33, use tabs.query:
var myTabId;
chrome.tabs.query({currentWindow: true, active: true}, function(tabs) {
myTabId = tabs[0].id;
});
Check tabId in the callback of onBeforeSendHeaders:
chrome.webRequest.onBeforeSendHeaders.addListener(function(details) {
if (details.tabId == myTabId) {
console.log(details);
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With