获取每个标签的网址

时间:2014-02-10 15:51:17

标签: javascript google-chrome-extension

我想开发一个chrome扩展来获取我浏览的每个页面的网址。

这是我的代码:

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://*/*" ]
    } ]
}

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();
    });
});

}

我的WS只是将url保存在一个文件中,但它只是在我用控制台检查扩展名的地方。

有什么问题?

谢谢

0 个答案:

没有答案
相关问题