summaryrefslogtreecommitdiff
path: root/bin/cookies_from_chromium
blob: b59e494d5f8566970a93b32e37f4a58881e2d14a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/sh -eu

_aoc_config="${HOME}/.adventofcode.json"

for _c in "${HOME}/.config/chrom"*/*'/Cookies'
do
  echo "${_c}"
  printf '%s\n%s%s\n' '.headers on' \
      'SELECT name, value, hex(encrypted_value) FROM cookies ' \
      'WHERE host_key=".adventofcode.com";' | sqlite3 "${_c}"
done

echo 'This is a reminder of how cookies are encrypted.' \
        'Manual export is required.' >&2
echo 'Ctrl-Shift-i > Application > Cookies' >&2

read -p 'Session cookie: ' _session_cookie

read -p "Create ${_aoc_config} (y/N)? " _input

case "${_input}" in
  'y' | 'Y')
    echo 'Ok. Creating the file.'
    printf '{ "session-cookie": "%s" }' "${_session_cookie}" \
        > "${_aoc_config}"
    ;;
  *)
    echo 'Ok. Skipping it.'
    ;;
esac

unset _c _input _session_cookie