Skip to content

tshaddix/chrome-tab-identifier

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

chrome-tab-identifier

Simple utility to fetch the current tab id inside a content-script.

Install

npm install --save chrome-tab-identifier

Usage

On your event page:

import { TabIdentifier } from "chrome-tab-identifier";

const tabIdentifier = new TabIdentifier();

Then, on your content script:

import { TabIdentifierClient } from "chrome-tab-identifier";

const tabIdClient = new TabIdentifierClient();

tabIdClient.getTabId().then(tabId => {});

Advanced Usage

By default, this package will use a message with the type property set to "__TAB_ID__". If you need to use your own type for whatever reason, you can just pass it as the first argument to both the identifier and the client:

new TabIdentifier("custom-type");
// ...
new TabIdentifierClient("custom-type");

Please note: If you do this and don't use the same string in both the identifier and client, then this won't work.

About

Simple utility to fetch the current tab id inside a content-script.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published