Skip to content

Instantly share code, notes, and snippets.

@kentbrew
Last active January 7, 2024 10:53
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kentbrew/6212f30491653e8534eae08c9de25894 to your computer and use it in GitHub Desktop.
Save kentbrew/6212f30491653e8534eae08c9de25894 to your computer and use it in GitHub Desktop.
Quick-read cookies via browser extension

Here's a thing you can do to quickly reveal any or all cookies set on your WebExtensions-compatible browser from any domain. For this example we'll use Chrome but it should work wherever you can debug a browser extension.

You need to have at least one add-on installed that has a background page; to find it, go to chrome://extensions, be sure Developer Mode is on (top right sliding switch) and see if any of your installed extensions has a link to background page next to Inspect Views.

Once you find a link to a background page, click it. A Web inspector should appear; when it does, go to the Console tab and paste this:

chrome.cookies.getAll(
  {domain: "facebook.com"},
  results => {
    console.log(JSON.stringify(results, null, 2));
  }
);

What's listed in the domain slot above will get you all cookies from all possible variations including the root. If you want to see all cookies from every domain, do this:

chrome.cookies.getAll(
  {},
  results => {
    console.log(JSON.stringify(results, null, 2));
  }
);

... and prepare to be amazed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment