generated from ReVanced/revanced-patches-template
-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Twitter): Add
Premium settings
patch, Unlocks premium options …
…from settings like custom app icon and custom navbar
- Loading branch information
Showing
2 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
src/main/kotlin/crimera/patches/twitter/premium/premiumsettings/PremiumSettingsPatch.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package crimera.patches.twitter.premium.premiumsettings | ||
|
||
import app.revanced.patcher.data.BytecodeContext | ||
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction | ||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction | ||
import app.revanced.patcher.extensions.InstructionExtensions.getInstructions | ||
import app.revanced.patcher.patch.BytecodePatch | ||
import app.revanced.patcher.patch.PatchException | ||
import app.revanced.patcher.patch.annotation.CompatiblePackage | ||
import app.revanced.patcher.patch.annotation.Patch | ||
import com.android.tools.smali.dexlib2.Opcode | ||
import com.android.tools.smali.dexlib2.builder.instruction.BuilderInstruction35c | ||
import crimera.patches.twitter.misc.settings.fingerprints.SettingsFingerprint | ||
import crimera.patches.twitter.premium.premiumsettings.fingerprints.PremiumSettingsPatchFingerprint | ||
|
||
@Patch( | ||
name = "Premium settings", | ||
description = "Unlocks premium options from settings like custom app icon and custom navbar", | ||
compatiblePackages = [CompatiblePackage("com.twitter.android")], | ||
) | ||
object PremiumSettingsPatch : BytecodePatch( | ||
setOf(PremiumSettingsPatchFingerprint, SettingsFingerprint) | ||
) { | ||
override fun execute(context: BytecodeContext) { | ||
PremiumSettingsPatchFingerprint.result?.mutableMethod?.addInstruction( | ||
0, "return-void" | ||
) ?: throw PatchException("Patch not found") | ||
|
||
val prefCLickedMethod = SettingsFingerprint.result?.mutableClass?.methods?.find { | ||
it.returnType == "Z" | ||
} ?: throw PatchException("Method not found") | ||
|
||
prefCLickedMethod.getInstructions().filter { it.opcode == Opcode.INVOKE_INTERFACE }.find { | ||
prefCLickedMethod.getInstruction<BuilderInstruction35c>(it.location.index).reference.toString() | ||
.contains("SubscriptionsUserSubgraph") | ||
}?.let { | ||
val loc = it.location.index | ||
prefCLickedMethod.addInstruction(loc + 4, "const p1, 0x1") | ||
} ?: throw PatchException("Error adding instruction") | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
...a/patches/twitter/premium/premiumsettings/fingerprints/PremiumSettingsPatchFingerprint.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package crimera.patches.twitter.premium.premiumsettings.fingerprints | ||
|
||
import app.revanced.patcher.fingerprint.MethodFingerprint | ||
|
||
object PremiumSettingsPatchFingerprint: MethodFingerprint( | ||
parameters = listOf("Lcom/twitter/navigation/subscriptions/ReferringPage"), | ||
strings = listOf("referringPage") | ||
) |