mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-06-12 21:27:43 +02:00
fix(youtube): separate hide-general-ads
to hide-layout-components
patch
This commit is contained in:
@ -13,18 +13,16 @@ 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.youtube.utils.fingerprints.LayoutConstructorFingerprint
|
||||
import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility
|
||||
import app.revanced.patches.youtube.utils.fingerprints.LayoutConstructorFingerprint
|
||||
import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch
|
||||
import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.AutoNavPreviewStub
|
||||
import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.AutoNavToggle
|
||||
import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch
|
||||
import app.revanced.util.bytecode.getStringIndex
|
||||
import app.revanced.util.bytecode.getWideLiteralIndex
|
||||
import app.revanced.util.integrations.Constants.FULLSCREEN
|
||||
import org.jf.dexlib2.iface.instruction.Instruction
|
||||
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
import org.jf.dexlib2.iface.instruction.ReferenceInstruction
|
||||
import org.jf.dexlib2.iface.reference.FieldReference
|
||||
|
||||
@Patch
|
||||
@Name("hide-autoplay-preview")
|
||||
@ -43,26 +41,17 @@ class HideAutoplayPreviewPatch : BytecodePatch(
|
||||
override fun execute(context: BytecodeContext): PatchResult {
|
||||
LayoutConstructorFingerprint.result?.let {
|
||||
it.mutableMethod.apply {
|
||||
val insertInstruction = implementation!!.instructions
|
||||
|
||||
val dummyRegister =
|
||||
getInstruction<OneRegisterInstruction>(getStringIndex("1.0x")).registerA
|
||||
val insertIndex = getWideLiteralIndex(AutoNavPreviewStub)
|
||||
|
||||
val branchIndex =
|
||||
insertInstruction.subList(insertIndex + 1, insertInstruction.size - 1)
|
||||
.indexOfFirst { instruction ->
|
||||
((instruction as? ReferenceInstruction)?.reference as? FieldReference)?.type == "Lcom/google/android/apps/youtube/app/player/autonav/AutonavToggleController;"
|
||||
} + 1
|
||||
|
||||
val jumpInstruction = getInstruction<Instruction>(insertIndex + branchIndex)
|
||||
val jumpIndex = getWideLiteralIndex(AutoNavToggle) - 1
|
||||
|
||||
addInstructionsWithLabels(
|
||||
insertIndex, """
|
||||
invoke-static {}, $FULLSCREEN->hideAutoPlayPreview()Z
|
||||
move-result v$dummyRegister
|
||||
if-nez v$dummyRegister, :hidden
|
||||
""", ExternalLabel("hidden", jumpInstruction)
|
||||
""", ExternalLabel("hidden", getInstruction(jumpIndex))
|
||||
)
|
||||
}
|
||||
} ?: return LayoutConstructorFingerprint.toErrorResult()
|
||||
|
@ -1,20 +0,0 @@
|
||||
package app.revanced.patches.youtube.fullscreen.compactcontrolsoverlay.fingerprints
|
||||
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.YoutubeControlsOverlay
|
||||
import app.revanced.util.bytecode.isWideLiteralExists
|
||||
import org.jf.dexlib2.Opcode
|
||||
|
||||
object YouTubeControlsOverlayFingerprint : MethodFingerprint(
|
||||
returnType = "V",
|
||||
opcodes = listOf(
|
||||
Opcode.INVOKE_STATIC,
|
||||
Opcode.MOVE_RESULT,
|
||||
Opcode.IF_EQZ
|
||||
),
|
||||
customFingerprint = { it, _ ->
|
||||
it.definingClass.endsWith("YouTubeControlsOverlay;") && it.isWideLiteralExists(
|
||||
YoutubeControlsOverlay
|
||||
)
|
||||
}
|
||||
)
|
@ -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.utils.annotations.YouTubeCompatibility
|
||||
import app.revanced.patches.youtube.fullscreen.compactcontrolsoverlay.fingerprints.YouTubeControlsOverlayFingerprint
|
||||
import app.revanced.patches.youtube.utils.fingerprints.YouTubeControlsOverlayFingerprint
|
||||
import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch
|
||||
import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch
|
||||
import app.revanced.util.integrations.Constants.FULLSCREEN
|
||||
|
@ -6,5 +6,5 @@ import app.revanced.util.bytecode.isWideLiteralExists
|
||||
|
||||
object EndScreenResultsFingerprint : MethodFingerprint(
|
||||
returnType = "V",
|
||||
customFingerprint = { it, _ -> it.isWideLiteralExists(AppRelatedEndScreenResults) }
|
||||
customFingerprint = { methodDef, _ -> methodDef.isWideLiteralExists(AppRelatedEndScreenResults) }
|
||||
)
|
@ -13,8 +13,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.youtube.utils.annotations.YouTubeCompatibility
|
||||
import app.revanced.patches.youtube.fullscreen.endscreenoverlay.fingerprints.EndScreenResultsFingerprint
|
||||
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
|
||||
import app.revanced.util.integrations.Constants.FULLSCREEN
|
||||
|
@ -6,8 +6,9 @@ import app.revanced.util.bytecode.isWideLiteralExists
|
||||
|
||||
object FullscreenEngagementPanelFingerprint : MethodFingerprint(
|
||||
returnType = "L",
|
||||
customFingerprint = { it, _ ->
|
||||
it.definingClass.endsWith("FullscreenEngagementPanelOverlay;") && it.isWideLiteralExists(
|
||||
parameters = listOf("L"),
|
||||
customFingerprint = { methodDef, _ ->
|
||||
methodDef.isWideLiteralExists(
|
||||
FullScreenEngagementPanel
|
||||
)
|
||||
}
|
||||
|
@ -12,5 +12,5 @@ object FullscreenViewAdderFingerprint : MethodFingerprint(
|
||||
Opcode.CONST_4,
|
||||
Opcode.INVOKE_VIRTUAL
|
||||
),
|
||||
customFingerprint = { it, _ -> it.definingClass.endsWith("FullscreenEngagementPanelOverlay;") }
|
||||
customFingerprint = { methodDef, _ -> methodDef.definingClass.endsWith("FullscreenEngagementPanelOverlay;") }
|
||||
)
|
@ -16,10 +16,10 @@ 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.youtube.utils.fingerprints.LayoutConstructorFingerprint
|
||||
import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility
|
||||
import app.revanced.patches.youtube.fullscreen.fullscreenpanels.fingerprints.FullscreenEngagementPanelFingerprint
|
||||
import app.revanced.patches.youtube.fullscreen.fullscreenpanels.fingerprints.FullscreenViewAdderFingerprint
|
||||
import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility
|
||||
import app.revanced.patches.youtube.utils.fingerprints.LayoutConstructorFingerprint
|
||||
import app.revanced.patches.youtube.utils.quickactionscontainer.patch.HideQuickActionsContainerPatch
|
||||
import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch
|
||||
import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.FullScreenEngagementPanel
|
||||
|
@ -13,5 +13,5 @@ object OrientationPrimaryFingerprint : MethodFingerprint(
|
||||
Opcode.INVOKE_STATIC,
|
||||
Opcode.MOVE_RESULT
|
||||
),
|
||||
customFingerprint = { it, _ -> it.name == "<init>" }
|
||||
customFingerprint = { methodDef, _ -> methodDef.name == "<init>" }
|
||||
)
|
@ -14,10 +14,10 @@ import app.revanced.patcher.patch.PatchResult
|
||||
import app.revanced.patcher.patch.PatchResultSuccess
|
||||
import app.revanced.patcher.patch.annotations.DependsOn
|
||||
import app.revanced.patcher.patch.annotations.Patch
|
||||
import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility
|
||||
import app.revanced.patches.youtube.fullscreen.landscapemode.fingerprints.OrientationParentFingerprint
|
||||
import app.revanced.patches.youtube.fullscreen.landscapemode.fingerprints.OrientationPrimaryFingerprint
|
||||
import app.revanced.patches.youtube.fullscreen.landscapemode.fingerprints.OrientationSecondaryFingerprint
|
||||
import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility
|
||||
import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch
|
||||
import app.revanced.util.integrations.Constants.FULLSCREEN
|
||||
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
|
@ -9,17 +9,18 @@ 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.patches.youtube.ads.general.resource.patch.GeneralAdsPatch
|
||||
import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility
|
||||
import app.revanced.patches.youtube.utils.litho.patch.LithoFilterPatch
|
||||
import app.revanced.patches.youtube.utils.quickactionscontainer.patch.HideQuickActionsContainerPatch
|
||||
import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch
|
||||
import app.revanced.util.integrations.Constants.PATCHES_PATH
|
||||
|
||||
@Patch
|
||||
@Name("hide-quick-actions")
|
||||
@Description("Adds the options to hide quick actions components in the fullscreen.")
|
||||
@DependsOn(
|
||||
[
|
||||
GeneralAdsPatch::class,
|
||||
LithoFilterPatch::class,
|
||||
HideQuickActionsContainerPatch::class,
|
||||
SettingsPatch::class
|
||||
]
|
||||
@ -28,6 +29,7 @@ import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch
|
||||
@Version("0.0.1")
|
||||
class QuickActionsPatch : ResourcePatch {
|
||||
override fun execute(context: ResourceContext): PatchResult {
|
||||
LithoFilterPatch.addFilter("$PATCHES_PATH/ads/QuickActionButtonsFilter;")
|
||||
|
||||
/**
|
||||
* Add settings
|
||||
|
Reference in New Issue
Block a user