feat(Twitter): remove Hide view stats patch

The patch is constrained on a version that is not working properly anymore.
This commit is contained in:
oSumAtrIX 2023-07-20 18:43:28 +02:00
parent ae4216776d
commit f0d38001b3
No known key found for this signature in database
GPG Key ID: A9B3094ACDB604B4
7 changed files with 0 additions and 245 deletions

View File

@ -1,12 +0,0 @@
package app.revanced.patches.twitter.layout.hideviews.annotations
import app.revanced.patcher.annotation.Compatibility
import app.revanced.patcher.annotation.Package
@Compatibility(
[Package(
"com.twitter.android", arrayOf("9.69.1-release.0", "9.71.0-release.0")
)]
)
@Target(AnnotationTarget.CLASS)
internal annotation class HideViewsCompatibility

View File

@ -1,15 +0,0 @@
package app.revanced.patches.twitter.layout.hideviews.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.AccessFlags
object InlineActionTypesFingerprint : MethodFingerprint(
returnType = "Ljava/util/List",
accessFlags = AccessFlags.PUBLIC or AccessFlags.STATIC,
strings = listOf(
"getCurrentMemoizing()",
"android_animated_reply_icon_enabled",
"reply_voting_android_position_before_favorite_enabled"
)
)

View File

@ -1,22 +0,0 @@
package app.revanced.patches.twitter.layout.hideviews.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.Opcode
object TweetStatsContainerConstructorFingerprint : MethodFingerprint(
accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR,
parameters = listOf("L"),
opcodes = listOf(
Opcode.INVOKE_DIRECT,
Opcode.IPUT_OBJECT,
Opcode.CONST,
Opcode.INVOKE_VIRTUAL,
Opcode.MOVE_RESULT_OBJECT,
Opcode.CHECK_CAST,
Opcode.CONST_4,
Opcode.INVOKE_VIRTUAL,
Opcode.INVOKE_VIRTUAL
)
)

View File

@ -1,22 +0,0 @@
package app.revanced.patches.twitter.layout.hideviews.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.Opcode
object TweetStatsContainerWrapperConstructorFingerprint : MethodFingerprint(
accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR,
parameters = listOf("L"),
opcodes = listOf(
Opcode.INVOKE_DIRECT,
Opcode.IPUT_OBJECT,
Opcode.NEW_INSTANCE,
Opcode.INVOKE_DIRECT,
Opcode.IPUT_OBJECT,
Opcode.IGET_OBJECT,
Opcode.INVOKE_STATIC,
Opcode.MOVE_RESULT_OBJECT,
Opcode.IPUT_OBJECT
)
)

View File

@ -1,26 +0,0 @@
package app.revanced.patches.twitter.layout.hideviews.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.Opcode
object TweetStatsViewDelegateBinderFingerprint : MethodFingerprint(
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
opcodes = listOf(
Opcode.NEW_INSTANCE,
Opcode.CONST_16,
Opcode.INVOKE_DIRECT,
Opcode.INVOKE_VIRTUAL,
Opcode.MOVE_RESULT_OBJECT,
Opcode.INVOKE_VIRTUAL,
Opcode.IGET_OBJECT,
Opcode.NEW_INSTANCE,
Opcode.CONST_16,
Opcode.INVOKE_DIRECT,
Opcode.INVOKE_VIRTUAL,
Opcode.MOVE_RESULT_OBJECT,
Opcode.INVOKE_VIRTUAL,
Opcode.RETURN_OBJECT
)
)

View File

@ -1,114 +0,0 @@
package app.revanced.patches.twitter.layout.hideviews.patch
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.removeInstruction
import app.revanced.patcher.extensions.InstructionExtensions.removeInstructions
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprintResult
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
import app.revanced.patches.twitter.layout.hideviews.fingerprints.InlineActionTypesFingerprint
import app.revanced.patches.twitter.layout.hideviews.fingerprints.TweetStatsContainerConstructorFingerprint
import app.revanced.patches.twitter.layout.hideviews.fingerprints.TweetStatsContainerWrapperConstructorFingerprint
import app.revanced.patches.twitter.layout.hideviews.fingerprints.TweetStatsViewDelegateBinderFingerprint
import org.jf.dexlib2.Opcode
class HideViewsBytecodePatch : BytecodePatch(
listOf(
InlineActionTypesFingerprint,
TweetStatsContainerWrapperConstructorFingerprint,
TweetStatsContainerConstructorFingerprint,
TweetStatsViewDelegateBinderFingerprint
)
) {
override fun execute(context: BytecodeContext): PatchResult {
removeViewsFromTimeline(context)
removeTweetStatViewInitializer(context)
removeTweetStatViewWrapperInitializer(context)
removeViewDelegateBinderSubscription()
return PatchResultSuccess()
}
private fun removeViewsFromTimeline(context: BytecodeContext) {
val addViewsToActionBarMethodFingerprint = object : MethodFingerprint(
opcodes = listOf(
Opcode.INVOKE_STATIC,
Opcode.MOVE_RESULT,
Opcode.IF_EQZ,
Opcode.SGET_OBJECT,
Opcode.INVOKE_VIRTUAL,
Opcode.IF_EQZ,
)
) {}
transformMethodAtPattern(
context,
InlineActionTypesFingerprint,
addViewsToActionBarMethodFingerprint
) { patternScanResult, method ->
method.removeInstruction(patternScanResult.endIndex - 1)
}
}
private fun removeTweetStatViewInitializer(context: BytecodeContext) {
val returnFingerprint = object : MethodFingerprint(
opcodes = listOf(Opcode.RETURN_VOID)
) {}
transformMethodAtPattern(
context,
TweetStatsContainerConstructorFingerprint,
returnFingerprint
) { patternScanResult, method ->
method.removeInstructions(patternScanResult.endIndex - 3, 3)
}
}
private fun removeTweetStatViewWrapperInitializer(context: BytecodeContext) {
val wrapperReturnFingerprint = object : MethodFingerprint(
opcodes = listOf(
Opcode.IGET_OBJECT,
Opcode.INVOKE_STATIC,
Opcode.MOVE_RESULT_OBJECT,
Opcode.IPUT_OBJECT,
Opcode.RETURN_VOID,
)
) {}
transformMethodAtPattern(
context,
TweetStatsContainerWrapperConstructorFingerprint,
wrapperReturnFingerprint
) { patternScanResult, method ->
method.removeInstructions(patternScanResult.startIndex - 4, 4)
}
}
private fun removeViewDelegateBinderSubscription() {
transformMethod(TweetStatsViewDelegateBinderFingerprint) { result, method ->
method.removeInstructions(result.scanResult.patternScanResult!!.startIndex - 4, 10)
}
}
private fun transformMethodAtPattern(
context: BytecodeContext, methodFingerprint: MethodFingerprint,
patternFingerprint: MethodFingerprint, transformer: TransformerAtPattern
) {
transformMethod(methodFingerprint) { result, method ->
val patternResult = patternFingerprint.also {
it.resolve(context, method, result.classDef)
}.result!!
transformer(patternResult.scanResult.patternScanResult!!, method)
}
}
private fun transformMethod(methodFingerprint: MethodFingerprint, transformer: Transformer) {
val result = methodFingerprint.result!!
val method = result.mutableMethod
transformer(result, method)
}
}
private typealias Transformer = (MethodFingerprintResult, MutableMethod) -> Unit
private typealias TransformerAtPattern = (MethodFingerprintResult.MethodFingerprintScanResult.PatternScanResult, MutableMethod) -> Unit

View File

@ -1,34 +0,0 @@
package app.revanced.patches.twitter.layout.hideviews.patch
import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.*
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.twitter.layout.hideviews.annotations.HideViewsCompatibility
import org.w3c.dom.Element
@Patch
@DependsOn([HideViewsBytecodePatch::class])
@Name("Hide views stats")
@Description("Hides the view stats under tweets.")
@HideViewsCompatibility
@Version("0.0.1")
class HideViewsResourcePatch : ResourcePatch {
override fun execute(context: ResourceContext): PatchResult {
arrayOf(
"res/layout/condensed_tweet_stats.xml",
"res/layout/focal_tweet_stats.xml"
).forEach { file ->
context.xmlEditor[file].use { editor ->
val tags = editor.file.getElementsByTagName("com.twitter.ui.tweet.TweetStatView")
List(tags.length) { tags.item(it) as Element }
.filter { it.getAttribute("android:id").contains("views_stat") }
.forEach { it.parentNode.removeChild(it) }
}
}
return PatchResultSuccess()
}
}