From b086822adb3650a6bf00a12db78c3c81f02f3077 Mon Sep 17 00:00:00 2001 From: inotia00 Date: Wed, 3 May 2023 21:53:27 +0900 Subject: [PATCH] drop support for old YouTube versions --- .../shared/annotation/YouTubeCompatibility.kt | 7 --- .../patch/ButtonContainerPatch.kt | 17 ++----- .../quickactions/patch/QuickActionsPatch.kt | 17 ++----- .../misc/litho/patch/LithoFilterPatch.kt | 44 +++++-------------- 4 files changed, 18 insertions(+), 67 deletions(-) diff --git a/src/main/kotlin/app/revanced/patches/shared/annotation/YouTubeCompatibility.kt b/src/main/kotlin/app/revanced/patches/shared/annotation/YouTubeCompatibility.kt index 945e65320..04d761730 100644 --- a/src/main/kotlin/app/revanced/patches/shared/annotation/YouTubeCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/shared/annotation/YouTubeCompatibility.kt @@ -6,17 +6,10 @@ import app.revanced.patcher.annotation.Package @Compatibility( [Package( "com.google.android.youtube", arrayOf( - "18.06.41", - "18.07.35", - "18.08.39", - "18.09.39", - "18.10.37", - "18.11.36", "18.12.35", "18.13.38", "18.14.41", "18.15.40", - "18.16.37", "18.16.39" ) )] diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/buttomplayer/buttoncontainer/patch/ButtonContainerPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/buttomplayer/buttoncontainer/patch/ButtonContainerPatch.kt index fb0d94743..ec34f48ea 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/buttomplayer/buttoncontainer/patch/ButtonContainerPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/buttomplayer/buttoncontainer/patch/ButtonContainerPatch.kt @@ -47,26 +47,15 @@ class ButtonContainerPatch : ResourcePatch { """ with(LithoFilterPatch.lithoMethod) { - if (LithoFilterPatch.bufferFingerprintResolved) { - // 18.11.36+ - addInstructions( - 0, """ + addInstructions( + 0, """ move-object/from16 v10, p3 iget-object v10, v10, ${LithoFilterPatch.objectReference.definingClass}->${LithoFilterPatch.objectReference.name}:${LithoFilterPatch.objectReference.type} if-eqz v10, :do_not_block check-cast v10, ${LithoFilterPatch.bufferReference} iget-object v10, v10, ${LithoFilterPatch.bufferReference}->b:Ljava/nio/ByteBuffer; """ + instructionList,listOf(ExternalLabel("do_not_block", LithoFilterPatch.lithoMethod.instruction(0))) - ) - } else { - val secondParameter = LithoFilterPatch.lithoMethod.parameters[2] - LithoFilterPatch.lithoMethod.addInstructions( - 0, """ - move-object/from16 v10, p3 - iget-object v10, v10, $secondParameter->b:Ljava/nio/ByteBuffer; - """ + instructionList,listOf(ExternalLabel("do_not_block", LithoFilterPatch.lithoMethod.instruction(0))) - ) - } + ) } /* diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/quickactions/patch/QuickActionsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/quickactions/patch/QuickActionsPatch.kt index 518fb7da7..9195c54c8 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/quickactions/patch/QuickActionsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/quickactions/patch/QuickActionsPatch.kt @@ -47,26 +47,15 @@ class QuickActionsPatch : ResourcePatch { """ with(LithoFilterPatch.lithoMethod) { - if (LithoFilterPatch.bufferFingerprintResolved) { - // 18.11.36+ - addInstructions( - 0, """ + addInstructions( + 0, """ move-object/from16 v10, p3 iget-object v10, v10, ${LithoFilterPatch.objectReference.definingClass}->${LithoFilterPatch.objectReference.name}:${LithoFilterPatch.objectReference.type} if-eqz v10, :do_not_block check-cast v10, ${LithoFilterPatch.bufferReference} iget-object v10, v10, ${LithoFilterPatch.bufferReference}->b:Ljava/nio/ByteBuffer; """ + instructionList,listOf(ExternalLabel("do_not_block", LithoFilterPatch.lithoMethod.instruction(0))) - ) - } else { - val secondParameter = LithoFilterPatch.lithoMethod.parameters[2] - LithoFilterPatch.lithoMethod.addInstructions( - 0, """ - move-object/from16 v10, p3 - iget-object v10, v10, $secondParameter->b:Ljava/nio/ByteBuffer; - """ + instructionList,listOf(ExternalLabel("do_not_block", LithoFilterPatch.lithoMethod.instruction(0))) - ) - } + ) } /* diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/litho/patch/LithoFilterPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/litho/patch/LithoFilterPatch.kt index 227aba80a..cb6a72358 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/litho/patch/LithoFilterPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/litho/patch/LithoFilterPatch.kt @@ -47,14 +47,9 @@ class LithoFilterPatch : BytecodePatch( ) { override fun execute(context: BytecodeContext): PatchResult { - try { - with (LithoBufferFingerprint.result!!) { - val startIndex = this.scanResult.patternScanResult!!.startIndex - bufferReference = (this.mutableMethod.instruction(startIndex) as BuilderInstruction21c).reference.toString() - } - bufferFingerprintResolved = true - } catch (_: Exception) { - bufferFingerprintResolved = false + with (LithoBufferFingerprint.result!!) { + val startIndex = this.scanResult.patternScanResult!!.startIndex + bufferReference = (this.mutableMethod.instruction(startIndex) as BuilderInstruction21c).reference.toString() } LithoObjectFingerprint.result?.let { @@ -67,14 +62,12 @@ class LithoFilterPatch : BytecodePatch( lithoMethod = result.mutableMethod with (lithoMethod.implementation!!.instructions) { - // 18.06.41+ val bufferIndex = indexOfFirst { it.opcode == Opcode.CONST && (it as Instruction31i).narrowLiteral == 168777401 } val bufferRegister = (lithoMethod.instruction(bufferIndex) as Instruction31i).registerA - // 18.06.41+ val targetIndex = indexOfFirst { it.opcode == Opcode.CONST_STRING && (it as BuilderInstruction21c).reference.toString() == "Element missing type extension" @@ -103,33 +96,21 @@ class LithoFilterPatch : BytecodePatch( return-object v0 """ - if (bufferFingerprintResolved) { - // 18.11.36+ - val objectIndex = indexOfFirst { - it.opcode == Opcode.CONST_STRING && - (it as BuilderInstruction21c).reference.toString() == "" - } - 2 - objectReference = (elementAt(objectIndex) as ReferenceInstruction).reference as FieldReference - lithoMethod.addInstructions( - insertIndex + 1, - """ + val objectIndex = indexOfFirst { + it.opcode == Opcode.CONST_STRING && + (it as BuilderInstruction21c).reference.toString() == "" + } - 2 + objectReference = (elementAt(objectIndex) as ReferenceInstruction).reference as FieldReference + lithoMethod.addInstructions( + insertIndex + 1, + """ move-object/from16 v$bufferRegister, p3 iget-object v$bufferRegister, v$bufferRegister, ${objectReference.definingClass}->${objectReference.name}:${objectReference.type} if-eqz v$bufferRegister, :not_an_ad check-cast v$bufferRegister, $bufferReference iget-object v$bufferRegister, v$bufferRegister, $bufferReference->b:Ljava/nio/ByteBuffer; """ + instructionList,listOf(ExternalLabel("not_an_ad", lithoMethod.instruction(insertIndex + 1))) - ) - } else { - val secondParameter = lithoMethod.parameters[2] - lithoMethod.addInstructions( - insertIndex + 1, - """ - move-object/from16 v$bufferRegister, p3 - iget-object v$bufferRegister, v$bufferRegister, $secondParameter->b:Ljava/nio/ByteBuffer; - """ + instructionList,listOf(ExternalLabel("not_an_ad", lithoMethod.instruction(insertIndex + 1))) - ) - } + ) } } } ?: return LithoFingerprint.toErrorResult() @@ -140,7 +121,6 @@ class LithoFilterPatch : BytecodePatch( } internal companion object { var objectRegister by Delegates.notNull() - var bufferFingerprintResolved by Delegates.notNull() lateinit var lithoMethod: MutableMethod lateinit var bufferReference: String