Skip to content

Instantly share code, notes, and snippets.

@cursorial
Created April 17, 2021 20:34
Show Gist options
  • Save cursorial/4469d65434c2e621a886b42daad686e8 to your computer and use it in GitHub Desktop.
Save cursorial/4469d65434c2e621a886b42daad686e8 to your computer and use it in GitHub Desktop.
Get CSRF token on Instagram
const getCookieObject = () => {
let obj = {}
document.cookie.split(';').map((item) => {
const keyValArray = item.split('=')
try {
const key = keyValArray[0].trim()
const val = keyValArray[1].trim()
obj[key] = val
} catch (e) {}
})
return obj
}
const getCSRFToken = () => {
return getCookieObject()['csrftoken']
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment