Skip to content

Commit

Permalink
feat(youtube/hide-suggested-video-overlay): no longer dependent on `o…
Browse files Browse the repository at this point in the history
…verlay-buttons` patches
  • Loading branch information
inotia00 committed Jul 24, 2023
1 parent a58a05a commit 837a54c
Showing 1 changed file with 19 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,17 @@ import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
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.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.youtube.overlaybutton.general.patch.OverlayButtonsPatch
import app.revanced.patches.youtube.player.suggestedvideooverlay.fingerprints.CoreConatinerBuilderFingerprint
import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility
import app.revanced.patches.youtube.utils.fingerprints.VideoEndFingerprint
import app.revanced.patches.youtube.utils.fingerprints.VideoEndParentFingerprint
import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch
import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.CoreContainer
import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch
Expand All @@ -29,15 +31,17 @@ import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
@Description("Hide the suggested video overlay to play next.")
@DependsOn(
[
OverlayButtonsPatch::class,
SettingsPatch::class,
SharedResourceIdPatch::class
]
)
@YouTubeCompatibility
@Version("0.0.1")
class SuggestedVideoOverlayPatch : BytecodePatch(
listOf(CoreConatinerBuilderFingerprint)
listOf(
CoreConatinerBuilderFingerprint,
VideoEndParentFingerprint
)
) {
override fun execute(context: BytecodeContext): PatchResult {

Expand All @@ -55,11 +59,22 @@ class SuggestedVideoOverlayPatch : BytecodePatch(

addInstruction(
targetIndex,
"invoke-static {v$targetRegister}, $INTEGRATIONS_CLASS_DESCRIPTOR"
"invoke-static {v$targetRegister}, $PLAYER->hideSuggestedVideoOverlay(Landroid/view/ViewGroup;)V"
)
}
} ?: return CoreConatinerBuilderFingerprint.toErrorResult()

VideoEndParentFingerprint.result?.classDef?.let { classDef ->
VideoEndFingerprint.also { it.resolve(context, classDef) }.result?.let {
it.mutableMethod.apply {
addInstruction(
implementation!!.instructions.size - 1,
"invoke-static {},$PLAYER->hideSuggestedVideoOverlay()V"
)
}
} ?: return VideoEndFingerprint.toErrorResult()
} ?: return VideoEndParentFingerprint.toErrorResult()

/**
* Add settings
*/
Expand Down

0 comments on commit 837a54c

Please sign in to comment.