npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

nothing-cookiesinject

v1.0.2

Published

nothing-browser plugin — injects cookies before page JS runs via the C++ PiggyCookieInject engine, fixing the WAWeb auth race condition

Readme

nothing-cookiesinject

Injects cookies from a JSON file into the browser before page JS runs, solving the WhatsApp Web authentication race condition that SessionManager alone cannot fix.

The C++ side (PiggyCookieInject) hooks loadStarted — not loadFinished — so cookies are in the store before WAWeb's WebSocket auth check fires.


Install

npm install nothing-cookiesinject

Usage

const piggy         = require('nothing-browser').default;
const cookiesinject = require('nothing-cookiesinject');
const fs            = require('fs');

await piggy.launch({ mode: 'tab', binary: 'headless' });
await piggy.register('whatsapp', 'https://web.whatsapp.com', { single: true });

await piggy.extend(
  cookiesinject({ cookieFile: './wa-cookies.json' })
);

// Save cookies after first authentication so they're available on next restart
piggy.whatsapp.on('authenticated', async () => {
  const cookies = await piggy.whatsapp.cookies.list();
  fs.writeFileSync('./wa-cookies.json', JSON.stringify(cookies, null, 2));
  console.log('Cookies saved — next restart will skip the QR code');
});

piggy.whatsapp.on('cookies:injected', (d) =>
  console.log(`${d.count} cookies injected (${d.skipped} skipped)`)
);

await piggy.whatsapp.navigate();

Options

| Option | Type | Default | Description | |---|---|---|---| | cookieFile | string | './wa-cookies.json' | Path to the cookies JSON file | | onInjected | function | — | Called every time C++ injects cookies |


Events

| Event | Data | When | |---|---|---| | cookies:injected | { tabId, count, skipped, file } | Every page load — C++ injected cookies before WAWeb booted |


API (site.cookieinject)

// Re-read file and inject into current tab right now
await piggy.whatsapp.cookieinject.reload();

// Check plugin status
const status = await piggy.whatsapp.cookieinject.status();
// { active: true, file: './wa-cookies.json', injected: 14 }

// Swap cookie file without restarting
await piggy.whatsapp.cookieinject.setFile('./backup-cookies.json');

Cookie file format

The file must be a JSON array. Domain must have a leading dot:

[
  {
    "name": "sid",
    "value": "abc123",
    "domain": ".whatsapp.net",
    "path": "/",
    "secure": true,
    "httpOnly": true,
    "expires": 1735689600
  }
]

⚠️ .whatsapp.net not whatsapp.net — the C++ normalises this automatically, but your exported file should already have the dot to avoid confusion.


Notes

  • To force a fresh QR scan: call site.storage.clear() before navigating (requires nothing-innerstorage)
  • This plugin was made upon request — report any issues found
  • This plugin is tailored specifically for WhatsApp sessions. You can use it on other sites but there is no guarantee it will work, and that is not a bug. A general-purpose nothing-storage plugin will be released in the future to solve that
  • Do not call session.reload() alongside this plugin — it injects at the wrong timing and will conflict
  • On first run, if wa-cookies.json does not exist yet, the plugin loads silently and activates automatically once the file appears after your first QR scan