nothing-innerstorage
v1.0.2
Published
nothing-browser plugin — persists WhatsApp Web localStorage to disk via the C++ PiggyInnerStorage engine
Maintainers
Readme
nothing-innerstorage
Persists WhatsApp Web's localStorage to disk on every write, and re-injects it before WAWeb JS runs on the next restart — so your session survives process restarts without re-scanning the QR code.
The C++ side (PiggyInnerStorage) handles all timing. This package is a thin JS wrapper.
Install
npm install nothing-innerstorageUsage
const piggy = require('nothing-browser').default;
const innerstorage = require('nothing-innerstorage');
await piggy.launch({ mode: 'tab', binary: 'headless' });
await piggy.register('whatsapp', 'https://web.whatsapp.com', { single: true });
await piggy.extend(
innerstorage({ path: './wa-storage.json' })
);
piggy.whatsapp.on('storage:loaded', (d) =>
console.log(`Session restored: ${d.keys} keys`)
);
piggy.whatsapp.on('storage:saved', (d) =>
console.log(`Session saved: ${d.keys} keys`)
);
await piggy.whatsapp.navigate();Options
| Option | Type | Default | Description |
|---|---|---|---|
| path | string | './wa-storage.json' | Where to persist the localStorage snapshot |
| onLoaded | function | — | Called when C++ restores a session into the page |
| onSaved | function | — | Called when C++ snapshots localStorage to disk |
Events
Listen via site.on(event, handler):
| Event | Data | When |
|---|---|---|
| storage:loaded | { tabId, keys } | Every page load — C++ injected saved keys |
| storage:saved | { tabId, keys } | Every localStorage write — C++ saved snapshot |
API (site.storage)
// Read one key from the live page localStorage
const val = await piggy.whatsapp.storage.get('wa-secret-bundle');
// Dump all keys from the live page localStorage
const all = await piggy.whatsapp.storage.dump();
// Wipe localStorage in-page AND delete the snapshot file (forces new QR)
await piggy.whatsapp.storage.clear();How it works
- C++ hooks
loadFinished→ injects saved snapshot intolocalStoragebefore WAWeb reads it - C++ installs a JS hook that intercepts every
localStorage.setItem/removeItem/clearcall - On each change, C++ snapshots the full localStorage and writes it to the file at
path - On restart, snapshot is re-injected — WAWeb sees its session as intact
Notes
- Do not call
session.reload()after installing this plugin — it uses older timing and will conflict - To force a fresh QR scan: call
site.storage.clear()before navigating - This plugin was made upon request and need report any issues found -This plugin is tailord specificaly for whatsap sessions you can use it on other sites but no guarantee of working and that is not a bug sonner or later nothing-storage plugin will be released to solve that
