inspect-browser-storage
With this package you can locally and programmatically modify the LocalStorage and SessionStorage of a browser. This also applies to an Browser based Electron app.
The default paths currently belong to chromium, other browsers will be added in the next versions. But you can set dbPath option for other databases.
Usage
Install package:
# npm
npm install inspect-browser-storage
# yarn
yarn install inspect-browser-storage
# pnpm
pnpm install inspect-browser-storage
Import:
// ESM
import { writeToStorage, readFromStorage } from 'inspect-browser-storage'
// CommonJS
const { writeToStorage, readFromStorage } = require('inspect-browser-storage')
readFromStorage(domain, key, options?)
Example:
const data = await readFromStorage('test-application.de', 'auth_token')
// -> Returns the value of the key 'auth_token' in the localStorage of 'https://test-application.de/'
Options:
dbPath: (string) The domain in the storage.key: (string) the key of the item in storageoptions?: (object) Options are defaults and get merged with the default options.dbPath: (string) Path to the database, default is the chromium path on your systemautoUnlink: (boolean) If true, the package will try to unlock the database LOCK File. Default is trueprotocol: (string) Which protocol should be added to the domain, can be https:// or http://. Default is https://storage: (string) Define which storage it should use, can belocalStorageorsessionStorage. Default islocalStorage
writeToStorage(domain, key, value, options?)
Example:
const data = await writeToStorage('test-application.de', 'auth_token', 'eyDasdlok.......')
Options:
dbPath: (string) The domain in the storage.key: (string) the key of the item in storagevalue: (string) the value which should set to the key in storageoptions?: (object) Options are defaults and get merged with the default options.dbPath: (string) Path to the database, default is the chromium path on your systemautoUnlink: (boolean) If true, the package will try to unlock the database LOCK File. Default is trueprotocol: (string) Which protocol should be added to the domain, can be https:// or http://. Default is https://storage: (string) Define which storage it should use, can belocalStorageorsessionStorage. Default islocalStorage
Development
- Clone this repository
- Install dependencies using
yarn install - Run watcher build
yarn dev
License
Made with by Conner Bachmann.
The idea originally comes from Jan Bölsche and his package chrome-localstorage
Published under MIT License.