-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcopy_firefox
More file actions
executable file
·153 lines (140 loc) · 5.32 KB
/
copy_firefox
File metadata and controls
executable file
·153 lines (140 loc) · 5.32 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#!/bin/sh
set -eu
# Firefox configuration is enough of a pain in the ass to warrant its own script
CWD="$(dirname "$0")"
ffsrc="$1"
ffdst="$2"
mkdir -p "$ffdst"
rsync --info=stats0,flist0 -r "$ffsrc/" "$ffdst" \
--include=/chrome/ \
--include=/extensions/ \
--include=/user.js \
--include=/userjs/ \
--include=/extensions.json \
--exclude='/*' \
--exclude='/extensions/langpack-*.xpi' \
--exclude=/extensions/deArrow@ajay.app.xpi \
--exclude=/extensions/jid1-MnnxcxisBPnSXQ@jetpack.xpi \
--exclude=/extensions/tridactyl.vim@cmcaine.co.uk.xpi
# Exclusions:
# - deArrow@ajay.app DeArrow: Still testing, not a huge fan yet
# - jid1-MnnxcxisBPnSXQ@jetpack Privacy Badger: Useless defaults when uBlock is used
# - tridactyl.vim@cmcaine.co.uk Tridactyl: Currently disabled
# Configure default search engine
cat > "$ffdst/search.json" << 'EOF'
{
"version": 8,
"engines": [
{
"id": "ddg@search.mozilla.orgdefault",
"_name": "DuckDuckGo",
"_metaData": {}
}
],
"metaData": {
"defaultEngineId": "ddg@search.mozilla.orgdefault"
}
}
EOF
# Add some additional preferences
cat > "$ffdst/prefs.js" << 'EOF'
user_pref("browser.uiCustomization.state", "{
\"placements\": {
\"nav-bar\": [
\"back-button\",
\"forward-button\",
\"stop-reload-button\",
\"urlbar-container\",
\"search-container\",
\"downloads-button\",
\"_testpilot-containers-browser-action\",
\"ublock0_raymondhill_net-browser-action\",
\"7esoorv3_alefvanoon_anonaddy_me-browser-action\",
\"passff_invicem_pro-browser-action\",
\"treestyletab_piro_sakura_ne_jp-browser-action\",
\"unified-extensions-button\"
],
\"TabsToolbar\": [
\"tabbrowser-tabs\",
\"new-tab-button\",
\"alltabs-button\"
]
},
\"seen\": [
\"sponsorblocker_ajay_app-browser-action\"
],
\"currentVersion\": 19
}");
user_pref("extensions.webextensions.uuids", "{
\"{aecec67f-0d10-4fa7-b7c7-609a2db280cf}\": \"00000000-0000-0000-0000-000000000000\",
\"treestyletab@piro.sakura.ne.jp\": \"00000000-0000-0000-0000-000000000001\",
\"jid1-bmMwuNrx3u5hqQ@jetpack\": \"00000000-0000-0000-0000-000000000002\"
}");
EOF
# Finding out extension parameters:
# cat extensions.json | jq -C '.addons[]|.id,.defaultLocale.name,.optionalPermissions' | less
# Enable all installed extensions
printf '{"schemaVersion":36,"addons":[' > "$ffdst/extensions.json"
for x in "$ffdst/extensions"/*.xpi; do
name="$(basename "$x" .xpi)"
printf '%s' \
'{' \
'"id":"'"$name"'",' \
'"version":"0",' \
'"type":"extension",' \
'"defaultLocale":{},' \
'"visible":true,' \
'"active":true,' \
'"location":"app-profile"' \
'},' >> "$ffdst/extensions.json"
done
printf '{}]}' >> "$ffdst/extensions.json"
# Enable all extensions' permissions
# Go through the extension permission settings to make sure everything is turned on
cat > "$ffdst/extension-preferences.json" << 'EOF'
{
"7esoorv3@alefvanoon.anonaddy.me":{"permissions":["bookmarks"],"origins":[]},
"@testpilot-containers":{"permissions":["bookmarks","browsingData","nativeMessaging","proxy"],"origins":[]},
"@ublacklist":{"permissions":[],"origins":["*://*/*"]},
"addon@fastforward.team":{"permissions":[],"origins":["<all_urls>"]},
"sponsorBlocker@ajay.app":{"permissions":[],"origins":["*://*/*"]},
"treestyletab@piro.sakura.ne.jp":{"permissions":["bookmarks","clipboardRead","tabHide"],"origins":["<all_urls>"]},
"{0731d555-4732-4047-99f9-38a388ffa044}":{"permissions":["downloads"],"origins":[]},
"{531906d3-e22f-4a6c-a102-8057b88a1a63}":{"permissions":["clipboardWrite","nativeMessaging","bookmarks","webRequest","webRequestBlocking"],"origins":[]},
"{60f82f00-9ad5-4de5-b31c-b16a47c51558}":{"permissions":["clipboardWrite"],"origins":[]},
"{cb31ec5d-c49a-4e5a-b240-16c767444f62}":{"permissions":[],"origins":["https://*/*"]}
}
EOF
# Configurations to put in data/firefox:
#
# {aecec67f-0d10-4fa7-b7c7-609a2db280cf}: Violentmonkey
# - Import scripts from zip backup (no script data/settings)
# - Use about:debugging and browser.storage.local.set({key:val}) to inject image cache
# treestyletab@piro.sakura.ne.jp: Tree Style Tab
# - Default configuration to avoid first-use popups
# jid1-bmMwuNrx3u5hqQ@jetpack: wasavi
# - Default configuration to avoid first-use popups
#
# Include the '^userContextId=' directories when copying
# Install extension configuration
rsync --info=stats0,flist0 -r "$CWD/data/firefox/" "$ffdst"
# "Compress" the files that require this...
# Yes, I wrote a non-compressor in posix shell for this
mozlz4() {
len=$(cat "$1" | wc -c)
test $len -lt 15 && buf=$(printf %x0 $len) || {
buf=f0
rem=$(( $len - 15 ))
while [ $rem -ge 255 ]; do
buf=${buf}ff
rem=$(( $rem - 255 ))
done
buf=$buf$(printf %02x $rem)
}
datalen=$(( $len + $(printf %s $buf | wc -c) / 2 ))
buf=$(printf %08x $datalen | sed 's/../&\n/g' | tac | tr -d \\n)$buf
buf=$(printf mozLz40\\0 | xxd -p)$buf
echo $buf | xxd -r -p | cat - "$1"
}
mozlz4 "$ffdst/search.json" > "$ffdst/search.json.mozlz4"
rm "$ffdst/search.json"