mirror of
https://github.com/revanced/revanced-patches
synced 2024-12-01 05:52:59 +01:00
feat: disable-auto-player-popup-panels
(#543)
This commit is contained in:
parent
8a7b086087
commit
d1fa2c3bc3
@ -0,0 +1,13 @@
|
||||
package app.revanced.patches.youtube.layout.playerpopuppanels.annotations
|
||||
|
||||
import app.revanced.patcher.annotation.Compatibility
|
||||
import app.revanced.patcher.annotation.Package
|
||||
|
||||
@Compatibility(
|
||||
[Package(
|
||||
"com.google.android.youtube", arrayOf("17.25.34", "17.26.35", "17.27.39", "17.28.34", "17.29.34", "17.32.35", "17.33.42", "17.36.37")
|
||||
)]
|
||||
)
|
||||
@Target(AnnotationTarget.CLASS)
|
||||
@Retention(AnnotationRetention.RUNTIME)
|
||||
internal annotation class PlayerPopupPanelsCompatibility
|
@ -0,0 +1,43 @@
|
||||
package app.revanced.patches.youtube.layout.playerpopuppanels.fingerprints
|
||||
|
||||
import app.revanced.patcher.annotation.Name
|
||||
import app.revanced.patcher.annotation.Version
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod
|
||||
import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import app.revanced.patches.youtube.layout.playerpopuppanels.annotations.PlayerPopupPanelsCompatibility
|
||||
import org.jf.dexlib2.AccessFlags
|
||||
import org.jf.dexlib2.Opcode
|
||||
|
||||
@Name("engagement-player-controller-fingerprint")
|
||||
@MatchingMethod("Lucf;", "L")
|
||||
@FuzzyPatternScanMethod(3)
|
||||
@PlayerPopupPanelsCompatibility
|
||||
@Version("0.0.1")
|
||||
object EngagementPanelControllerFingerprint : MethodFingerprint(
|
||||
"L", AccessFlags.PRIVATE or AccessFlags.FINAL, listOf("L", "L", "Z", "Z", "Z"), listOf(
|
||||
Opcode.MOVE_OBJECT_FROM16,
|
||||
Opcode.MOVE_OBJECT_FROM16,
|
||||
Opcode.MOVE_FROM16,
|
||||
Opcode.IGET_BOOLEAN,
|
||||
Opcode.CONST_4,
|
||||
Opcode.IF_NEZ,
|
||||
Opcode.CONST_STRING,
|
||||
Opcode.INVOKE_STATIC,
|
||||
Opcode.SGET_OBJECT,
|
||||
Opcode.SGET_OBJECT,
|
||||
Opcode.CONST_STRING,
|
||||
Opcode.INVOKE_STATIC,
|
||||
Opcode.RETURN_OBJECT,
|
||||
Opcode.IGET_OBJECT,
|
||||
Opcode.IGET_OBJECT,
|
||||
Opcode.INVOKE_VIRTUAL,
|
||||
Opcode.CONST_4,
|
||||
Opcode.CONST_4,
|
||||
Opcode.CONST_4,
|
||||
Opcode.CONST_4,
|
||||
Opcode.CONST_4,
|
||||
Opcode.CONST_4,
|
||||
)
|
||||
)
|
@ -0,0 +1,59 @@
|
||||
package app.revanced.patches.youtube.layout.playerpopuppanels.patch
|
||||
|
||||
import app.revanced.patcher.annotation.Description
|
||||
import app.revanced.patcher.annotation.Name
|
||||
import app.revanced.patcher.annotation.Version
|
||||
import app.revanced.patcher.data.impl.BytecodeData
|
||||
import app.revanced.patcher.extensions.addInstructions
|
||||
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.patcher.patch.impl.BytecodePatch
|
||||
import app.revanced.patches.youtube.layout.playerpopuppanels.annotations.PlayerPopupPanelsCompatibility
|
||||
import app.revanced.patches.youtube.layout.playerpopuppanels.fingerprints.EngagementPanelControllerFingerprint
|
||||
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
|
||||
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
|
||||
import app.revanced.patches.youtube.misc.settings.framework.components.impl.StringResource
|
||||
import app.revanced.patches.youtube.misc.settings.framework.components.impl.SwitchPreference
|
||||
|
||||
@Patch
|
||||
@DependsOn([IntegrationsPatch::class, SettingsPatch::class])
|
||||
@Name("disable-auto-player-popup-panels")
|
||||
@Description("Disable automatic popup panels (playlist or live chat) on video player.")
|
||||
@PlayerPopupPanelsCompatibility
|
||||
@Version("0.0.1")
|
||||
class PlayerPopupPanelsPatch : BytecodePatch(
|
||||
listOf(
|
||||
EngagementPanelControllerFingerprint
|
||||
)
|
||||
) {
|
||||
override fun execute(data: BytecodeData): PatchResult {
|
||||
SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(
|
||||
SwitchPreference(
|
||||
"revanced_player_popup_panels_enabled",
|
||||
StringResource("revanced_player_popup_panels_title", "Disable player popup panels"),
|
||||
false,
|
||||
StringResource("revanced_player_popup_panels_summary_on", "Player popup panels are enabled"),
|
||||
StringResource("revanced_player_popup_panels_summary_off", "Player popup panels are disabled")
|
||||
)
|
||||
)
|
||||
|
||||
val engagementPanelControllerMethod = EngagementPanelControllerFingerprint.result!!.mutableMethod
|
||||
|
||||
engagementPanelControllerMethod.addInstructions(
|
||||
0, """
|
||||
invoke-static { }, Lapp/revanced/integrations/patches/DisablePlayerPopupPanelsPatch;->disablePlayerPopupPanels()Z
|
||||
move-result v0
|
||||
if-eqz v0, :player_popup_panels
|
||||
if-eqz p4, :player_popup_panels
|
||||
const/4 v0, 0x0
|
||||
return-object v0
|
||||
:player_popup_panels
|
||||
nop
|
||||
"""
|
||||
)
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user