Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/arshadkazmi42/firefox-cookie

Firefox cookie manager for node. To set and get cookie from firefox
https://github.com/arshadkazmi42/firefox-cookie

cookie cookie-crud cookie-manager crud database firefox firefox-cookie-manager sqlite

Last synced: 3 months ago
JSON representation

Firefox cookie manager for node. To set and get cookie from firefox

Awesome Lists containing this project

README

        

# firefox-cookie

[![Build](https://github.com/arshadkazmi42/firefox-cookie/actions/workflows/nodejs.yml/badge.svg)](https://github.com/arshadkazmi42/firefox-cookie/actions/workflows/nodejs.yml)

Node Cookie Manager for Firefox, read / write cookie from sqlite db

## Install

```
npm i firefox-cookie
```

## Usage

```javascript

// Search for the "default" profile in Firefox implicitly https://support.mozilla.org/gl/questions/1264072
const FirefoxCookie = require('firefox-cookie');
const FFCookie = new FirefoxCookie();

// Search for the "default-release" new profile in Firefox explicitly (or any other profile you give as parameter)
const FirefoxCookie = require('firefox-cookie');
const FFCookie = new FirefoxCookie("default-release");

// Reading cookie
const cookie = await FFCookie.getCookie('arshad.com');

// Inserting cookie
const DATA = [
{
'baseDomain': 'arshad.com',
'originAttributes': '',
'name': 'arshad',
'value': 'arshad-test-cookie',
'host': 'arshad.com',
'path': '/root',
'expiry': 1,
'lastAccessed': 111111111,
'creationTime': 10001110,
'isSecure': 1,
'isHttpOnly': 0,
'inBrowserElement': 0,
'sameSite': 0,
}
];

await FFCookie.setCookie(DATA);
```

## API

- **`getCookie(path)`**
- Returns cookie json from database for the input path
- **Params**
- path (String)

- **`setCookie(cookies)`**
- Adds all the input cookies into the sqlite database
- **Params**
- cookies (Array of cookies object)

- **`removeCookie(domain)`**
- Removes all records matching the domain.
- > It uses `like` condition (`%domain%`) so anything matching the pattern will be removed
- **Params**
- path (String)

## Contributing

Interested in contributing to this project?
You can log any issues or suggestion related to this library [here](https://github.com/arshadkazmi42/firefox-cookie/issues/new)

Read our contributing [guide](CONTRIBUTING.md) on getting started with contributing to the codebase

## Contributors

Thank you to all the contributors who have helped us in making this project better :raised_hands: