使用chrome扩展名获取所有窗口中所有选项卡的URL [英] Get the urls of all the tabs in all windows using chrome extension
本文介绍了使用chrome扩展名获取所有窗口中所有选项卡的URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是否可能使用扩展名来获取所有标签页中的所有URL(使用扩展名)?
Is this possible for chrome extension to get all the URLs in all tabs using chrome extension ?
使用此代码获取当前标签页的url
I have got the url of current Tab using this code
chrome.tabs.getSelected(null, function(tab) {
tabUrl = tab.url;
alert(tabUrl);
});
我们需要在manifest.json文件中拥有以下权限
We need the following permissions in manifest.json file
"permissions": [
"tabs"
]
我的问题是找出所有标签中的URL?
My question is to find out the URLs in all tabs ?
推荐答案
像这样:
You could do something like this:
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扩展名获取所有窗口中所有选项卡的URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文