我写了 chome 扩展,处理浏览器中的所有请求:
清单.json:
{
"name": "MyExtension",
"version": "0.1",
"description": "All requests are under control!",
"permissions": [
"tabs",
"webRequest",
"http://*/*"
],
"background": {
"scripts": ["background.js"]
},
"manifest_version": 2
}
背景.js:
chrome.webRequest.onCompleted.addListener(
function(details) {
console.log(details);
console.log(chrome.tabs.getCurrent());
},
{urls: ["http://*/*"],
types: ["image"]});
但是现在,我想知道,哪个页面(标签?)创建了这个请求?
例如:
Request 1 - generated by google.com page,
Request 2 - generated by stackoverflow.com.
我该如何解决这个任务?