get-cookies.txt-locally

repository·master·Indexed 19 days ago

https://github.com/kairi003/get-cookies.txt-locally

A browser extension for exporting cookies locally in Netscape, JSON, or header formats. It is designed for data privacy, operating entirely locally without transmitting information to external servers. The Netscape format provides compatibility with tools such as wget, curl, and Python3's MozillaCookieJar.

Tokens
1.3K
Snippets
2
Records
8
Agent score
28%

What's inside get-cookies.txt-locally

  1. Overview of get-cookies.txt-locally

    master

    The get-cookies.txt-locally extension allows you to export cookies from your browser in either Netscape or JSON format.

    The Netscape format is specifically designed for compatibility with tools like wget, curl, and MozillaCookieJar (Python3).

    A key security feature of this extension is that it operates entirely locally; it never transmits your cookie information to external servers. The source code is open-source and unobfuscated for transparency.

  2. Install get-cookies.txt-locally from source (Google Chrome)

    master

    To install the extension in Google Chrome using the source code:

    1. Download and unzip the repository.
    2. Navigate to chrome://extensions/ in your browser.
    3. Enable Developer mode.
    4. Click Load Unpacked and select the Get-cookies.txt-LOCALLY/src directory.
  3. Install get-cookies.txt-locally from source (Firefox)

    master

    Installing from source in Firefox requires patching the manifest file by merging src/manifest.json and src/manifest-firefox.json.

    You can use one of the following methods:

    • Use the firefox branch: The manifest is already merged on this branch.
    • Use other branches: You must merge the manifests manually, using jq, or by running npm run build:firefox.
  4. Permissions used by get-cookies.txt-locally

    master

    For transparency, the extension uses the following permissions to function:

    • activeTab: To retrieve the URL of the currently active tab.
    • cookies: To access and export cookies (read-only; does not write or send).
    • downloads: Used to export the cookie files locally.
    • notifications: To provide update notifications.
    • hosts permissions: To access and export cookies for specific hosts (read-only; does not write or send).
  5. Locate the extension installation directory (Google Chrome)

    master

    If you need to find the local installation directory for the Chrome extension (ID: cclelndahbckbenkjhflpdbgdldlbecc), use the following paths based on your OS:

    • Windows: %LOCALAPPDATA%\Google\Chrome\User Data\Default\Extensions\cclelndahbckbenkjhflpdbgdldlbecc
    • Mac: ~/Library/Application Support/Google/Chrome/Default/Extensions/cclelndahbckbenkjhflpdbgdldlbecc
    • Linux: ~/.config/google-chrome/Default/Extensions/cclelndahbckbenkjhflpdbgdldlbecc
  6. Available cookie serialization formats in formatMap

    master

    The formatMap object defines the available serialization strategies for cookie data. Each format includes an extension (ext), a mimeType, and a serializer function that converts the cookie array into a string.

    Supported formats:

    • netscape: Generates a standard Netscape HTTP Cookie File (text/plain) with header comments.
    • json: Generates a standard JSON string (application/json).
    • header: Generates a single-line string of cookie pairs in the format name=value; name2=value2; (text/plain).
    import { formatMap } from './src/modules/cookie_format.mjs';
    
    const cookies = [{ name: 'foo', value: 'bar' }];
    
    // Use the netscape serializer
    const netscapeText = formatMap.netscape.serializer(cookies);
    
    // Use the json serializer
    const jsonText = formatMap.json.serializer(cookies);
    
    // Use the header serializer
    const headerText = formatMap.header.serializer(cookies);
  7. Convert Chrome JSON cookies to Netscape format using jsonToNetscapeMapper

    master

    The jsonToNetscapeMapper function transforms an array of Chrome cookie objects (chrome.cookies.Cookie[]) into a 2D string array compatible with the Netscape cookie file format. Each inner array represents a row in the Netscape format with the following fields: domain, includeSubDomain (boolean as string), path, secure (boolean as string), expiry, name, and value.

    import { jsonToNetscapeMapper } from './src/modules/cookie_format.mjs';
    
    // Example input matching chrome.cookies.Cookie structure
    const cookies = [{
      domain: '.example.com',
      expirationDate: 1738886400,
      path: '/',
      secure: true,
      name: 'session_id',
      value: 'abc123xyz'
    }];
    
    const netscapeRows = jsonToNetscapeMapper(cookies);
    // Result: [['.example.com', 'TRUE', '/', 'TRUE', '1738886400', 'session_id', 'abc123xyz']]