tabnab
v1.0.1
Published
Get a list of open Chrome browser tabs with information on their title, URL, and source.
Downloads
3
Readme
Tabnab
Get a list of open Chrome browser tabs with information on their title, URL, and source.
Simple example
import { getActiveChromeTab } from tabnab;
const activeTab = await getActiveChromeTab();
const $ = await activeTab.loadDom();
console.log($('title').text());
Crawl the page
import { getChromeTabs } from tabnab;
const tabs = await getChromeTabs();
const hackerNews = tabs.find(
(tab) => tab.url.hostname === "news.ycombinator.com"
);
if (!hackerNews) {
console.error("No Hacker News tab found.");
return;
}
console.log(hackerNews.title);
const $ = await hackerNews.loadDom();
$(".titleline a").each((i, el) => {
console.log(`- [${$(el).text()}](${$(el).attr("href")})`);
});