#!/usr/bin/env bash ################################################### # "THE DRINK-WARE LICENSE" (Revision 42): # # # # As long as you retain this notice you can # # do whatever you want with this stuff. # # If we meet some day, and you think this stuff # # is worth it, you can buy me a drink in return. # # # # -- Observer of Time # ################################################### set -euo pipefail : "$KEYSTORE_PATH" "$KEYSTORE_ALIAS" 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)"') discord="com.discord-${data[0]}" printf 'Downloading %s...\n' "${data[1]}" curl -L#fo "$discord.apk" "${data[1]}" apktool d "$discord.apk" -o "$discord" 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 \ -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 done printf 'Replacing files...\n' pushd "$discord" >/dev/null bash ../cutthecord/patches/notrack/"${data[0]}"-post.sh bash ../cutthecord/patches/branding/customicon.sh bash ../cutthecord/patches/branding/customdynamicicon.sh bash ../cutthecord/patches/bettertm/bettertm.sh ../cutthecord/patches/bettertm popd >/dev/null curl -LSsfo "$discord"/res/font/whitney_semibold.ttf \ https://github.com/google/fonts/raw/master/ofl/asap/Asap-Medium.ttf curl -LSsfo "$discord"/res/font/whitney_bold.ttf \ https://github.com/google/fonts/raw/master/ofl/asap/Asap-SemiBold.ttf curl -LSsfo "$discord"/res/font/whitney_medium.ttf \ https://github.com/google/fonts/raw/master/ofl/asap/Asap-Regular.ttf curl -LSsfo "$discord"/res/font/sourcecodepro_semibold.ttf \ https://github.com/thiagolucio/code-editor-fonts/raw/master/Hasklig.ttf/Hasklig-Medium.ttf apktool b "$discord" jarsigner -keystore "$KEYSTORE_PATH" "$discord/dist/$discord.apk" "$KEYSTORE_ALIAS" if [[ -z ${SKIP_INSTALL+x} ]]; then adb install -r "$discord/dist/$discord.apk" rm -rf "$discord" "$discord.apk" cutthecord fi