generated from ReVanced/revanced-patches-template
-
-
Notifications
You must be signed in to change notification settings - Fork 211
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat:
premium-icon-reddit
patch (#333)
- Loading branch information
Showing
3 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
...in/app/revanced/patches/reddit/layout/premiumicon/annotations/PremiumIconCompatibility.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,13 @@ | ||
package app.revanced.patches.reddit.layout.premiumicon.annotations | ||
|
||
import app.revanced.patcher.annotation.Compatibility | ||
import app.revanced.patcher.annotation.Package | ||
|
||
@Compatibility( | ||
[Package( | ||
"com.reddit.frontpage", arrayOf() | ||
)] | ||
) | ||
@Target(AnnotationTarget.CLASS) | ||
@Retention(AnnotationRetention.RUNTIME) | ||
internal annotation class PremiumIconCompatibility |
24 changes: 24 additions & 0 deletions
24
...lin/app/revanced/patches/reddit/layout/premiumicon/fingerprints/PremiumIconFingerprint.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,24 @@ | ||
package app.revanced.patches.reddit.layout.premiumicon.fingerprints | ||
|
||
import app.revanced.patcher.annotation.Name | ||
import app.revanced.patcher.annotation.Version | ||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint | ||
import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod | ||
import app.revanced.patches.reddit.layout.premiumicon.annotations.PremiumIconCompatibility | ||
|
||
@Name("premium-icon-fingerprint") | ||
@MatchingMethod( | ||
"Lcom/reddit/domain/model/MyAccount;", "isPremiumSubscriber" | ||
) | ||
@PremiumIconCompatibility | ||
@Version("0.0.1") | ||
object PremiumIconFingerprint : MethodFingerprint( | ||
"Z", | ||
null, | ||
null, | ||
null, | ||
null, | ||
{ methodDef -> | ||
methodDef.definingClass.endsWith("MyAccount;") && methodDef.name == "isPremiumSubscriber" | ||
} | ||
) |
32 changes: 32 additions & 0 deletions
32
src/main/kotlin/app/revanced/patches/reddit/layout/premiumicon/patch/PremiumIconPatch.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,32 @@ | ||
package app.revanced.patches.reddit.layout.premiumicon.patch | ||
|
||
import app.revanced.patcher.annotation.Description | ||
import app.revanced.patcher.annotation.Name | ||
import app.revanced.patcher.annotation.Version | ||
import app.revanced.patcher.data.impl.BytecodeData | ||
import app.revanced.patcher.extensions.addInstructions | ||
import app.revanced.patcher.patch.annotations.Patch | ||
import app.revanced.patcher.patch.impl.BytecodePatch | ||
import app.revanced.patcher.patch.PatchResult | ||
import app.revanced.patcher.patch.PatchResultSuccess | ||
import app.revanced.patches.reddit.layout.premiumicon.annotations.PremiumIconCompatibility | ||
import app.revanced.patches.reddit.layout.premiumicon.fingerprints.PremiumIconFingerprint | ||
|
||
@Patch | ||
@Name("premium-icon-reddit") | ||
@Description("Unlocking Premium Icons in reddit app.") | ||
@PremiumIconCompatibility | ||
@Version("0.0.1") | ||
class PremiumIconPatch : BytecodePatch() { | ||
override fun execute(data: BytecodeData): PatchResult { | ||
val method = PremiumIconFingerprint.result!!.mutableMethod | ||
method.addInstructions( | ||
0, | ||
""" | ||
const/4 v0, 0x1 | ||
return v0 | ||
""" | ||
) | ||
return PatchResultSuccess() | ||
} | ||
} |