feat(YouTube/Hide shorts components): now hiding all shorts toolbar components will hide the entire shorts toolbar

This commit is contained in:
inotia00
2023-10-28 10:01:41 +09:00
parent 12645fe66f
commit 5a11c6ffbb
5 changed files with 47 additions and 4 deletions

View File

@ -10,7 +10,7 @@ import app.revanced.patcher.patch.annotation.CompatiblePackage
import app.revanced.patcher.patch.annotation.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.general.widesearchbar.fingerprints.YouActionBarFingerprint
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch
import app.revanced.patches.youtube.utils.settings.SettingsPatch

View File

@ -2,19 +2,39 @@ package app.revanced.patches.youtube.shorts.shortscomponent
import app.revanced.extensions.exception
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchException
import app.revanced.patcher.patch.annotation.Patch
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
import app.revanced.patcher.util.smali.ExternalLabel
import app.revanced.patches.youtube.shorts.shortscomponent.fingerprints.ShortsCommentFingerprint
import app.revanced.patches.youtube.shorts.shortscomponent.fingerprints.ToolBarBannerFingerprint
import app.revanced.patches.youtube.utils.fingerprints.SetToolBarPaddingFingerprint
import app.revanced.patches.youtube.utils.navbarindex.NavBarIndexHookPatch
import app.revanced.patches.youtube.utils.navbarindex.NavBarIndexHookPatch.injectIndex
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.ToolBarPaddingHome
import app.revanced.patches.youtube.utils.toolbar.ToolBarHookPatch
import app.revanced.util.bytecode.getWideLiteralIndex
import app.revanced.util.integrations.Constants.SHORTS
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
@Patch(dependencies = [ToolBarHookPatch::class])
@Patch(
dependencies =
[
NavBarIndexHookPatch::class,
ToolBarHookPatch::class
]
)
object ShortsToolBarPatch : BytecodePatch(
setOf(ToolBarBannerFingerprint)
setOf(
SetToolBarPaddingFingerprint,
ShortsCommentFingerprint,
ToolBarBannerFingerprint
)
) {
override fun execute(context: BytecodeContext) {
ToolBarBannerFingerprint.result?.let {
@ -37,5 +57,26 @@ object ShortsToolBarPatch : BytecodePatch(
} ?: throw ToolBarBannerFingerprint.exception
ToolBarHookPatch.injectCall("$SHORTS->hideShortsToolBarButton")
SetToolBarPaddingFingerprint.result?.let {
val targetMethod = context
.toMethodWalker(it.method)
.nextMethod(it.mutableMethod.getWideLiteralIndex(ToolBarPaddingHome) + 3, true)
.getMethod() as MutableMethod
targetMethod.apply {
val targetParameter = getInstruction<ReferenceInstruction>(0).reference
if (!targetParameter.toString().endsWith("Landroid/support/v7/widget/Toolbar;"))
throw PatchException("Method signature parameter did not match: $targetParameter")
val targetRegister = getInstruction<TwoRegisterInstruction>(0).registerA
addInstruction(
1,
"invoke-static {v$targetRegister}, $SHORTS->hideShortsToolBar(Landroid/support/v7/widget/Toolbar;)V"
)
}
} ?: throw SetToolBarPaddingFingerprint.exception
ShortsCommentFingerprint.injectIndex(1)
}
}

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.MethodFingerprint
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.ToolBarPaddingHome