feat(youtube/hide-shorts-component): hide toolbar in shorts player

This commit is contained in:
inotia00
2023-06-27 01:53:30 +09:00
parent d32d1d340d
commit 7f5be6241a
6 changed files with 69 additions and 4 deletions

View File

@ -15,7 +15,7 @@ import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
import app.revanced.patches.youtube.general.widesearchbar.fingerprints.SetActionBarRingoFingerprint
import app.revanced.patches.youtube.general.widesearchbar.fingerprints.SetToolBarPaddingFingerprint
import app.revanced.patches.youtube.utils.fingerprints.SetToolBarPaddingFingerprint
import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility
import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch
import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch

View File

@ -12,6 +12,7 @@ import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.youtube.shorts.shortsnavigationbar.patch.ShortsNavigationBarPatch
import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility
import app.revanced.patches.youtube.utils.litho.patch.LithoFilterPatch
import app.revanced.patches.youtube.utils.navbarindex.patch.NavBarIndexHookPatch
import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch
import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch
import app.revanced.util.bytecode.BytecodeHelper.updatePatchStatus
@ -23,6 +24,7 @@ import app.revanced.util.integrations.Constants.PATCHES_PATH
@DependsOn(
[
LithoFilterPatch::class,
NavBarIndexHookPatch::class,
SettingsPatch::class,
SharedResourceIdPatch::class,
ShortsCommentButtonPatch::class,
@ -33,7 +35,8 @@ import app.revanced.util.integrations.Constants.PATCHES_PATH
ShortsPaidContentBannerPatch::class,
ShortsRemixButtonPatch::class,
ShortsShareButtonPatch::class,
ShortsSubscriptionsButtonPatch::class
ShortsSubscriptionsButtonPatch::class,
ShortsToolBarPatch::class
]
)
@YouTubeCompatibility

View File

@ -0,0 +1,58 @@
package app.revanced.patches.youtube.shorts.shortscomponent.patch
import app.revanced.extensions.toErrorResult
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.data.toMethodWalker
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultError
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
import app.revanced.patches.youtube.shorts.shortscomponent.fingerprints.ShortsCommentFingerprint
import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility
import app.revanced.patches.youtube.utils.fingerprints.SetToolBarPaddingFingerprint
import app.revanced.patches.youtube.utils.navbarindex.patch.NavBarIndexHookPatch.Companion.injectIndex
import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.ToolBarPaddingHome
import app.revanced.util.bytecode.getWideLiteralIndex
import app.revanced.util.integrations.Constants.SHORTS
import org.jf.dexlib2.iface.instruction.ReferenceInstruction
import org.jf.dexlib2.iface.instruction.TwoRegisterInstruction
@Name("hide-shorts-toolbar")
@YouTubeCompatibility
@Version("0.0.1")
class ShortsToolBarPatch : BytecodePatch(
listOf(
SetToolBarPaddingFingerprint,
ShortsCommentFingerprint
)
) {
override fun execute(context: BytecodeContext): PatchResult {
SetToolBarPaddingFingerprint.result?.let {
val targetIndex = it.mutableMethod.getWideLiteralIndex(ToolBarPaddingHome) + 3
(context.toMethodWalker(it.method)
.nextMethod(targetIndex, true)
.getMethod() as MutableMethod
).apply {
val targetParameter = getInstruction<ReferenceInstruction>(0).reference
if (!targetParameter.toString().endsWith("Landroid/support/v7/widget/Toolbar;"))
return PatchResultError("Method signature parameter did not match: $targetParameter")
val targetRegister = getInstruction<TwoRegisterInstruction>(0).registerA
addInstruction(
1,
"invoke-static {v$targetRegister}, $SHORTS->hideShortsPlayerToolBar(Landroid/support/v7/widget/Toolbar;)V"
)
}
} ?: return SetToolBarPaddingFingerprint.toErrorResult()
ShortsCommentFingerprint.injectIndex(1)
return PatchResultSuccess()
}
}

View File

@ -1,4 +1,4 @@
package app.revanced.patches.youtube.general.widesearchbar.fingerprints
package app.revanced.patches.youtube.utils.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.ToolBarPaddingHome