[Chrome Extension] Get Cookies to Access Instagram API


Chrome extension to get cookies, used in my repo, to access Instagram API.

manifest.json:

{
  "manifest_version": 2,

  "name": "igcookies",
  "description": "Get cookies to access Instagram API",
  "version": "0.1",

  "browser_action": {
    "default_title": "get IG cookies",
    "default_popup": "popup.html"
  },
  "permissions": [
    "cookies",
    "tabs",
    "*://www.instagram.com/"
  ]
}

popup.html:

<script src="popup.js"></script>

popup.js:

chrome.tabs.query({
  active: true,
  currentWindow: true
}, function(tabs) {
  chrome.cookies.getAll({}, function (cookies) {

    var cookieNames = ["ds_user_id", "sessionid", "csrftoken"];

    var cookieAuth = {};
    document.write("<pre>");
    for (var i in cookies) {

      var cookie = cookies[i];
      if (cookieNames.indexOf(cookie.name) == -1) {
        continue;
      }

      cookieAuth[cookie.name] = cookie.value;
    }
    document.write(JSON.stringify(cookieAuth, null, 2));
    document.write("</pre>");
  });
});

References:

[1][Chrome Extension] Get Authentication Cookies of gphotosuploader