Skip to content

Instantly share code, notes, and snippets.

@varenc
Last active April 13, 2025 01:42
Show Gist options
  • Save varenc/534c917806f77bf436e6982634b17181 to your computer and use it in GitHub Desktop.
Save varenc/534c917806f77bf436e6982634b17181 to your computer and use it in GitHub Desktop.
Backup your Chrome Developer tools saved snippets
## Use the path below for macOS.
# On linux it may be `~/.config/chromium/Default/Preferences` or `~/snap/chromium/common/chromium/Default/Preferences``
# Find yours by opening chrome://version/, finding the "Profile Path" line, and appending `/Preferences` to it.
cat "$HOME/Library/Application Support/Google/Chrome/Default/Preferences" \
| jq -r '
.devtools.preferences["script-snippets"]
| fromjson[]
| [.name, (.content | @base64)]
| @tsv
' \
| while IFS=$'\t' read -r snippet_name snippet_content_b64; do
snippet_name_clean=$(echo -n "$snippet_name" | tr -cs '[:alnum:]._$' '_')
base64 --decode <<<"$snippet_content_b64" \
> "${snippet_name_clean}.js"
echo "Saved snippet: $snippet_name_clean.js (original name: $snippet_name)"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment