diff --git a/.gitignore b/.gitignore index f64a83b..53fd1fe 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ cutthecord/ -com.discord-*/ -com.discord-*.apk +com.discord/ +*.p12 *.jks *.keystore diff --git a/README.md b/README.md index 0de29ea..da77775 100644 --- a/README.md +++ b/README.md @@ -3,11 +3,10 @@ ### Requires - `bash` -- `coreutils` - `sed` - `patch` -- `git` - `curl` +- `tar` - `apktool` - `keytool` - `jarsigner` @@ -21,7 +20,6 @@ - `customversion` - `necessary` - `noblocked` -- `notrack` - `squareavatars` ### Usage @@ -38,20 +36,28 @@ export KEYSTORE_ALIAS="ctc-key" If the file doesn't exist, generate it with `keytool`. ```sh -keytool -genkeypair \ - -keystore "$KEYSTORE_PATH" \ - -alias "$KEYSTORE_ALIAS" +keytool -genkeypair -keystore "$KEYSTORE_PATH" -alias "$KEYSTORE_ALIAS" +``` + +You also need to set the following variables: + +```sh +# the version code of the Discord APK +export VERCODE="1196" +# the apkfuckery commit hash corresponding to VERCODE +# https://gitdab.com/distok/apkfuckery/commits/branch/master +export COMMIT_HASH="2e0ee2fb8b4825de22cb43163be7072ea2f2b7b3" ``` Now, you can run the script.
You will be prompted to enter the keystore password. ```sh -bash < <(curl -LSs https://ikl.sh/ctc-patcher) +bash < <(curl -LSs https://discord.coffee/5V4AnGq) ``` You can install the patched app manually by setting `SKIP_INSTALL` -before running the script.
You will find it in `com.discord-*/dist/`. +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 diff --git a/patch.sh b/patch.sh index 73ccb2d..750d693 100755 --- a/patch.sh +++ b/patch.sh @@ -13,63 +13,57 @@ set -euo pipefail -: "$KEYSTORE_PATH" "$KEYSTORE_ALIAS" +trap 'exit 130' INT -URL='https://ws75.aptoide.com/api/7/app/getMeta?package_name=com.discord' +: "$KEYSTORE_PATH" "$KEYSTORE_ALIAS" "$VERCODE" "$COMMIT_HASH" -if [[ -n ${VERCODE+x} ]]; then - URL+="&max_vercode=$VERCODE" -fi +_dab() (curl --progress-bar -Lf "https://gitdab.com/distok/$1/archive/$2.tar.gz") -[[ $(curl -Ssf "$URL") =~ \"vercode\":([0-9]+),.*\"path\":\"([^\"]+)\" ]] +printf 'Downloading Discord...\n' -discord="com.discord-${BASH_REMATCH[1]}" +_dab apkfuckery "$COMMIT_HASH" | tar xzf - --strip-components=1 -printf 'Downloading %s...\n' "${BASH_REMATCH[2]}" +printf 'Downloading CutTheCord...\n' -curl --progress-bar -Lfo "$discord.apk" "${BASH_REMATCH[2]}" - -apktool d "$discord.apk" -o "$discord" - -git clone --depth=1 https://gitdab.com/distok/cutthecord +_dab cutthecord master | tar xzf - printf 'Editing patches...\n' -sed -i cutthecord/patches/squareavatars/"${BASH_REMATCH[1]}".patch -e 's/3dp/5dp/' -sed -i cutthecord/patches/branding/"${BASH_REMATCH[1]}".patch \ +sed -i cutthecord/patches/squareavatars/"$VERCODE".patch -e 's/3dp/5dp/' +sed -i cutthecord/patches/branding/"$VERCODE".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/${BASH_REMATCH[1]}.patch" +for p in necessary noblocked nocamerabutton squareavatars branding customversion; do + printf 'Applying %s patch...\n' "$p" + patch -d com.discord -p1 < "cutthecord/patches/$p/$VERCODE.patch" done printf 'Replacing files...\n' -pushd "$discord" >/dev/null -bash ../cutthecord/patches/notrack/"${BASH_REMATCH[1]}"-post.sh +pushd com.discord >/dev/null 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 \ +curl -LSsfo com.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 \ +curl -LSsfo com.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 \ +curl -LSsfo com.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 \ +curl -LSsfo com.discord/res/font/sourcecodepro_semibold.ttf \ https://github.com/thiagolucio/code-editor-fonts/raw/master/Hasklig.ttf/Hasklig-Medium.ttf -apktool b "$discord" +apktool b com.discord while ! jarsigner -keystore "$KEYSTORE_PATH" \ - "$discord/dist/$discord.apk" "$KEYSTORE_ALIAS" + "com.discord/dist/com.discord-$VERCODE.apk" "$KEYSTORE_ALIAS" do :; done if [[ -z ${SKIP_INSTALL+x} ]]; then - adb install -r "$discord/dist/$discord.apk" - rm -rf "$discord" "$discord.apk" cutthecord -fi \ No newline at end of file + adb install -r "com.discord/dist/com.discord-$VERCODE.apk" + rm -rf com.discord/ cutthecord/ +fi