Skip to content

Commit

Permalink
feat(reddit): add disable-screenshot-popup patch (#2387)
Browse files Browse the repository at this point in the history
Co-authored-by: oSumAtrIX <johan.melkonyan1@web.de>
  • Loading branch information
Aunali321 and oSumAtrIX committed Jun 29, 2023
1 parent 1b66069 commit 473e051
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package app.revanced.patches.reddit.layout.disablescreenshotpopup.annotations

import app.revanced.patcher.annotation.Compatibility
import app.revanced.patcher.annotation.Package

@Compatibility([Package("com.reddit.frontpage")])
@Target(AnnotationTarget.CLASS)
internal annotation class DisableScreenshotPopupCompatibility
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package app.revanced.patches.reddit.layout.disablescreenshotpopup.fingerprints

import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint

object DisableScreenshotPopupFingerprint : MethodFingerprint(
"V",
parameters = listOf("Landroidx/compose/runtime/", "I"),
customFingerprint = custom@{ methodDef, classDef ->
if (!classDef.type.endsWith("\$ScreenshotTakenBannerKt\$lambda-1\$1;"))
return@custom false

methodDef.name == "invoke"
}
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package app.revanced.patches.reddit.layout.disablescreenshotpopup.patch

import app.revanced.extensions.toErrorResult
import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.reddit.layout.disablescreenshotpopup.annotations.DisableScreenshotPopupCompatibility
import app.revanced.patches.reddit.layout.disablescreenshotpopup.fingerprints.DisableScreenshotPopupFingerprint

@Patch
@Name("disable-screenshot-popup")
@Description("Disables the popup that shows up when taking a screenshot.")
@DisableScreenshotPopupCompatibility
@Version("0.0.1")
class DisableScreenshotPopupPatch : BytecodePatch(
listOf(DisableScreenshotPopupFingerprint)
) {
override fun execute(context: BytecodeContext): PatchResult {
DisableScreenshotPopupFingerprint.result?.mutableMethod?.addInstruction(0, "return-void")
?: return DisableScreenshotPopupFingerprint.toErrorResult()

return PatchResultSuccess()
}
}

0 comments on commit 473e051

Please sign in to comment.