0

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

skurty
  • 738
  • 1
  • 11
  • 26
  • 1
    Hmm I answered a question very similar to this a few hours ago, check it out here http://stackoverflow.com/questions/21657319/detect-youtube-video-change-with-injected-javascript – 1337holiday Feb 10 '14 at 21:56
  • It uses a background script that listens for URL changes in various tabs, then it sends that URL change information to your content script. Create a new app, paste the code and give that a try. – 1337holiday Feb 10 '14 at 21:57

0 Answers0