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 be62ca592..e1232527b 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 @@ -4,14 +4,18 @@ 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.extensions.addInstructions +import app.revanced.patcher.extensions.instruction import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch +import app.revanced.patcher.util.smali.ExternalLabel import app.revanced.patches.shared.annotation.YouTubeCompatibility import app.revanced.patches.youtube.misc.litho.patch.LithoFilterPatch import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch +import app.revanced.util.integrations.Constants.BOTTOM_LAYOUT @Patch @Name("hide-button-container") @@ -27,6 +31,42 @@ import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch class ButtonContainerPatch : ResourcePatch { override fun execute(context: ResourceContext): PatchResult { + val instructionList = + """ + move-object/from16 v3, p2 + invoke-static {v3, v10}, $BOTTOM_LAYOUT->hideActionButtons(Ljava/lang/Object;Ljava/nio/ByteBuffer;)Z + move-result v10 + if-eqz v10, :do_not_block + move-object/from16 v15, p1 + invoke-static {v15}, ${LithoFilterPatch.builderMethodDescriptor} + move-result-object v0 + iget-object v0, v0, ${LithoFilterPatch.emptyComponentFieldDescriptor} + return-object v0 + """ + + with(LithoFilterPatch.lithoMethod) { + if (LithoFilterPatch.bufferFingerprintResolved) { + // 18.11.35+ + 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))) + ) + } + } + /* * Add settings */ 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 bb1f1a612..74d658bc0 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 @@ -9,6 +9,7 @@ import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn +import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod import app.revanced.patcher.util.smali.ExternalLabel import app.revanced.patches.shared.annotation.YouTubeCompatibility import app.revanced.patches.shared.fingerprints.LithoBufferFingerprint @@ -27,6 +28,7 @@ import org.jf.dexlib2.iface.instruction.TwoRegisterInstruction import org.jf.dexlib2.iface.instruction.formats.Instruction31i import org.jf.dexlib2.iface.reference.FieldReference import org.jf.dexlib2.iface.reference.MethodReference +import kotlin.properties.Delegates @DependsOn( [ @@ -62,32 +64,32 @@ class LithoFilterPatch : BytecodePatch( LithoFingerprint.result?.let { result -> val endIndex = result.scanResult.patternScanResult!!.endIndex - val method = result.mutableMethod + lithoMethod = result.mutableMethod - with (method.implementation!!.instructions) { + with (lithoMethod.implementation!!.instructions) { // 18.06.41+ val bufferIndex = indexOfFirst { it.opcode == Opcode.CONST && (it as Instruction31i).narrowLiteral == 168777401 } - val bufferRegister = (method.instruction(bufferIndex) as Instruction31i).registerA + 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" } + 2 - val builderMethodDescriptor = (elementAt(targetIndex) as ReferenceInstruction).reference as MethodReference - val emptyComponentFieldDescriptor = (elementAt(targetIndex + 2) as ReferenceInstruction).reference as FieldReference + builderMethodDescriptor = (elementAt(targetIndex) as ReferenceInstruction).reference as MethodReference + emptyComponentFieldDescriptor = (elementAt(targetIndex + 2) as ReferenceInstruction).reference as FieldReference - val identifierRegister = (method.instruction(endIndex) as OneRegisterInstruction).registerA + val identifierRegister = (lithoMethod.instruction(endIndex) as OneRegisterInstruction).registerA filter { instruction -> val fieldReference = (instruction as? ReferenceInstruction)?.reference as? FieldReference fieldReference?.let { it.type == "Ljava/lang/StringBuilder;" } == true }.forEach { instruction -> val insertIndex = indexOf(instruction) - val stringBuilderRegister = (method.instruction(insertIndex) as TwoRegisterInstruction).registerA + val stringBuilderRegister = (lithoMethod.instruction(insertIndex) as TwoRegisterInstruction).registerA val instructionList = """ @@ -107,8 +109,8 @@ class LithoFilterPatch : BytecodePatch( it.opcode == Opcode.CONST_STRING && (it as BuilderInstruction21c).reference.toString() == "" } - 2 - val objectReference = (elementAt(objectIndex) as ReferenceInstruction).reference as FieldReference - method.addInstructions( + objectReference = (elementAt(objectIndex) as ReferenceInstruction).reference as FieldReference + lithoMethod.addInstructions( insertIndex + 1, """ move-object/from16 v$bufferRegister, p3 @@ -116,16 +118,16 @@ class LithoFilterPatch : BytecodePatch( 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", method.instruction(insertIndex + 1))) + """ + instructionList,listOf(ExternalLabel("not_an_ad", lithoMethod.instruction(insertIndex + 1))) ) } else { - val secondParameter = method.parameters[2] - method.addInstructions( + 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", method.instruction(insertIndex + 1))) + """ + instructionList,listOf(ExternalLabel("not_an_ad", lithoMethod.instruction(insertIndex + 1))) ) } } @@ -136,10 +138,14 @@ class LithoFilterPatch : BytecodePatch( return PatchResultSuccess() } - private companion object { - private var objectRegister: Int = 3 - private var bufferFingerprintResolved: Boolean = false + internal companion object { + var objectRegister by Delegates.notNull() + var bufferFingerprintResolved by Delegates.notNull() - private lateinit var bufferReference: String + lateinit var lithoMethod: MutableMethod + lateinit var bufferReference: String + lateinit var builderMethodDescriptor: MethodReference + lateinit var emptyComponentFieldDescriptor: FieldReference + lateinit var objectReference: FieldReference } } diff --git a/src/main/kotlin/app/revanced/util/integrations/Constants.kt b/src/main/kotlin/app/revanced/util/integrations/Constants.kt index 6868efbd3..d25c43552 100644 --- a/src/main/kotlin/app/revanced/util/integrations/Constants.kt +++ b/src/main/kotlin/app/revanced/util/integrations/Constants.kt @@ -11,6 +11,7 @@ internal object Constants { const val GENERAL_LAYOUT = "$PATCHES_PATH/layout/GeneralLayoutPatch;" const val PLAYER_LAYOUT = "$PATCHES_PATH/layout/PlayerLayoutPatch;" const val FULLSCREEN_LAYOUT = "$PATCHES_PATH/layout/FullscreenLayoutPatch;" + const val BOTTOM_LAYOUT = "$PATCHES_PATH/layout/BottomLayoutPatch;" const val FLYOUT_PANEL_LAYOUT = "$PATCHES_PATH/layout/FlyoutPanelLayoutPatch;" const val SEEKBAR_LAYOUT = "$PATCHES_PATH/layout/SeekbarLayoutPatch;" diff --git a/src/main/resources/youtube/settings/host/values/strings.xml b/src/main/resources/youtube/settings/host/values/strings.xml index 0f913a005..61e9a8620 100644 --- a/src/main/resources/youtube/settings/host/values/strings.xml +++ b/src/main/resources/youtube/settings/host/values/strings.xml @@ -268,6 +268,8 @@ Is it ready to submit?" Action buttons are shown Action buttons are hidden Hide action buttons + "These features are outdated. So, even if a issue exists, there are no plans to fix it. +Please do not report any issues you encounter while using this feature." Autoplay button is shown Autoplay button is hidden Hide autoplay button @@ -280,6 +282,9 @@ Is it ready to submit?" Auto player popup panels are shown Auto player popup panels are hidden Hide auto player popup panels + Clip button is shown + Clip button is hidden + Hide clip button Dislike button is shown Dislike button is hidden Hide dislike button @@ -289,9 +294,24 @@ Is it ready to submit?" Like button is shown Like button is hidden Hide like button + Live chat button is shown + Live chat button is hidden + Hide live chat button Playlist button is shown Playlist button is hidden Hide playlist button + Remix button is shown + Remix button is hidden + Hide remix button + Report button is shown + Report button is hidden + Hide report button + Share button is shown + Share button is hidden + Hide share button + Thanks button is shown + Thanks button is hidden + Hide thanks button Captions button is shown Captions button is hidden Hide captions button diff --git a/src/main/resources/youtube/settings/xml/revanced_prefs.xml b/src/main/resources/youtube/settings/xml/revanced_prefs.xml index 698f061fa..09d677315 100644 --- a/src/main/resources/youtube/settings/xml/revanced_prefs.xml +++ b/src/main/resources/youtube/settings/xml/revanced_prefs.xml @@ -245,7 +245,15 @@ - SETTINGS: BUTTON_CONTAINER --> + + + + + + + + + SETTINGS: BUTTON_CONTAINER -->