forked from rattboi/dotfiles
/
read-safari-usercss.sh
executable file
·32 lines (25 loc) · 1.21 KB
/
read-safari-usercss.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#! /usr/bin/env bash
################################################################################
# Dumps everything in the local storage for Injector onto disk. The result will
# include all transformations. This includes substitutions (which might be
# sensitive) and CSS variables.
################################################################################
set -e
# user_css_file=$(ls -1 ~/Library/Safari/LocalStorage/safari-extension_com.gridth.usercss*.localstorage);
# user_css_file=$(ls -1 ~/Library/Safari/LocalStorage/safari-extension_com.tsbehlman.injector-*.localstorage);
user_css_file=$(ls -1 ~/Library/Safari/LocalStorage/safari-extension_com.logustus.injector-*.localstorage);
get_keys_sql="select key from itemtable;"
# $1 - the key to select
function read_blob_sql() {
echo "select hex(value) from itemtable where key = '$1';"
}
keys=`sqlite3 $user_css_file "$get_keys_sql"`
mkdir -p .tmp-css
for key in $keys; do
if [ "$key" != "StyleStorageVersion" ]; then
TMP_JSON=.tmp-css/user-css-$key.json
sqlite3 $base_path$user_css_file "$(read_blob_sql $key)" |\
xxd -r -p | tr -dc '[:print:]' | jq '.' > $TMP_JSON
node ./write-css-from-safari.js $TMP_JSON custom-css $key
fi
done