As I know , personal data always be saved at profile path which can be find at chrome://version.
I added many snippets in my Chrome Dev Tool, and want to backup them .
But I cann't find a file that snippets data saved in under this path.
Does anyone knows ? Plz tell me . Thanks very much!
On my ubuntu18
, chromium
snippets are saved under:
~/.config/chromium/Default/Preferences
as a one-line json file.
The above and Bookmarks
are the files I normally backup.
if you parse that Preferences json file you find the snippets at the following json path:
ROOT.devtools.preferences.scriptSnippets
that property's value need to be parsed again as json. then you get an array of {name,content} for all your snippets.
Note: I am using jq-1.6
for the commands below
To backup all snippetes into one json file:
jq .devtools.preferences.scriptSnippets ~/.config/chromium/Default/Preferences \
| jq '. | fromjson' > /tmp/backup.json
To backup all snippets into separate .js files
# 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"'
jq is a great command-line tool to query and process JSON files. You can get it from stedolan.github.io/jq/.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With