使用 chrome 扩展获取所有窗口中所有选项卡的 url [英] Get the urls of all the tabs in all windows using chrome extension

查看:32
本文介绍了使用 chrome 扩展获取所有窗口中所有选项卡的 url的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

chrome 扩展是否可以使用 chrome 扩展获取所有选项卡中的所有 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"
]

我的问题是找出所有标签中的网址?

My question is to find out the URLs in all 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 扩展获取所有窗口中所有选项卡的 url的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆