
Security News
152 Chrome Live Wallpaper Extensions Hid Ad Tracking and Faked Google Search Traffic
A network of 152 Chrome live wallpaper extensions hid ad tracking and made extension-driven traffic look like Google search clicks.
unique-tabid
Advanced tools
This package helps you maintain Unique IDs per tab, takes care of differentiating duplicated tabs/sessions, and also new tabs vs old tabs. This works by using SessionStorage and BroadcastChannel Communication.
This package helps you maintain Unique IDs per tab by taking care of differentiating duplicated tabs/sessions as well. This package can also be leveraged to let you know if a newly loaded tab was duplicated or not, and also get the TabId of the parent tab (the tab from which this was duplicated)
We make use of the following
As soon as a tab is loaded/refreshed, we first check if the SessionStorage contains a TabId.
So whenever a page is loaded/refreshed, we look into SessionStorage and if it returns a valid TabID, we use BroadcastChannel to send a "SEARCH" message to all other tabs, and they would respond with a "FOUND" message if they have the same TabID; None of the tabs would respond if they do not have the TabID we are looking for.
So in this second scenario where a new tab was loaded without duplication, we would not receive any response from the other tabs... So how long to wait till we assume that no duplication has occured...? For now we have kept this as a property that you can configure, with the default set at 1 second.
This means that when we use a debugger and pause execution at the right (or wrong) time, we could mess up this operation.
The default export is a class. Instantiate the class and set the appropriate properties.
npm install --save unique-tabid
// Import
import UniqueTabId from "unique-tabid";
// Instantiate the class and pass some string that identifies your app
const uniqueTabId = new UniqueTabId("testapp");
// Set properties
// Override the wait time for communication
uniqueTabId.WAIT_TIMEOUT = 2000;
// Mandatory: a function that is to be called to generate a unique TabID.
// In this example, I have used the famous uniqid package from NPM
uniqueTabId.uniqIdFunc = uniqid;
// This is the callback that is called when we have the tabId ready, after all the communications
uniqueTabId.tabIdCallback = ({tabId, isNewTab, parentTabId}) => {}
// If used in React, you can call a State Change like shown in the functional React example below.
const [text, setText] = useState("");
uniqueTabId.tabIdCallback = ({tabId, isNewTab, parentTabId}) => setText(`TabId: ${tabId}; New Tab: ${isNewTab}; Duplicated: ${parentTabId !== null ? `Yes. ParentTabId = ${parentTabId}` : "No"}`);
// IMPORTANT: You need to absolutely call the following method at every tab initialization. This is the main process.
uniqueTabId.initTab()
// If used in React, you can call this in the componentDidMount or like in the following functional React equivalent.
useEffect(() => uniqueTabId.initTab(), []);
You can also have a look at the example React App at https://github.com/haricane8133/unique-tabid-client. This was created using create-react-app. Have a look at the changes from the second commit.
I couldn't take part in #hacktoberfest2022. So would this package make it up instead?
It would be awesome to have contributions coming in to remove 'The Catch' mentioned above.
FAQs
This package helps you maintain Unique IDs per tab, takes care of differentiating duplicated tabs/sessions, and also new tabs vs old tabs. This works by using SessionStorage and BroadcastChannel Communication.
The npm package unique-tabid receives a total of 340 weekly downloads. As such, unique-tabid popularity was classified as not popular.
We found that unique-tabid demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
A network of 152 Chrome live wallpaper extensions hid ad tracking and made extension-driven traffic look like Google search clicks.

Company News
Socket’s first CISO brings deep experience securing high-growth SaaS companies as open source supply chain threats accelerate.

Company News
Replit is integrating Socket Firewall into its AI-powered development experience to help protect builders from malicious open source packages.