We are a group of students, and we are attempting to develop a web extension (chrome) for a project. We'd like to develop a web extension which measures the data usage of the Internet browser. To this goal, we want to take the header of a page to have files sizes.
We wanted to test if we could make an alert after receiving the headers.
We have make this test :
var callback = function(details) {
console.log('Les Headers ont ete recus');
alert("BBBBBBBBBBBBBBBBBBBBB");
}
var filter = { urls:
[
'<all_urls>'
]
};
var opt_extraInfoSpec = [];
chrome.webRequest.onHeadersReceived.addListener(
callback, filter, opt_extraInfoSpec
);
We also try this :
function callback() {
console.log('Les Headers ont ete recus');
alert("BBBBBBBBBBBBBBBBBBBBB");
}
var filter = { urls:
[
'<all_urls>'
]
};
var opt_extraInfoSpec = ["requestHeaders"];
chrome.webRequest.onHeadersReceived.addListener(
callback, filter, opt_extraInfoSpec
)
the manifest :
{
"description": "truc écolo",
"manifest_version": 2,
"name": "PolNum",
"version": "0.1",
"icons": {
"48": "icons/icon48.png"
},
"permissions": [
"activeTab",
"http://*/*",
"https://*/*",
"tabs",
"notifications",
"webRequest",
"*://*.google.com/",
"storage"
],
"browser_action": {
"default_popup" :"popup.html",
"default_icon": {
"16": "icons/icon16.png",
"32": "icons/icon32.png"
},
"background": {
"scripts": ["background.js"]
}
}
}
We are a beginner in Javascript
But we have a problem, we never see the alert
and the console.log
. Can we help us ?