这是可能的Chrome扩展获得使用Chrome扩展所有选项卡所有的网址吗?
我有当前选项卡的使用此代码的网址
chrome.tabs.getSelected(null, function(tab) {
tabUrl = tab.url;
alert(tabUrl);
});
我们需要在manifest.json档案以下权限
"permissions": [
"tabs"
]
我的问题是要找出所有选项卡中的网址?
这是可能的Chrome扩展获得使用Chrome扩展所有选项卡所有的网址吗?
我有当前选项卡的使用此代码的网址
chrome.tabs.getSelected(null, function(tab) {
tabUrl = tab.url;
alert(tabUrl);
});
我们需要在manifest.json档案以下权限
"permissions": [
"tabs"
]
我的问题是要找出所有选项卡中的网址?
你可以这样做:
chrome.windows.getAll({populate:true},function(windows){
windows.forEach(function(window){
window.tabs.forEach(function(tab){
//collect all of the urls here, I will just log them instead
console.log(tab.url);
});
});
});
随着chrome.tabs.query方法,你也可以简单地做,
chrome.tabs.query({},function(tabs){
console.log("\n/////////////////////\n");
tabs.forEach(function(tab){
console.log(tab.url);
});
});