diff --git a/README.md b/README.md
new file mode 100644
index 0000000..0de29ea
--- /dev/null
+++ b/README.md
@@ -0,0 +1,58 @@
+## [CutTheCord][] patcher
+
+### Requires
+
+- `bash`
+- `coreutils`
+- `sed`
+- `patch`
+- `git`
+- `curl`
+- `apktool`
+- `keytool`
+- `jarsigner`
+- `adb` (optional if `SKIP_INSTALL` is set)
+
+### Patches
+
+- `bettertm`
+- `branding`
+- `customfont` ([text][Asap], [code][Hasklig])
+- `customversion`
+- `necessary`
+- `noblocked`
+- `notrack`
+- `squareavatars`
+
+### Usage
+
+The script needs a keystore to sign the patched app.
+
+```sh
+# the path to a .keystore or .jks file
+export KEYSTORE_PATH="ctc-key.jks"
+# the alias of the keystore
+export KEYSTORE_ALIAS="ctc-key"
+```
+
+If the file doesn't exist, generate it with `keytool`.
+
+```sh
+keytool -genkeypair \
+ -keystore "$KEYSTORE_PATH" \
+ -alias "$KEYSTORE_ALIAS"
+```
+
+Now, you can run the script.
You will
+be prompted to enter the keystore password.
+
+```sh
+bash < <(curl -LSs https://ikl.sh/ctc-patcher)
+```
+
+You can install the patched app manually by setting `SKIP_INSTALL`
+before running the script.
You will find it in `com.discord-*/dist/`.
+
+[CutTheCord]: https://gitdab.com/distok/cutthecord
+[Asap]: https://fonts.google.com/specimen/Asap
+[Hasklig]: https://github.com/i-tu/Hasklig
diff --git a/patch.sh b/patch.sh
index 3549365..b49512b 100755
--- a/patch.sh
+++ b/patch.sh
@@ -17,13 +17,13 @@ set -euo pipefail
URL='https://ws75.aptoide.com/api/7/app/getMeta?package_name=com.discord'
-readarray -t data < <(curl -Ssf "$URL" | jq -r '.data.file | "\(.vercode)\n\(.path)"')
+[[ $(curl -Ssf "$URL") =~ \"vercode\":([0-9]+),.*\"path\":\"([^\"]+)\" ]]
-discord="com.discord-${data[0]}"
+discord="com.discord-${BASH_REMATCH[1]}"
-printf 'Downloading %s...\n' "${data[1]}"
+printf 'Downloading %s...\n' "${BASH_REMATCH[2]}"
-curl -L#fo "$discord.apk" "${data[1]}"
+curl --progress-bar -Lfo "$discord.apk" "${BASH_REMATCH[2]}"
apktool d "$discord.apk" -o "$discord"
@@ -31,20 +31,20 @@ git clone --depth=1 https://gitdab.com/distok/cutthecord
printf 'Editing patches...\n'
-sed -i cutthecord/patches/squareavatars/"${data[0]}".patch -e 's/3dp/5dp/'
-sed -i cutthecord/patches/branding/"${data[0]}".patch \
+sed -i cutthecord/patches/squareavatars/"${BASH_REMATCH[1]}".patch -e 's/3dp/5dp/'
+sed -i cutthecord/patches/branding/"${BASH_REMATCH[1]}".patch \
-e 's/CTCNAME/Discord (CTC)/g;s/CTCBRANCH/chronobserver/g' \
-e "s/-CTCBUILD/-$(date --iso-8601)/g;s/CTCBUILD//g"
sed -i cutthecord/patches/branding/customicon.sh -e 's/#rm/rm/'
for p in necessary notrack noblocked squareavatars branding customversion; do
- patch -d "$discord" -p1 < cutthecord/patches/"$p"/"${data[0]}".patch
+ patch -d "$discord" -p1 < "cutthecord/patches/$p/${BASH_REMATCH[1]}.patch"
done
printf 'Replacing files...\n'
pushd "$discord" >/dev/null
-bash ../cutthecord/patches/notrack/"${data[0]}"-post.sh
+bash ../cutthecord/patches/notrack/"${BASH_REMATCH[1]}"-post.sh
bash ../cutthecord/patches/branding/customicon.sh
bash ../cutthecord/patches/branding/customdynamicicon.sh
bash ../cutthecord/patches/bettertm/bettertm.sh ../cutthecord/patches/bettertm
@@ -61,7 +61,9 @@ curl -LSsfo "$discord"/res/font/sourcecodepro_semibold.ttf \
apktool b "$discord"
-jarsigner -keystore "$KEYSTORE_PATH" "$discord/dist/$discord.apk" "$KEYSTORE_ALIAS"
+while ! jarsigner -keystore "$KEYSTORE_PATH" \
+ "$discord/dist/$discord.apk" "$KEYSTORE_ALIAS"
+do :; done
if [[ -z ${SKIP_INSTALL+x} ]]; then
adb install -r "$discord/dist/$discord.apk"