mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-06-12 05:07:41 +02:00
feat(youtube): add hide-suggested-video-overlay
patch
This commit is contained in:
@ -116,6 +116,7 @@ class HideFilmstripOverlayPatch : BytecodePatch(
|
||||
SettingsPatch.addPreference(
|
||||
arrayOf(
|
||||
"PREFERENCE: PLAYER_SETTINGS",
|
||||
"SETTINGS: PLAYER_EXPERIMENTAL_FLAGS",
|
||||
"SETTINGS: HIDE_FILMSTRIP_OVERLAY"
|
||||
)
|
||||
)
|
||||
|
@ -0,0 +1,17 @@
|
||||
package app.revanced.patches.youtube.player.suggestedvideooverlay.fingerprints
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.CoreContainer
|
||||
import app.revanced.util.bytecode.isWideLiteralExists
|
||||
import org.jf.dexlib2.AccessFlags
|
||||
|
||||
object CoreConatinerBuilderFingerprint : MethodFingerprint(
|
||||
returnType = "Landroid/view/View;",
|
||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
parameters = listOf("Landroid/content/Context;"),
|
||||
customFingerprint = { methodDef, _ ->
|
||||
methodDef.isWideLiteralExists(
|
||||
CoreContainer
|
||||
)
|
||||
})
|
@ -0,0 +1,81 @@
|
||||
package app.revanced.patches.youtube.player.suggestedvideooverlay.patch
|
||||
|
||||
import app.revanced.extensions.toErrorResult
|
||||
import app.revanced.patcher.annotation.Description
|
||||
import app.revanced.patcher.annotation.Name
|
||||
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.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.player.suggestedvideooverlay.fingerprints.CoreConatinerBuilderFingerprint
|
||||
import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility
|
||||
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
|
||||
import app.revanced.util.bytecode.getWideLiteralIndex
|
||||
import app.revanced.util.integrations.Constants.PLAYER
|
||||
import org.jf.dexlib2.iface.instruction.ReferenceInstruction
|
||||
import org.jf.dexlib2.iface.instruction.TwoRegisterInstruction
|
||||
|
||||
@Patch
|
||||
@Name("Hide suggested video overlay")
|
||||
@Description("Hide the suggested video overlay to play next.")
|
||||
@DependsOn(
|
||||
[
|
||||
SettingsPatch::class,
|
||||
SharedResourceIdPatch::class
|
||||
]
|
||||
)
|
||||
@YouTubeCompatibility
|
||||
@Version("0.0.1")
|
||||
class SuggestedVideoOverlayPatch : BytecodePatch(
|
||||
listOf(CoreConatinerBuilderFingerprint)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext): PatchResult {
|
||||
|
||||
CoreConatinerBuilderFingerprint.result?.let {
|
||||
it.mutableMethod.apply {
|
||||
val targetIndex = getWideLiteralIndex(CoreContainer) + 4
|
||||
val targetReference =
|
||||
getInstruction<ReferenceInstruction>(targetIndex).reference
|
||||
|
||||
if (!targetReference.toString().endsWith("Landroid/view/ViewGroup;"))
|
||||
return PatchResultError("Reference did not match: $targetReference")
|
||||
|
||||
val targetRegister =
|
||||
getInstruction<TwoRegisterInstruction>(targetIndex).registerA
|
||||
|
||||
addInstruction(
|
||||
targetIndex,
|
||||
"invoke-static {v$targetRegister}, $INTEGRATIONS_CLASS_DESCRIPTOR"
|
||||
)
|
||||
}
|
||||
} ?: return CoreConatinerBuilderFingerprint.toErrorResult()
|
||||
|
||||
/**
|
||||
* Add settings
|
||||
*/
|
||||
SettingsPatch.addPreference(
|
||||
arrayOf(
|
||||
"PREFERENCE: PLAYER_SETTINGS",
|
||||
"SETTINGS: PLAYER_EXPERIMENTAL_FLAGS",
|
||||
"SETTINGS: HIDE_SUGGESTED_VIDEO_OVERLAY"
|
||||
)
|
||||
)
|
||||
|
||||
SettingsPatch.updatePatchStatus("hide-suggested-video-overlay")
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
|
||||
private companion object {
|
||||
const val INTEGRATIONS_CLASS_DESCRIPTOR =
|
||||
"$PLAYER->hideSuggestedVideoOverlay(Landroid/view/ViewGroup;)V"
|
||||
}
|
||||
}
|
@ -35,6 +35,7 @@ class SharedResourceIdPatch : ResourcePatch {
|
||||
var ChannelListSubMenu: Long = -1
|
||||
var CompactLink: Long = -1
|
||||
var ControlsLayoutStub: Long = -1
|
||||
var CoreContainer: Long = -1
|
||||
var DislikeButton: Long = -1
|
||||
var DonationCompanion: Long = -1
|
||||
var EasySeekEduContainer: Long = -1
|
||||
@ -105,6 +106,7 @@ class SharedResourceIdPatch : ResourcePatch {
|
||||
ChannelListSubMenu = find(LAYOUT, "channel_list_sub_menu")
|
||||
CompactLink = find(LAYOUT, "compact_link")
|
||||
ControlsLayoutStub = find(ID, "controls_layout_stub")
|
||||
CoreContainer = find(ID, "core_container")
|
||||
DislikeButton = find(ID, "dislike_button")
|
||||
DonationCompanion = find(LAYOUT, "donation_companion")
|
||||
EasySeekEduContainer = find(ID, "easy_seek_edu_container")
|
||||
|
Reference in New Issue
Block a user