feat(reddit): add disable-screenshot-popup patch (#2387)

Co-authored-by: oSumAtrIX <johan.melkonyan1@web.de>
This commit is contained in:
Aunali321 2023-06-29 06:37:03 +05:30 committed by GitHub
parent 1b66069c02
commit 473e051231
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 53 additions and 1 deletions

View File

@ -4,5 +4,5 @@
<component name="FrameworkDetectionExcludesConfiguration">
<file type="web" url="file://$PROJECT_DIR$" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="azul-17" project-jdk-type="JavaSDK" />
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" project-jdk-name="azul-17" project-jdk-type="JavaSDK" />
</project>

View File

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

View File

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

View File

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