I would like to develop a chrome extension to get the url of each page where I browse.
Here is my code :
manifest.json :
{
"name": "Test",
"version": "0.1",
"manifest_version": 2,
"description": "Test",
"browser_action": {
"default_icon": "img/icon.png",
"default_popup": "popup.html"
},
"permissions": [
"http://*/*",
"https://*/*",
"tabs"
],
"content_scripts": [ {
"js": [ "js/jquery.min.js", "js/app.js" ],
"matches": [ "http://*/*", "https://*/*" ]
} ]
}
And app.js :
window.addEventListener('load', windowLoaded, false);
function windowLoaded() {
chrome.tabs.onUpdated.addListener(function(tabId, info) {
chrome.tabs.query({ currentWindow: true, active: true }, function (tabs) {
var xhr = new XMLHttpRequest();
xhr.open('GET', 'http://...?url=' + tabs[0].url, true);
xhr.onreadystatechange = function() {
// ...
}
xhr.send();
});
});
}
My WS is just saving the url in a file but it's only appening where I inspect the extension with the console.
What is wrong ?
Thank you