diff --git a/README.md b/README.md index 5c8ee6bb0d..4413df3f74 100644 --- a/README.md +++ b/README.md @@ -9,15 +9,17 @@ Automatically patched binaries are available on [distok.a3.pm/cutthecord](https: - Get apktool - Get a keystore, see [here](https://stackoverflow.com/a/14994354/3286892), step 1. - Get 72x72 copies of latest version of mutant standard emojis with codepoints. I have a zip [here](https://mutant.lavatech.top/72x72.zip). -- Extract the emojis you got somewhere, then prepend `emoji_` to their names (`for f in * ; do mv -- "$f" "emoji_$f" ; done`). -- Get rid of `-fe0f` on filenames to fix render of some emojis (`find . -name '*png' -exec bash -c ' mv $0 ${0/-fe0f/}' {} \;`, lots of mv errors will happen, that's fine). -- Clone this repo somewhere, edit `emojireplace.sh` and set the variables to the folders you want it to run on. +- Extract the emojis you got somewhere. +- Clone this repo somewhere, edit `emojireplace.sh` and set the `extracted_mutstd_path` folder to the folder you just extracted emojis to. ## Building an patched discord app -- Get a Discord apk (*cough* [aptoide](https://ws75.aptoide.com/api/7/app/getMeta?package_name=com.discord)), and get all the necessary patches and the optional patches you want for that version. If the patches aren't available, you'll have to port them yourself. +- Get a Discord apk (*cough* [aptoide](https://ws75.aptoide.com/api/7/app/getMeta?package_name=com.discord)). +- Extract it with apktool (`apktool d `) +- Get all the necessary patches for that version. Necessary patches are not available for all versions and are only required to get some versions to pack together correctly. +- Get optional patches you want for your version. If the patch you want isn't available for your version, you'll have to port them yourself. - Apply the patches (`patch -p1 < `). -- Edit `emojireplace.sh` to point to right directories, and apply emoji patches (`bash emojireplace.sh`) +- Edit `emojireplace.py` to point to extracted discord folder (`extracted_discord_path`), and apply emoji patches (`python3 emojireplace.py`) - Build the new APK (`apktool b com.discord-831`) - Sign the new APK (`jarsigner -keystore /dist/.apk `) - Get your new APK from `/dist/.apk`, install and enjoy! diff --git a/emojireplace.py b/emojireplace.py new file mode 100644 index 0000000000..a543178ddb --- /dev/null +++ b/emojireplace.py @@ -0,0 +1,45 @@ +#!/bin/env python3 +import os +import shutil + +# REPLACE THESE LINES +extracted_discord_path = "/tmp/cutthecord/discord" +extracted_mutstd_path = "/var/www/mutant/72x72" + + +def clean_emoji_name(name): + name = name.lower().replace("_", "-")\ + .replace("emoji_", "").replace("-fe0f", "") + return name + + +discord_emoji_path = os.path.join(extracted_discord_path, "res", "raw") +# Get file listings in relevant folders +discord_emojis = os.listdir(discord_emoji_path) +mutstd_emojis = os.listdir(extracted_mutstd_path) + +# Clean names of mutantstd emojis so thar we can compare them +# to clean discord emojis later +clean_mutstd_emojis = {clean_emoji_name(emoji): emoji for + emoji in mutstd_emojis} + +replace_counter = 0 + +# Go through each discord emoji, and clean their names +for emoji in discord_emojis: + clean_discord_emoji = clean_emoji_name(emoji) + + # Check if said clean name of emoji is in clean mutstd list + if clean_discord_emoji in clean_mutstd_emojis: + # Get full unclean filename of mutantstd emoji, generate relevant paths + full_mutstd_name = clean_mutstd_emojis[clean_discord_emoji] + full_mutstd_path = os.path.join(extracted_mutstd_path, full_mutstd_name) + full_discord_path = os.path.join(extracted_discord_path, emoji) + + # Copy and overwrite the discord emojis with the mutantstd alternatives + shutil.copyfile(full_mutstd_path, full_discord_path) + + print("Replaced {} emoji.".format(full_mutstd_name)) + replace_counter += 1 + +print("Done, {} emojis replaced.".format(replace_counter)) diff --git a/emojireplace.sh b/emojireplace.sh deleted file mode 100644 index 1f0a4dcd54..0000000000 --- a/emojireplace.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash -EXTRACTED_DISCORD="/home/ave/Downloads/dic/com.discord-830" -EXTRACTED_MUTSTD="/home/ave/Downloads/emojo/72x72" -for filename in $EXTRACTED_DISCORD/res/raw/*.png; do - basefilename=$(basename $filename) - if [ -f $EXTRACTED_MUTSTD/$basefilename ]; then - echo "$basefilename replaced" - \cp $EXTRACTED_MUTSTD/$basefilename $filename - fi -done