Download the decompiled code from apkfuckery

This commit is contained in:
Observer of Time 2020-11-02 13:36:12 +02:00
parent 277641529d
commit b6d701e9e8
Signed by: chronobserver
GPG Key ID: 8A2DEA1DBAEBCA9E
3 changed files with 38 additions and 38 deletions

4
.gitignore vendored
View File

@ -1,5 +1,5 @@
cutthecord/
com.discord-*/
com.discord-*.apk
com.discord/
*.p12
*.jks
*.keystore

View File

@ -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.<br>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.<br>You will find it in `com.discord-*/dist/`.
before running the script.<br>You will find it in `com.discord/dist/`.
[CutTheCord]: https://gitdab.com/distok/cutthecord
[Asap]: https://fonts.google.com/specimen/Asap

View File

@ -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
adb install -r "com.discord/dist/com.discord-$VERCODE.apk"
rm -rf com.discord/ cutthecord/
fi