Skip to content

Instantly share code, notes, and snippets.

@kentbrew

kentbrew/cookies.md

Last active Feb 7, 2020
Embed
What would you like to do?
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