tabnab
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i tabnab

Weekly Downloads

1

Version

1.0.1

License

GNU GPLv3

Unpacked Size

802 kB

Total Files

26

Last publish

Collaborators

  • evanagain