1.0.1 • Published 1 year ago

tabnab v1.0.1

Weekly downloads
-
License
GNU GPLv3
Repository
-
Last release
1 year ago

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")})`);
});
1.0.1

1 year ago

1.0.0

1 year ago