Hi all. It seems like there's a lot of people annoyed by ads on Instagram. I was, too, until I figured out a novel way to patch it.
Changes
Without further ado, here's the link: Download.
How my patch works
Instagram, as, probably, all the other Facebook apps, uses Proxygen for its HTTP client. Since Proxygen is written in C++, it needs JNI bindings to be used in an Android app. This means that the Java classes that interface with the native code can't be obfuscated. So, instead of digging through piles of obfuscated code that gets reshuffled with each update, I did the most straightforward thing: I injected my code into Proxygen's Java part. I had to make minimal modifications to the bytecode in order to intercept the API responses and pass them through my code before the app gets any chance to process them.
To repeat the process yourself:
Unlocking the developer settings is another thing entirely as it doesn't depend on the API. There's no getting around the obfuscated code. You need to find an enum class that has RELEASE, DEBUG, INHOUSE as its values. There are several methods that return boolean; you need to change the one that returns true to false (this determines whether this is a release build), and then another one to return true so that the build type returned ends up as INHOUSE. Decompiling it using jadx makes figuring this out a lot easier.
I'll probably automate the patching process at some point in the future.
Hope you enjoy!
13/10/2019: updated to v114 and updated hooks files.
Changes
- Removed ads in the feed.
- Removed ads in stories.
- Removed "who to follow" blocks in the feed.
- Removed stories in the feed (those between the posts, not those on top of course).
- Carousel posts always show the first media instead of randomly jumping to the second one.
- Analytics requests are blocked.
- Enabled "internal" settings, accessible by either long-pressing the home tab or in the settings menu. These allow doing a lot, so use with care. The most useful feature so far is the ability to manually override each of the gazillion server-side configuration values.
Without further ado, here's the link: Download.
How my patch works
Instagram, as, probably, all the other Facebook apps, uses Proxygen for its HTTP client. Since Proxygen is written in C++, it needs JNI bindings to be used in an Android app. This means that the Java classes that interface with the native code can't be obfuscated. So, instead of digging through piles of obfuscated code that gets reshuffled with each update, I did the most straightforward thing: I injected my code into Proxygen's Java part. I had to make minimal modifications to the bytecode in order to intercept the API responses and pass them through my code before the app gets any chance to process them.
To repeat the process yourself:
- Download any Instagram apk or pull one from your device.
- Run apktool d on it.
- Download View attachment 4752809 and unpack it. Place the two files into smail/com/facebook/proxygen in your disassembled Instagram folder, replacing the existing ones.
- Download View attachment 4842971, unpack it and place the folder into any of the smali folders; I did smali_classes3 because there was no room for method references in the first dex.
- Build the new apk with apktool b.
- Sign it.
- Install it.
- Enjoy!
Unlocking the developer settings is another thing entirely as it doesn't depend on the API. There's no getting around the obfuscated code. You need to find an enum class that has RELEASE, DEBUG, INHOUSE as its values. There are several methods that return boolean; you need to change the one that returns true to false (this determines whether this is a release build), and then another one to return true so that the build type returned ends up as INHOUSE. Decompiling it using jadx makes figuring this out a lot easier.
I'll probably automate the patching process at some point in the future.
Hope you enjoy!
13/10/2019: updated to v114 and updated hooks files.
Last edited: