feat(Sync for Reddit): Add Fix post thumbnails patch

This commit is contained in:
kolpazar
2025-06-03 21:48:24 +02:00
committed by GitHub
parent 9862694564
commit e1ec30c5b0
3 changed files with 47 additions and 0 deletions

View File

@ -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;
}

View File

@ -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;")
}
}

View File

@ -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
"""
)
}
}