mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-08 02:24:35 +02:00
feat(Reddit): add Hide recently visited shelf
patch
This commit is contained in:
parent
b021ab9019
commit
5c39f9108a
@ -0,0 +1,53 @@
|
||||
package app.revanced.patches.reddit.layout.recentlyvisited
|
||||
|
||||
import app.revanced.extensions.exception
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||
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.layout.recentlyvisited.fingerprints.CommunityDrawerPresenterFingerprint
|
||||
import app.revanced.patches.reddit.utils.settings.SettingsBytecodePatch.updateSettingsStatus
|
||||
import app.revanced.patches.reddit.utils.settings.SettingsPatch
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
|
||||
@Patch(
|
||||
name = "Hide recently visited shelf",
|
||||
description = "Hides recently visited shelf in sidebar.",
|
||||
dependencies = [SettingsPatch::class],
|
||||
compatiblePackages = [CompatiblePackage("com.reddit.frontpage")]
|
||||
)
|
||||
@Suppress("unused")
|
||||
object RecentlyVisitedShelfPatch : BytecodePatch(
|
||||
setOf(CommunityDrawerPresenterFingerprint)
|
||||
) {
|
||||
private const val INTEGRATIONS_METHOD_DESCRIPTOR =
|
||||
"Lapp/revanced/reddit/patches/RecentlyVisitedShelfPatch;" +
|
||||
"->hideRecentlyVisitedShelf(Ljava/util/List;)Ljava/util/List;"
|
||||
|
||||
override fun execute(context: BytecodeContext) {
|
||||
|
||||
CommunityDrawerPresenterFingerprint.result?.let {
|
||||
it.mutableMethod.apply {
|
||||
arrayOf(
|
||||
it.scanResult.patternScanResult!!.endIndex,
|
||||
it.scanResult.patternScanResult!!.startIndex + 3
|
||||
).forEach { insertIndex ->
|
||||
val insertRegister =
|
||||
getInstruction<OneRegisterInstruction>(insertIndex).registerA
|
||||
|
||||
addInstructions(
|
||||
insertIndex, """
|
||||
invoke-static {v$insertRegister}, $INTEGRATIONS_METHOD_DESCRIPTOR
|
||||
move-result-object v$insertRegister
|
||||
"""
|
||||
)
|
||||
}
|
||||
}
|
||||
} ?: throw CommunityDrawerPresenterFingerprint.exception
|
||||
|
||||
updateSettingsStatus("RecentlyVisitedShelf")
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package app.revanced.patches.reddit.layout.recentlyvisited.fingerprints
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.MethodFingerprint
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
|
||||
object CommunityDrawerPresenterFingerprint : MethodFingerprint(
|
||||
returnType = "V",
|
||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
parameters = emptyList(),
|
||||
opcodes = listOf(
|
||||
Opcode.XOR_INT_2ADDR,
|
||||
Opcode.INVOKE_STATIC,
|
||||
Opcode.MOVE_RESULT_OBJECT,
|
||||
Opcode.CHECK_CAST,
|
||||
Opcode.IGET_OBJECT,
|
||||
Opcode.IGET_OBJECT,
|
||||
Opcode.INVOKE_STATIC,
|
||||
Opcode.MOVE_RESULT_OBJECT,
|
||||
Opcode.CHECK_CAST
|
||||
),
|
||||
customFingerprint = { methodDef, _ ->
|
||||
methodDef.definingClass.endsWith("/CommunityDrawerPresenter;")
|
||||
}
|
||||
)
|
Loading…
x
Reference in New Issue
Block a user