Skip to content

Commit

Permalink
feat(Twitter): Hide Banner
Browse files Browse the repository at this point in the history
  • Loading branch information
Swakshan committed Mar 1, 2024
1 parent b3044c3 commit b653c84
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package crimera.patches.twitter.timeline.banner


import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.getInstructions
import app.revanced.patcher.extensions.InstructionExtensions.removeInstruction
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchException
import app.revanced.patcher.patch.annotation.CompatiblePackage
import app.revanced.patcher.patch.annotation.Patch
import com.android.tools.smali.dexlib2.Opcode
import crimera.patches.twitter.timeline.banner.fingerprints.HideBannerFingerprint

@Patch(
name = "Hide Banner",
description = "Hide new post banner",
compatiblePackages = [CompatiblePackage("com.twitter.android")]
,use = false
)
@Suppress("unused")
object HideBannerPatch : BytecodePatch(
setOf(HideBannerFingerprint)
) {
override fun execute(context: BytecodeContext) {
val result = HideBannerFingerprint.result
?: throw PatchException("Fingerprint not found")

val method = result.mutableMethod
val instuctions = method.getInstructions()

val loc = instuctions.first{it.opcode == Opcode.IF_NEZ}.location.index

method.removeInstruction(loc)

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package crimera.patches.twitter.timeline.banner.fingerprints

import app.revanced.patcher.fingerprint.MethodFingerprint
import com.android.tools.smali.dexlib2.Opcode

object HideBannerFingerprint : MethodFingerprint(
returnType = "Z",
opcodes = listOf( Opcode.RETURN),
customFingerprint = {it, _ ->
it.definingClass == "Lcom/twitter/timeline/newtweetsbanner/BaseNewTweetsBannerPresenter;"
}
)

0 comments on commit b653c84

Please sign in to comment.