From db82839a9c47d404aaf829a9e19d87c35cc81c74 Mon Sep 17 00:00:00 2001 From: inotia00 Date: Sun, 23 Jul 2023 01:56:13 +0900 Subject: [PATCH] feat(youtube): add support version `v18.27.35` --- README-template.md | 3 ++- .../patch/HideFullscreenPanelsPatch.kt | 3 ++- .../EmptyFlatBufferFingerprint.kt | 18 +++++++++++++++++ .../mixplaylists/patch/MixPlaylistsPatch.kt | 20 +++++++++---------- .../utils/annotations/YouTubeCompatibility.kt | 3 ++- 5 files changed, 34 insertions(+), 13 deletions(-) create mode 100644 src/main/kotlin/app/revanced/patches/youtube/general/mixplaylists/fingerprints/EmptyFlatBufferFingerprint.kt diff --git a/README-template.md b/README-template.md index 4c06c7b66..11c35ba33 100644 --- a/README-template.md +++ b/README-template.md @@ -32,7 +32,8 @@ Example: "18.22.37", "18.23.36", "18.24.37", - "18.25.40" + "18.25.40", + "18.27.35" ] } ] diff --git a/src/main/kotlin/app/revanced/patches/youtube/fullscreen/fullscreenpanels/patch/HideFullscreenPanelsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/fullscreen/fullscreenpanels/patch/HideFullscreenPanelsPatch.kt index 3a6b37b9a..430039633 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/fullscreen/fullscreenpanels/patch/HideFullscreenPanelsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/fullscreen/fullscreenpanels/patch/HideFullscreenPanelsPatch.kt @@ -24,6 +24,7 @@ import app.revanced.patches.youtube.utils.quickactions.patch.QuickActionsHookPat import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.FullScreenEngagementPanel import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch +import app.revanced.util.bytecode.getNarrowLiteralIndex import app.revanced.util.bytecode.getStringIndex import app.revanced.util.bytecode.getWideLiteralIndex import app.revanced.util.integrations.Constants.FULLSCREEN @@ -84,7 +85,7 @@ class HideFullscreenPanelsPatch : BytecodePatch( LayoutConstructorFingerprint.result?.let { it.mutableMethod.apply { val dummyRegister = - getInstruction(getStringIndex("1.0x")).registerA + getInstruction(getNarrowLiteralIndex(159962)).registerA val invokeIndex = implementation!!.instructions.indexOfFirst { instruction -> instruction.opcode == Opcode.INVOKE_VIRTUAL && diff --git a/src/main/kotlin/app/revanced/patches/youtube/general/mixplaylists/fingerprints/EmptyFlatBufferFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/general/mixplaylists/fingerprints/EmptyFlatBufferFingerprint.kt new file mode 100644 index 000000000..c89ac335d --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/general/mixplaylists/fingerprints/EmptyFlatBufferFingerprint.kt @@ -0,0 +1,18 @@ +package app.revanced.patches.youtube.general.mixplaylists.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 EmptyFlatBufferFingerprint : MethodFingerprint( + returnType = "L", + accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, + opcodes = listOf( + Opcode.INVOKE_VIRTUAL_RANGE, + Opcode.MOVE_RESULT_OBJECT, + Opcode.IGET_BOOLEAN, + Opcode.IF_EQZ + ), + strings = listOf("Failed to convert Element to Flatbuffers: %s") +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/general/mixplaylists/patch/MixPlaylistsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/general/mixplaylists/patch/MixPlaylistsPatch.kt index 052138a3e..cd3d8d799 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/general/mixplaylists/patch/MixPlaylistsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/general/mixplaylists/patch/MixPlaylistsPatch.kt @@ -14,8 +14,8 @@ import app.revanced.patcher.patch.PatchResultSuccess 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.fingerprints.litho.EmptyComponentBuilderFingerprint import app.revanced.patches.youtube.general.mixplaylists.fingerprints.BottomPanelOverlayTextFingerprint +import app.revanced.patches.youtube.general.mixplaylists.fingerprints.EmptyFlatBufferFingerprint import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch import app.revanced.util.bytecode.getStringIndex @@ -33,7 +33,7 @@ import org.jf.dexlib2.iface.instruction.TwoRegisterInstruction class MixPlaylistsPatch : BytecodePatch( listOf( BottomPanelOverlayTextFingerprint, - EmptyComponentBuilderFingerprint + EmptyFlatBufferFingerprint ) ) { override fun execute(context: BytecodeContext): PatchResult { @@ -58,22 +58,22 @@ class MixPlaylistsPatch : BytecodePatch( * Separated from bytebuffer patch * Target method is only used for Hide MixPlaylists patch */ - EmptyComponentBuilderFingerprint.result?.let { + EmptyFlatBufferFingerprint.result?.let { it.mutableMethod.apply { - val freeIndex = implementation!!.instructions.indexOfFirst { instruction -> - instruction.opcode == Opcode.CONST_4 - } + val insertIndex = implementation!!.instructions.indexOfFirst { instruction -> + instruction.opcode == Opcode.CHECK_CAST + } + 1 val jumpIndex = getStringIndex("Failed to convert Element to Flatbuffers: %s") + 2 - val insertIndex = freeIndex + 5 - val freeRegister = getInstruction(freeIndex).registerA + 1 + val freeIndex = it.scanResult.patternScanResult!!.startIndex - 1 + val freeRegister = getInstruction(freeIndex).registerA addInstructionsWithLabels( insertIndex, """ invoke-static {v$freeRegister}, $GENERAL->hideMixPlaylists([B)Z move-result v$freeRegister if-nez v$freeRegister, :not_an_ad - """, ExternalLabel("not_an_ad", getInstruction(jumpIndex)) + """, ExternalLabel("not_an_ad", getInstruction(jumpIndex)) ) addInstruction( @@ -81,7 +81,7 @@ class MixPlaylistsPatch : BytecodePatch( "move-object/from16 v$freeRegister, p3" ) } - } ?: return EmptyComponentBuilderFingerprint.toErrorResult() + } ?: return EmptyFlatBufferFingerprint.toErrorResult() /** * Add settings diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/annotations/YouTubeCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/annotations/YouTubeCompatibility.kt index 24f3de2c9..cb01e59ed 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/annotations/YouTubeCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/annotations/YouTubeCompatibility.kt @@ -11,7 +11,8 @@ import app.revanced.patcher.annotation.Package "18.22.37", "18.23.36", "18.24.37", - "18.25.40" + "18.25.40", + "18.27.35" ) )] )