diff --git a/patches/api/patches.api b/patches/api/patches.api index 233b3ad9f..978961283 100644 --- a/patches/api/patches.api +++ b/patches/api/patches.api @@ -575,6 +575,10 @@ public final class app/revanced/patches/reddit/customclients/sync/syncforreddit/ public static final fun getFixSLinksPatch ()Lapp/revanced/patcher/patch/BytecodePatch; } +public final class app/revanced/patches/reddit/customclients/sync/syncforreddit/fix/thumbnail/FixPostThumbnailsPatchKt { + public static final fun getFixPostThumbnailsPatch ()Lapp/revanced/patcher/patch/BytecodePatch; +} + public final class app/revanced/patches/reddit/customclients/sync/syncforreddit/fix/user/UseUserEndpointPatchKt { public static final fun getUseUserEndpointPatch ()Lapp/revanced/patcher/patch/BytecodePatch; } diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/syncforreddit/fix/thumbnail/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/syncforreddit/fix/thumbnail/Fingerprints.kt new file mode 100644 index 000000000..7a64031f1 --- /dev/null +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/syncforreddit/fix/thumbnail/Fingerprints.kt @@ -0,0 +1,12 @@ +package app.revanced.patches.reddit.customclients.sync.syncforreddit.fix.thumbnail + +import app.revanced.patcher.fingerprint +import com.android.tools.smali.dexlib2.AccessFlags + +internal val customImageViewLoadFingerprint = fingerprint { + accessFlags(AccessFlags.PUBLIC) + parameters("Ljava/lang/String;", "Z", "Z", "I", "I") + custom { _, classDef -> + classDef.endsWith("CustomImageView;") + } +} diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/syncforreddit/fix/thumbnail/FixPostThumbnailsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/syncforreddit/fix/thumbnail/FixPostThumbnailsPatch.kt new file mode 100644 index 000000000..4ac2fc3d0 --- /dev/null +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/syncforreddit/fix/thumbnail/FixPostThumbnailsPatch.kt @@ -0,0 +1,31 @@ +package app.revanced.patches.reddit.customclients.sync.syncforreddit.fix.thumbnail + +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions +import app.revanced.patcher.patch.bytecodePatch + +@Suppress("unused") +val fixPostThumbnailsPatch = bytecodePatch( + name = "Fix post thumbnails", + description = "Fixes loading post thumbnails by correcting their URLs.", +) { + + compatibleWith( + "com.laurencedawson.reddit_sync", + "com.laurencedawson.reddit_sync.pro", + "com.laurencedawson.reddit_sync.dev" + ) + + // Image URLs contain escaped ampersands (&), let's replace these with unescaped ones (&). + execute { + customImageViewLoadFingerprint.method.addInstructions( + 0, + """ + # url = url.replace("&", "&"); + const-string v0, "&" + const-string v1, "&" + invoke-virtual { p1, v0, v1 }, Ljava/lang/String;->replace(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Ljava/lang/String; + move-result-object p1 + """ + ) + } +}