diff --git a/api/revanced-patches.api b/api/revanced-patches.api index 10956e60c..25de72baa 100644 --- a/api/revanced-patches.api +++ b/api/revanced-patches.api @@ -550,6 +550,12 @@ public final class app/revanced/patches/reddit/customclients/syncforreddit/detec public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V } +public final class app/revanced/patches/reddit/customclients/syncforreddit/fix/slink/FixSLinksPatch : app/revanced/patcher/patch/BytecodePatch { + public static final field INSTANCE Lapp/revanced/patches/reddit/customclients/syncforreddit/fix/slink/FixSLinksPatch; + public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V + public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V +} + public final class app/revanced/patches/reddit/layout/disablescreenshotpopup/DisableScreenshotPopupPatch : app/revanced/patcher/patch/BytecodePatch { public static final field INSTANCE Lapp/revanced/patches/reddit/layout/disablescreenshotpopup/DisableScreenshotPopupPatch; public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V diff --git a/src/main/kotlin/app/revanced/patches/reddit/customclients/syncforreddit/fix/slink/FixSLinksPatch.kt b/src/main/kotlin/app/revanced/patches/reddit/customclients/syncforreddit/fix/slink/FixSLinksPatch.kt new file mode 100644 index 000000000..09fa4e370 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/reddit/customclients/syncforreddit/fix/slink/FixSLinksPatch.kt @@ -0,0 +1,32 @@ +package app.revanced.patches.reddit.customclients.syncforreddit.fix.slink + +import app.revanced.patcher.data.BytecodeContext +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions +import app.revanced.patcher.patch.BytecodePatch +import app.revanced.patcher.patch.annotation.CompatiblePackage +import app.revanced.patcher.patch.annotation.Patch +import app.revanced.patches.reddit.customclients.syncforreddit.fix.slink.fingerprints.LinkHelperOpenLinkFingerprint +import app.revanced.util.exception + +@Patch( + name = "Fix /s/ links", + description = "Fixes the issue where /s/ links do not work.", + compatiblePackages = [ + CompatiblePackage("com.laurencedawson.reddit_sync"), + CompatiblePackage("com.laurencedawson.reddit_sync.pro"), + CompatiblePackage("com.laurencedawson.reddit_sync.dev") + ], + requiresIntegrations = true +) +object FixSLinksPatch : BytecodePatch( + setOf(LinkHelperOpenLinkFingerprint) +) { + override fun execute(context: BytecodeContext) = + LinkHelperOpenLinkFingerprint.result?.mutableMethod?.addInstructions( + 1, + """ + invoke-static { p3 }, Lapp/revanced/integrations/syncforreddit/FixSLinksPatch;->resolveSLink(Ljava/lang/String;)Ljava/lang/String; + move-result-object p3 + """ + ) ?: throw LinkHelperOpenLinkFingerprint.exception +} diff --git a/src/main/kotlin/app/revanced/patches/reddit/customclients/syncforreddit/fix/slink/fingerprints/LinkHelperOpenLinkFingerprint.kt b/src/main/kotlin/app/revanced/patches/reddit/customclients/syncforreddit/fix/slink/fingerprints/LinkHelperOpenLinkFingerprint.kt new file mode 100644 index 000000000..a84de6b21 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/reddit/customclients/syncforreddit/fix/slink/fingerprints/LinkHelperOpenLinkFingerprint.kt @@ -0,0 +1,7 @@ +package app.revanced.patches.reddit.customclients.syncforreddit.fix.slink.fingerprints + +import app.revanced.patcher.fingerprint.MethodFingerprint + +internal object LinkHelperOpenLinkFingerprint: MethodFingerprint( + strings = listOf("Link title: ") +)