#!/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