-
-
Notifications
You must be signed in to change notification settings - Fork 414
feat(Reddit Is Fun): Add Unlock Platinum
patch and use public Imgur API
#4787
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
@@ -0,0 +1,18 @@ | |||
package app.revanced.patches.reddit.customclients.redditisfun.ads |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Package should be misc not ads
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The file should be called UnlockPlatinumPatch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is no ads the only premium feature? If so then Hide ads
would be more descriptive.
import app.revanced.util.returnEarly | ||
|
||
// Based on: https://github.com/ReVanced/revanced-patches/issues/661#issuecomment-2549674017 | ||
val fakePremiumPatch = bytecodePatch( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The patch should be named unlockPlatinumPatch
// Based on: https://github.com/ReVanced/revanced-patches/issues/661#issuecomment-2549674017 | ||
val fakePremiumPatch = bytecodePatch( | ||
name = "Fake reddit premium", | ||
description = "Allows using pro features without ads." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The description can be removed.
compatibleWith( | ||
"com.andrewshu.android.reddit", | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
compatibleWith( | |
"com.andrewshu.android.reddit", | |
) | |
compatibleWith("com.andrewshu.android.reddit") |
new-instance v0, L$androidNetUriBuilder; | ||
invoke-direct {v0}, L$androidNetUriBuilder;-><init>()V | ||
const-string v1, "https" | ||
invoke-virtual {v0, v1}, L$androidNetUriBuilder;->scheme(Ljava/lang/String;)L$androidNetUriBuilder; | ||
move-result-object v0 | ||
const-string v1, "api.imgur.com" | ||
invoke-virtual {v0, v1}, L$androidNetUriBuilder;->authority(Ljava/lang/String;)L$androidNetUriBuilder; | ||
move-result-object v0 | ||
const-string v1, "3" | ||
invoke-virtual {v0, v1}, L$androidNetUriBuilder;->appendPath(Ljava/lang/String;)L$androidNetUriBuilder; | ||
move-result-object v0 | ||
if-eqz p1, :cond_0 | ||
const-string p1, "gallery" | ||
invoke-virtual {v0, p1}, L$androidNetUriBuilder;->appendPath(Ljava/lang/String;)L$androidNetUriBuilder; | ||
:cond_0 | ||
const-string p1, "album" | ||
invoke-virtual {v0, p1}, L$androidNetUriBuilder;->appendPath(Ljava/lang/String;)L$androidNetUriBuilder; | ||
move-result-object p1 | ||
invoke-virtual {p1, p0}, L$androidNetUriBuilder;->appendPath(Ljava/lang/String;)L$androidNetUriBuilder; | ||
move-result-object p0 | ||
const-string v0, "client_id" | ||
const-string v1, "$clientId" | ||
invoke-virtual {p0, v0, v1}, L$androidNetUriBuilder;->appendQueryParameter(Ljava/lang/String;Ljava/lang/String;)L$androidNetUriBuilder; | ||
move-result-object p0 | ||
invoke-virtual {p0}, L$androidNetUriBuilder;->build()Landroid/net/Uri; | ||
move-result-object p0 | ||
return-object p0 | ||
""".trimIndent()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The patch is way too big. Complex patches should be moved into an extension as explained in the patcher docs.
) | ||
|
||
execute { | ||
val m = imgurApiFingerprint.method |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dont use single letters for variables and use .appy and other idiomatic Kotlin APIs.
m.addInstructions(0, """ | ||
new-instance v0, L$androidNetUriBuilder; | ||
invoke-direct {v0}, L$androidNetUriBuilder;-><init>()V |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code should be formatted. Refer to other patches as reference.
// Obtained from: https://s.imgur.com/desktop-assets/js/main.[snip].js | grep apiClientId | ||
default = "546c25a59c58ad7", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No Imgur API client id is probably needed. Imgur has a free public API, refer to Sync's imgur patch.
} | ||
} | ||
|
||
/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment is not necessary/unconventional. Remove it
Unlock Platinum
patch and use public Imgur API
Ideally create two separate PRs for the imgur fix and the unlock platinum patch, otherwise the PR title is weird. |
api.redditisfun.com
endpoint to the public Imgur API. The user can optionally select their own client ID.Closes #661