Skip to content

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

null-dev
Copy link

  • Added premium patch from this comment (thanks @Vogtinator!)
    • I also implemented the patch to spoof the golden platinum edition, but it doesn't really seem to do much so I left it out for now. Implementation attached here if somebody wants to add it back in for whatever reason.
  • Add patch to fix imgur albums by switching from the private api.redditisfun.com endpoint to the public Imgur API. The user can optionally select their own client ID.

Closes #661

@@ -0,0 +1,18 @@
package app.revanced.patches.reddit.customclients.redditisfun.ads
Copy link
Member

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

Copy link
Member

@oSumAtrIX oSumAtrIX Apr 14, 2025

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

Copy link
Contributor

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(
Copy link
Member

@oSumAtrIX oSumAtrIX Apr 14, 2025

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."
Copy link
Member

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.

Comment on lines +11 to +13
compatibleWith(
"com.andrewshu.android.reddit",
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
compatibleWith(
"com.andrewshu.android.reddit",
)
compatibleWith("com.andrewshu.android.reddit")

Comment on lines +32 to +59
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())
Copy link
Member

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
Copy link
Member

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.

Comment on lines +31 to +33
m.addInstructions(0, """
new-instance v0, L$androidNetUriBuilder;
invoke-direct {v0}, L$androidNetUriBuilder;-><init>()V
Copy link
Member

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.

Comment on lines +20 to +21
// Obtained from: https://s.imgur.com/desktop-assets/js/main.[snip].js | grep apiClientId
default = "546c25a59c58ad7",
Copy link
Member

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.

}
}

/*
Copy link
Member

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

@oSumAtrIX oSumAtrIX changed the title reddit is fun: Hide ads & fix imgur albums feat(Reddit Is Fun): Add Unlock Platinum patch and use public Imgur API Apr 14, 2025
@oSumAtrIX
Copy link
Member

Ideally create two separate PRs for the imgur fix and the unlock platinum patch, otherwise the PR title is weird.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat(Reddit is fun): Block / hide ads
3 participants