I have wrote chome extension, that processing all requests in the browser:
manifest.json:
{
"name": "MyExtension",
"version": "0.1",
"description": "All requests are under control!",
"permissions": [
"tabs",
"webRequest",
"http://*/*"
],
"background": {
"scripts": ["background.js"]
},
"manifest_version": 2
}
background.js:
chrome.webRequest.onCompleted.addListener(
function(details) {
console.log(details);
console.log(chrome.tabs.getCurrent());
},
{urls: ["http://*/*"],
types: ["image"]});
But now, I want to know, which page (tab?) has created this request?
for example:
Request 1 - generated by google.com page,
Request 2 - generated by stackoverflow.com.
How can I solve this task?
The following code will fetch tab\page details Who has generated Web Request.
onCompleted Listenerhas a tabId property which identifies tab, and you can retrieve all details of the tab.Sample Output