-
Notifications
You must be signed in to change notification settings - Fork 26
/
generate_patch.sh
executable file
·47 lines (36 loc) · 1.8 KB
/
generate_patch.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/bash
# Usage: ./generate_patch.sh
set -e
PLUGIN="$(mktemp)"
CSSINSERTCODE="$(mktemp)"
PLUGINWITHCSS="$(mktemp)"
URL="https:\/\/raw.githubusercontent.com\/paveyry\/better-hangoutschat\/master\/css\/COLOR"
if [ $OSTYPE == *"linux"* ]; then
POSIXFLAG="--posix"
fi
generateFiles() {
mkdir -p "$2"
COLORURL="$(echo $URL | sed "s/COLOR/$1/g")"
[ -z $1 ] && COLORURL=""
cat js/insert_css.js | sed "s#CSSCOLORURL#$COLORURL#g" > "$CSSINSERTCODE"
cat js/plugin.js | sed "/INSERTCSS/r $CSSINSERTCODE" > "$PLUGINWITHCSS"
cat js/plugin.js | sed "s/^.*INSERTCSS$//g" > "$PLUGIN"
cat js/gmonkeyscript_template.js "$PLUGINWITHCSS" > "$2/gmonkeyscript.js"
VERSION="$(git tag | tail -n 1 | cut -c2-)"
mkdir -p "$2/firefox"
cp css/shape.css $2/firefox/
[ -z $1 ] && touch $2/firefox/color.css || cp "css/$1" $2/firefox/color.css
cp "$PLUGIN" $2/firefox/plugin.js
mkdir -p "$2/firefox/icons"
cp browser_extensions/icon.png "$2/firefox/icons/icon.png"
cat "$2/firefox/color.css" | sed $POSIXFLAG 's/.important;$/;/g' | sed $POSIXFLAG 's/;$/!important;/g' > "$2/firefox/color2.css"
cat "$2/firefox/shape.css" | sed $POSIXFLAG 's/.important;$/;/g' | sed $POSIXFLAG 's/;$/!important;/g' > "$2/firefox/shape2.css"
mv "$2/firefox/shape2.css" "$2/firefox/shape.css" && mv "$2/firefox/color2.css" "$2/firefox/color.css"
rsync -r "$2/firefox/" "$2/chrome"
cat browser_extensions/firefox_manifest.json | sed "s/VERSION/$VERSION/g" | sed "s/COLOR/$3/g" > $2/firefox/manifest.json
cat browser_extensions/chrome_manifest.json | sed "s/VERSION/$VERSION/g" | sed "s/COLOR/$3/g" > $2/chrome/manifest.json
}
generateFiles "color_slack.css" "out/slacktheme" "Slack"
generateFiles "" "out/lighttheme" "Light"
generateFiles "color_dark.css" "out/darktheme" "Dark"
rm -rf "$PLUGINGEN" "$PLUGINWITHCSS"