Skip to content

Instantly share code, notes, and snippets.

@akkys77
Created October 16, 2020 09:52
Show Gist options
  • Save akkys77/2768380671b54e18637d7c4ac5da9b75 to your computer and use it in GitHub Desktop.
Save akkys77/2768380671b54e18637d7c4ac5da9b75 to your computer and use it in GitHub Desktop.
Extract snippets from chrome
# Tested with jq-1.6
# The script converts json entries into lines of format
# `filename[TAB]content-in-base64` and then
# for each line creates the corresponding file
# with the content decoded.
# Better be in a safe directory!!
mkdir /tmp/snippets-backup
cd /tmp/snippets-backup
jq .devtools.preferences.scriptSnippets ~/.config/chromium/Default/Preferences \
| jq '. | fromjson | .[]| [ .name, @base64 "\(.content)" ] | @tsv' -r \
| xargs -I{} /bin/bash -c 'file=$(echo "{}"|cut -f1); fileContent=$(echo "{}"|cut -f2); echo "$fileContent" | base64 -d > "${file}.js"'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment