summaryrefslogtreecommitdiff
path: root/bin/cookies_from_chromium
diff options
context:
space:
mode:
authorcos <cos>2022-12-01 16:14:20 +0000
committercos <cos>2022-12-01 17:27:23 +0000
commit1773627631cc873b6a09098dda1cac14c6ed03fa (patch)
tree13e34a2c0348fe20cf2283321189a59c91641f94 /bin/cookies_from_chromium
parent4a54a0d97a57df6c1525b9bbfcabdf829e44a4d1 (diff)
downloadadventofcode-1773627631cc873b6a09098dda1cac14c6ed03fa.zip
Initial commit of init_year, poke support scripts
Diffstat (limited to 'bin/cookies_from_chromium')
-rwxr-xr-xbin/cookies_from_chromium32
1 files changed, 32 insertions, 0 deletions
diff --git a/bin/cookies_from_chromium b/bin/cookies_from_chromium
new file mode 100755
index 0000000..b59e494
--- /dev/null
+++ b/bin/cookies_from_chromium
@@ -0,0 +1,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