mirror of
https://github.com/revanced/revanced-patches
synced 2024-09-02 12:35:16 +02:00
fix(YouTube - Hide layout components): Hide new channel watermark component
This commit is contained in:
parent
894b5c0ebd
commit
cbfd5691d3
@ -2,9 +2,12 @@ package app.revanced.patches.youtube.layout.hide.general
|
|||||||
|
|
||||||
import app.revanced.extensions.exception
|
import app.revanced.extensions.exception
|
||||||
import app.revanced.patcher.data.BytecodeContext
|
import app.revanced.patcher.data.BytecodeContext
|
||||||
|
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
||||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
|
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
|
||||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstructions
|
import app.revanced.patcher.extensions.InstructionExtensions.getInstructions
|
||||||
|
import app.revanced.patcher.extensions.InstructionExtensions.removeInstruction
|
||||||
|
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
|
||||||
import app.revanced.patcher.patch.BytecodePatch
|
import app.revanced.patcher.patch.BytecodePatch
|
||||||
import app.revanced.patcher.patch.annotation.CompatiblePackage
|
import app.revanced.patcher.patch.annotation.CompatiblePackage
|
||||||
import app.revanced.patcher.patch.annotation.Patch
|
import app.revanced.patcher.patch.annotation.Patch
|
||||||
@ -14,6 +17,8 @@ import app.revanced.patches.shared.settings.preference.impl.StringResource
|
|||||||
import app.revanced.patches.shared.settings.preference.impl.SwitchPreference
|
import app.revanced.patches.shared.settings.preference.impl.SwitchPreference
|
||||||
import app.revanced.patches.shared.settings.preference.impl.TextPreference
|
import app.revanced.patches.shared.settings.preference.impl.TextPreference
|
||||||
import app.revanced.patches.youtube.layout.hide.general.fingerprints.ParseElementFromBufferFingerprint
|
import app.revanced.patches.youtube.layout.hide.general.fingerprints.ParseElementFromBufferFingerprint
|
||||||
|
import app.revanced.patches.youtube.layout.hide.general.fingerprints.PlayerOverlayFingerprint
|
||||||
|
import app.revanced.patches.youtube.layout.hide.general.fingerprints.ShowWatermarkFingerprint
|
||||||
import app.revanced.patches.youtube.misc.litho.filter.LithoFilterPatch
|
import app.revanced.patches.youtube.misc.litho.filter.LithoFilterPatch
|
||||||
import app.revanced.patches.youtube.misc.settings.SettingsPatch
|
import app.revanced.patches.youtube.misc.settings.SettingsPatch
|
||||||
import app.revanced.patches.youtube.misc.settings.SettingsPatch.PreferenceScreen
|
import app.revanced.patches.youtube.misc.settings.SettingsPatch.PreferenceScreen
|
||||||
@ -39,7 +44,7 @@ import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
|
|||||||
)
|
)
|
||||||
@Suppress("unused")
|
@Suppress("unused")
|
||||||
object HideLayoutComponentsPatch : BytecodePatch(
|
object HideLayoutComponentsPatch : BytecodePatch(
|
||||||
setOf(ParseElementFromBufferFingerprint)
|
setOf(ParseElementFromBufferFingerprint, PlayerOverlayFingerprint)
|
||||||
) {
|
) {
|
||||||
private const val FILTER_CLASS_DESCRIPTOR =
|
private const val FILTER_CLASS_DESCRIPTOR =
|
||||||
"Lapp/revanced/integrations/patches/components/LayoutComponentsFilter;"
|
"Lapp/revanced/integrations/patches/components/LayoutComponentsFilter;"
|
||||||
@ -58,7 +63,15 @@ object HideLayoutComponentsPatch : BytecodePatch(
|
|||||||
StringResource("revanced_hide_join_membership_button_summary_on", "Button is hidden"),
|
StringResource("revanced_hide_join_membership_button_summary_on", "Button is hidden"),
|
||||||
StringResource("revanced_hide_join_membership_button_summary_off", "Button is shown")
|
StringResource("revanced_hide_join_membership_button_summary_off", "Button is shown")
|
||||||
),
|
),
|
||||||
|
SwitchPreference(
|
||||||
|
"revanced_hide_channel_watermark_title",
|
||||||
|
StringResource(
|
||||||
|
"revanced_hide_channel_watermark_title",
|
||||||
|
"Hide channel watermark in video player"
|
||||||
|
),
|
||||||
|
StringResource("revanced_hide_channel_watermark_title_summary_on", "Watermark is hidden"),
|
||||||
|
StringResource("revanced_hide_channel_watermark_title_summary_off", "Watermark is shown")
|
||||||
|
),
|
||||||
SwitchPreference(
|
SwitchPreference(
|
||||||
"revanced_hide_notify_me_button",
|
"revanced_hide_notify_me_button",
|
||||||
StringResource("revanced_hide_notify_me_button_title", "Hide \\\'Notify me\\\' button"),
|
StringResource("revanced_hide_notify_me_button_title", "Hide \\\'Notify me\\\' button"),
|
||||||
@ -316,5 +329,24 @@ object HideLayoutComponentsPatch : BytecodePatch(
|
|||||||
} ?: throw ParseElementFromBufferFingerprint.exception
|
} ?: throw ParseElementFromBufferFingerprint.exception
|
||||||
|
|
||||||
// endregion
|
// endregion
|
||||||
|
|
||||||
|
// region Watermark (legacy code for old versions of YouTube)
|
||||||
|
|
||||||
|
ShowWatermarkFingerprint.also {
|
||||||
|
it.resolve(context, PlayerOverlayFingerprint.result?.classDef ?: throw PlayerOverlayFingerprint.exception)
|
||||||
|
}.result?.mutableMethod?.apply {
|
||||||
|
val index = implementation!!.instructions.size - 5
|
||||||
|
|
||||||
|
removeInstruction(index)
|
||||||
|
addInstructions(
|
||||||
|
index,
|
||||||
|
"""
|
||||||
|
invoke-static {}, $FILTER_CLASS_DESCRIPTOR->showWatermark()Z
|
||||||
|
move-result p2
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
} ?: throw ShowWatermarkFingerprint.exception
|
||||||
|
|
||||||
|
// endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
package app.revanced.patches.youtube.layout.hide.watermark.fingerprints
|
package app.revanced.patches.youtube.layout.hide.general.fingerprints
|
||||||
|
|
||||||
import app.revanced.patcher.extensions.or
|
import app.revanced.patcher.extensions.or
|
||||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||||
import com.android.tools.smali.dexlib2.AccessFlags
|
import com.android.tools.smali.dexlib2.AccessFlags
|
||||||
|
|
||||||
object HideWatermarkParentFingerprint : MethodFingerprint (
|
object PlayerOverlayFingerprint : MethodFingerprint (
|
||||||
"L", AccessFlags.PUBLIC or AccessFlags.FINAL, strings = listOf("player_overlay_in_video_programming")
|
"L", AccessFlags.PUBLIC or AccessFlags.FINAL, strings = listOf("player_overlay_in_video_programming")
|
||||||
)
|
)
|
@ -1,9 +1,9 @@
|
|||||||
package app.revanced.patches.youtube.layout.hide.watermark.fingerprints
|
package app.revanced.patches.youtube.layout.hide.general.fingerprints
|
||||||
|
|
||||||
import app.revanced.patcher.extensions.or
|
import app.revanced.patcher.extensions.or
|
||||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||||
import com.android.tools.smali.dexlib2.AccessFlags
|
import com.android.tools.smali.dexlib2.AccessFlags
|
||||||
|
|
||||||
object HideWatermarkFingerprint : MethodFingerprint (
|
object ShowWatermarkFingerprint : MethodFingerprint (
|
||||||
"V", AccessFlags.PUBLIC or AccessFlags.FINAL, listOf("L", "L")
|
"V", AccessFlags.PUBLIC or AccessFlags.FINAL, listOf("L", "L")
|
||||||
)
|
)
|
@ -1,68 +0,0 @@
|
|||||||
package app.revanced.patches.youtube.layout.hide.watermark
|
|
||||||
|
|
||||||
import app.revanced.patcher.data.BytecodeContext
|
|
||||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
|
||||||
import app.revanced.patcher.extensions.InstructionExtensions.removeInstruction
|
|
||||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
|
|
||||||
import app.revanced.patcher.patch.BytecodePatch
|
|
||||||
import app.revanced.patcher.patch.PatchException
|
|
||||||
import app.revanced.patcher.patch.annotation.CompatiblePackage
|
|
||||||
import app.revanced.patcher.patch.annotation.Patch
|
|
||||||
import app.revanced.patches.shared.settings.preference.impl.StringResource
|
|
||||||
import app.revanced.patches.shared.settings.preference.impl.SwitchPreference
|
|
||||||
import app.revanced.patches.youtube.layout.hide.watermark.fingerprints.HideWatermarkFingerprint
|
|
||||||
import app.revanced.patches.youtube.layout.hide.watermark.fingerprints.HideWatermarkParentFingerprint
|
|
||||||
import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch
|
|
||||||
import app.revanced.patches.youtube.misc.settings.SettingsPatch
|
|
||||||
|
|
||||||
@Patch(
|
|
||||||
name = "Hide watermark",
|
|
||||||
description = "Hides creator's watermarks on videos.",
|
|
||||||
dependencies = [IntegrationsPatch::class, SettingsPatch::class],
|
|
||||||
compatiblePackages = [
|
|
||||||
CompatiblePackage(
|
|
||||||
"com.google.android.youtube",
|
|
||||||
[
|
|
||||||
"18.16.37",
|
|
||||||
"18.19.35",
|
|
||||||
"18.20.39",
|
|
||||||
"18.23.35",
|
|
||||||
"18.29.38",
|
|
||||||
"18.32.39",
|
|
||||||
"18.37.36",
|
|
||||||
"18.38.44"
|
|
||||||
]
|
|
||||||
)
|
|
||||||
]
|
|
||||||
)
|
|
||||||
@Suppress("unused")
|
|
||||||
object HideWatermarkPatch : BytecodePatch(
|
|
||||||
setOf(HideWatermarkParentFingerprint)
|
|
||||||
) {
|
|
||||||
override fun execute(context: BytecodeContext) {
|
|
||||||
SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(
|
|
||||||
SwitchPreference(
|
|
||||||
"revanced_hide_video_watermark",
|
|
||||||
StringResource("revanced_hide_video_watermark_title", "Hide creator watermark on videos"),
|
|
||||||
StringResource("revanced_hide_video_watermark_summary_on", "Watermark is hidden"),
|
|
||||||
StringResource("revanced_hide_video_watermark_summary_off", "Watermark is shown")
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
HideWatermarkFingerprint.resolve(context, HideWatermarkParentFingerprint.result!!.classDef)
|
|
||||||
val result = HideWatermarkFingerprint.result
|
|
||||||
?: throw PatchException("Required parent method could not be found.")
|
|
||||||
|
|
||||||
val method = result.mutableMethod
|
|
||||||
val line = method.implementation!!.instructions.size - 5
|
|
||||||
|
|
||||||
method.removeInstruction(line)
|
|
||||||
method.addInstructions(
|
|
||||||
line,
|
|
||||||
"""
|
|
||||||
invoke-static {}, Lapp/revanced/integrations/patches/BrandingWaterMarkPatch;->isBrandingWatermarkShown()Z
|
|
||||||
move-result p2
|
|
||||||
"""
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user