Skip to content

Commit e1ec30c

Browse files
authored
feat(Sync for Reddit): Add Fix post thumbnails patch
1 parent 9862694 commit e1ec30c

File tree

3 files changed

+47
-0
lines changed

3 files changed

+47
-0
lines changed

patches/api/patches.api

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -575,6 +575,10 @@ public final class app/revanced/patches/reddit/customclients/sync/syncforreddit/
575575
public static final fun getFixSLinksPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
576576
}
577577

578+
public final class app/revanced/patches/reddit/customclients/sync/syncforreddit/fix/thumbnail/FixPostThumbnailsPatchKt {
579+
public static final fun getFixPostThumbnailsPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
580+
}
581+
578582
public final class app/revanced/patches/reddit/customclients/sync/syncforreddit/fix/user/UseUserEndpointPatchKt {
579583
public static final fun getUseUserEndpointPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
580584
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package app.revanced.patches.reddit.customclients.sync.syncforreddit.fix.thumbnail
2+
3+
import app.revanced.patcher.fingerprint
4+
import com.android.tools.smali.dexlib2.AccessFlags
5+
6+
internal val customImageViewLoadFingerprint = fingerprint {
7+
accessFlags(AccessFlags.PUBLIC)
8+
parameters("Ljava/lang/String;", "Z", "Z", "I", "I")
9+
custom { _, classDef ->
10+
classDef.endsWith("CustomImageView;")
11+
}
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package app.revanced.patches.reddit.customclients.sync.syncforreddit.fix.thumbnail
2+
3+
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
4+
import app.revanced.patcher.patch.bytecodePatch
5+
6+
@Suppress("unused")
7+
val fixPostThumbnailsPatch = bytecodePatch(
8+
name = "Fix post thumbnails",
9+
description = "Fixes loading post thumbnails by correcting their URLs.",
10+
) {
11+
12+
compatibleWith(
13+
"com.laurencedawson.reddit_sync",
14+
"com.laurencedawson.reddit_sync.pro",
15+
"com.laurencedawson.reddit_sync.dev"
16+
)
17+
18+
// Image URLs contain escaped ampersands (&), let's replace these with unescaped ones (&).
19+
execute {
20+
customImageViewLoadFingerprint.method.addInstructions(
21+
0,
22+
"""
23+
# url = url.replace("&", "&");
24+
const-string v0, "&"
25+
const-string v1, "&"
26+
invoke-virtual { p1, v0, v1 }, Ljava/lang/String;->replace(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Ljava/lang/String;
27+
move-result-object p1
28+
"""
29+
)
30+
}
31+
}

0 commit comments

Comments
 (0)