mirror of
https://github.com/revanced/revanced-patches
synced 2024-12-25 06:55:54 +01:00
fix(youtube/hide-info-cards): remove initial popup of info-cards (#992)
Co-authored-by: oSumAtrIX <johan.melkonyan1@web.de>
This commit is contained in:
parent
fb18e9c2ed
commit
d4771f7c9a
@ -1,19 +0,0 @@
|
|||||||
package app.revanced.patches.youtube.ad.infocardsuggestions.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.impl.MethodFingerprint
|
|
||||||
import app.revanced.patches.youtube.ad.infocardsuggestions.annotations.HideInfocardSuggestionsCompatibility
|
|
||||||
import org.jf.dexlib2.AccessFlags
|
|
||||||
|
|
||||||
@Name("hide-infocard-suggestions-fingerprint")
|
|
||||||
@FuzzyPatternScanMethod(2)
|
|
||||||
@HideInfocardSuggestionsCompatibility
|
|
||||||
@Version("0.0.1")
|
|
||||||
object HideInfocardSuggestionsFingerprint : MethodFingerprint(
|
|
||||||
"Ljava/lang/Boolean;",
|
|
||||||
AccessFlags.PUBLIC or AccessFlags.FINAL,
|
|
||||||
strings = listOf("vibrator")
|
|
||||||
)
|
|
@ -1,19 +0,0 @@
|
|||||||
package app.revanced.patches.youtube.ad.infocardsuggestions.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.impl.MethodFingerprint
|
|
||||||
import app.revanced.patches.youtube.ad.infocardsuggestions.annotations.HideInfocardSuggestionsCompatibility
|
|
||||||
import org.jf.dexlib2.AccessFlags
|
|
||||||
|
|
||||||
@Name("hide-infocard-suggestions-parent-fingerprint")
|
|
||||||
@FuzzyPatternScanMethod(2)
|
|
||||||
@HideInfocardSuggestionsCompatibility
|
|
||||||
@Version("0.0.1")
|
|
||||||
object HideInfocardSuggestionsParentFingerprint : MethodFingerprint(
|
|
||||||
"Ljava/lang/String;",
|
|
||||||
AccessFlags.PUBLIC or AccessFlags.FINAL,
|
|
||||||
strings = listOf("player_overlay_info_card_teaser"),
|
|
||||||
)
|
|
@ -1,67 +0,0 @@
|
|||||||
package app.revanced.patches.youtube.ad.infocardsuggestions.patch
|
|
||||||
|
|
||||||
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.replaceInstruction
|
|
||||||
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.ad.infocardsuggestions.annotations.HideInfocardSuggestionsCompatibility
|
|
||||||
import app.revanced.patches.youtube.ad.infocardsuggestions.fingerprints.HideInfocardSuggestionsFingerprint
|
|
||||||
import app.revanced.patches.youtube.ad.infocardsuggestions.fingerprints.HideInfocardSuggestionsParentFingerprint
|
|
||||||
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
|
|
||||||
import org.jf.dexlib2.builder.instruction.BuilderInstruction35c
|
|
||||||
|
|
||||||
@Patch
|
|
||||||
@DependsOn([IntegrationsPatch::class, SettingsPatch::class])
|
|
||||||
@Name("hide-infocard-suggestions")
|
|
||||||
@Description("Hides infocards in videos.")
|
|
||||||
@HideInfocardSuggestionsCompatibility
|
|
||||||
@Version("0.0.1")
|
|
||||||
class HideInfocardSuggestionsPatch : BytecodePatch(
|
|
||||||
listOf(
|
|
||||||
HideInfocardSuggestionsParentFingerprint
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
override fun execute(context: BytecodeContext): PatchResult {
|
|
||||||
SettingsPatch.PreferenceScreen.ADS.addPreferences(
|
|
||||||
SwitchPreference(
|
|
||||||
"revanced_info_cards_enabled",
|
|
||||||
StringResource("revanced_info_cards_enabled_title", "Show info-cards"),
|
|
||||||
false,
|
|
||||||
StringResource("revanced_info_cards_enabled_summary_on", "Info-cards are shown"),
|
|
||||||
StringResource("revanced_info_cards_enabled_summary_off", "Info-cards are hidden")
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
val parentResult = HideInfocardSuggestionsParentFingerprint.result
|
|
||||||
?: return PatchResultError("Parent fingerprint not resolved!")
|
|
||||||
|
|
||||||
|
|
||||||
HideInfocardSuggestionsFingerprint.resolve(context, parentResult.classDef)
|
|
||||||
val result = HideInfocardSuggestionsFingerprint.result
|
|
||||||
?: return PatchResultError("Required parent method could not be found.")
|
|
||||||
|
|
||||||
val method = result.mutableMethod
|
|
||||||
val implementation = method.implementation
|
|
||||||
?: return PatchResultError("Implementation not found.")
|
|
||||||
|
|
||||||
val index = implementation.instructions.indexOfFirst { ((it as? BuilderInstruction35c)?.reference.toString() == "Landroid/view/View;->setVisibility(I)V") }
|
|
||||||
|
|
||||||
method.replaceInstruction(index, """
|
|
||||||
invoke-static {p1}, Lapp/revanced/integrations/patches/HideInfoCardSuggestionsPatch;->hideInfoCardSuggestions(Landroid/view/View;)V
|
|
||||||
""")
|
|
||||||
|
|
||||||
return PatchResultSuccess()
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,4 +1,4 @@
|
|||||||
package app.revanced.patches.youtube.ad.infocardsuggestions.annotations
|
package app.revanced.patches.youtube.layout.hideinfocards.annotations
|
||||||
|
|
||||||
import app.revanced.patcher.annotation.Compatibility
|
import app.revanced.patcher.annotation.Compatibility
|
||||||
import app.revanced.patcher.annotation.Package
|
import app.revanced.patcher.annotation.Package
|
||||||
@ -10,4 +10,4 @@ import app.revanced.patcher.annotation.Package
|
|||||||
)
|
)
|
||||||
@Target(AnnotationTarget.CLASS)
|
@Target(AnnotationTarget.CLASS)
|
||||||
@Retention(AnnotationRetention.RUNTIME)
|
@Retention(AnnotationRetention.RUNTIME)
|
||||||
internal annotation class HideInfocardSuggestionsCompatibility
|
internal annotation class HideInfocardsCompatibility
|
@ -0,0 +1,17 @@
|
|||||||
|
package app.revanced.patches.youtube.layout.hideinfocards.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.impl.MethodFingerprint
|
||||||
|
import app.revanced.patches.youtube.layout.hideinfocards.annotations.HideInfocardsCompatibility
|
||||||
|
import org.jf.dexlib2.AccessFlags
|
||||||
|
|
||||||
|
@Name("infocards-incognito-fingerprint")
|
||||||
|
@HideInfocardsCompatibility
|
||||||
|
@Version("0.0.1")
|
||||||
|
object InfocardsIncognitoFingerprint : MethodFingerprint(
|
||||||
|
"Ljava/lang/Boolean;",
|
||||||
|
AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||||
|
strings = listOf("vibrator")
|
||||||
|
)
|
@ -0,0 +1,17 @@
|
|||||||
|
package app.revanced.patches.youtube.layout.hideinfocards.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.impl.MethodFingerprint
|
||||||
|
import app.revanced.patches.youtube.layout.hideinfocards.annotations.HideInfocardsCompatibility
|
||||||
|
import org.jf.dexlib2.AccessFlags
|
||||||
|
|
||||||
|
@Name("infocards-incognito-parent-fingerprint")
|
||||||
|
@HideInfocardsCompatibility
|
||||||
|
@Version("0.0.1")
|
||||||
|
object InfocardsIncognitoParentFingerprint : MethodFingerprint(
|
||||||
|
"Ljava/lang/String;",
|
||||||
|
AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||||
|
strings = listOf("player_overlay_info_card_teaser"),
|
||||||
|
)
|
@ -0,0 +1,25 @@
|
|||||||
|
package app.revanced.patches.youtube.layout.hideinfocards.fingerprints
|
||||||
|
|
||||||
|
import app.revanced.patcher.annotation.Name
|
||||||
|
import app.revanced.patcher.annotation.Version
|
||||||
|
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||||
|
import app.revanced.patches.youtube.layout.hideinfocards.annotations.HideInfocardsCompatibility
|
||||||
|
import app.revanced.patches.youtube.layout.hideinfocards.resource.patch.HideInfocardsResourcePatch
|
||||||
|
import org.jf.dexlib2.Opcode
|
||||||
|
import org.jf.dexlib2.iface.instruction.WideLiteralInstruction
|
||||||
|
|
||||||
|
@Name("infocards-method-call-fingerprint")
|
||||||
|
@HideInfocardsCompatibility
|
||||||
|
@Version("0.0.1")
|
||||||
|
object InfocardsMethodCallFingerprint : MethodFingerprint(
|
||||||
|
opcodes = listOf(
|
||||||
|
Opcode.INVOKE_VIRTUAL,
|
||||||
|
Opcode.IGET_OBJECT,
|
||||||
|
Opcode.INVOKE_INTERFACE,
|
||||||
|
),
|
||||||
|
customFingerprint = { methodDef ->
|
||||||
|
methodDef.implementation?.instructions?.any { instruction ->
|
||||||
|
(instruction as? WideLiteralInstruction)?.wideLiteral == HideInfocardsResourcePatch.drawerResourceId
|
||||||
|
} == true
|
||||||
|
}
|
||||||
|
)
|
@ -0,0 +1,71 @@
|
|||||||
|
package app.revanced.patches.youtube.layout.hideinfocards.patch
|
||||||
|
|
||||||
|
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.addInstructions
|
||||||
|
import app.revanced.patcher.extensions.instruction
|
||||||
|
import app.revanced.patcher.extensions.replaceInstruction
|
||||||
|
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.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.layout.hideinfocards.annotations.HideInfocardsCompatibility
|
||||||
|
import app.revanced.patches.youtube.layout.hideinfocards.fingerprints.InfocardsIncognitoFingerprint
|
||||||
|
import app.revanced.patches.youtube.layout.hideinfocards.fingerprints.InfocardsMethodCallFingerprint
|
||||||
|
import app.revanced.patches.youtube.layout.hideinfocards.fingerprints.InfocardsIncognitoParentFingerprint
|
||||||
|
import app.revanced.patches.youtube.layout.hideinfocards.resource.patch.HideInfocardsResourcePatch
|
||||||
|
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
|
||||||
|
import org.jf.dexlib2.Opcode
|
||||||
|
import org.jf.dexlib2.builder.instruction.BuilderInstruction35c
|
||||||
|
|
||||||
|
@Patch
|
||||||
|
@DependsOn([IntegrationsPatch::class, HideInfocardsResourcePatch::class])
|
||||||
|
@Name("hide-info-cards")
|
||||||
|
@Description("Hides info-cards in videos.")
|
||||||
|
@HideInfocardsCompatibility
|
||||||
|
@Version("0.0.1")
|
||||||
|
class HideInfocardsPatch : BytecodePatch(
|
||||||
|
listOf(
|
||||||
|
InfocardsIncognitoParentFingerprint,
|
||||||
|
InfocardsMethodCallFingerprint,
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
override fun execute(context: BytecodeContext): PatchResult {
|
||||||
|
with(InfocardsIncognitoFingerprint.also {
|
||||||
|
it.resolve(context, InfocardsIncognitoParentFingerprint.result!!.classDef)
|
||||||
|
}.result!!.mutableMethod) {
|
||||||
|
val invokeInstructionIndex = implementation!!.instructions.indexOfFirst {
|
||||||
|
it.opcode.ordinal == Opcode.INVOKE_VIRTUAL.ordinal &&
|
||||||
|
((it as? BuilderInstruction35c)?.reference.toString() ==
|
||||||
|
"Landroid/view/View;->setVisibility(I)V")
|
||||||
|
}
|
||||||
|
|
||||||
|
replaceInstruction(invokeInstructionIndex, """
|
||||||
|
invoke-static {v${(instruction(invokeInstructionIndex) as? BuilderInstruction35c)?.registerC}}, Lapp/revanced/integrations/patches/HideInfocardsPatch;->hideInfocardsIncognito(Landroid/view/View;)V
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
with(InfocardsMethodCallFingerprint.result!!) {
|
||||||
|
val hideInfocardsCallMethod = mutableMethod
|
||||||
|
|
||||||
|
val invokeInterfaceIndex = scanResult.patternScanResult!!.endIndex
|
||||||
|
val toggleRegister = hideInfocardsCallMethod.implementation!!.registerCount - 1
|
||||||
|
|
||||||
|
hideInfocardsCallMethod.addInstructions(
|
||||||
|
invokeInterfaceIndex, """
|
||||||
|
invoke-static {}, Lapp/revanced/integrations/patches/HideInfocardsPatch;->hideInfocardsMethodCall()Z
|
||||||
|
move-result v$toggleRegister
|
||||||
|
if-nez v$toggleRegister, :hide_info_cards
|
||||||
|
""", listOf(ExternalLabel("hide_info_cards", hideInfocardsCallMethod.instruction(invokeInterfaceIndex + 1)))
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
return PatchResultSuccess()
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,40 @@
|
|||||||
|
package app.revanced.patches.youtube.layout.hideinfocards.resource.patch
|
||||||
|
|
||||||
|
import app.revanced.patcher.annotation.Version
|
||||||
|
import app.revanced.patcher.data.ResourceContext
|
||||||
|
import app.revanced.patcher.patch.PatchResult
|
||||||
|
import app.revanced.patcher.patch.PatchResultSuccess
|
||||||
|
import app.revanced.patcher.patch.ResourcePatch
|
||||||
|
import app.revanced.patcher.patch.annotations.DependsOn
|
||||||
|
import app.revanced.patches.youtube.layout.hideinfocards.annotations.HideInfocardsCompatibility
|
||||||
|
import app.revanced.patches.youtube.misc.mapping.patch.ResourceMappingResourcePatch
|
||||||
|
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
|
||||||
|
|
||||||
|
@HideInfocardsCompatibility
|
||||||
|
@DependsOn([SettingsPatch::class, ResourceMappingResourcePatch::class])
|
||||||
|
@Version("0.0.1")
|
||||||
|
class HideInfocardsResourcePatch : ResourcePatch {
|
||||||
|
internal companion object {
|
||||||
|
var drawerResourceId: Long = -1
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun execute(context: ResourceContext): PatchResult {
|
||||||
|
SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(
|
||||||
|
SwitchPreference(
|
||||||
|
"revanced_hide_infocards",
|
||||||
|
StringResource("revanced_hide_infocards_title", "Hide info-cards"),
|
||||||
|
true,
|
||||||
|
StringResource("revanced_hide_infocards_summary_on", "Info-cards are hidden"),
|
||||||
|
StringResource("revanced_hide_infocards_summary_off", "Info-cards are shown")
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
drawerResourceId = ResourceMappingResourcePatch.resourceMappings.single {
|
||||||
|
it.type == "id" && it.name == "info_cards_drawer_header"
|
||||||
|
}.id
|
||||||
|
|
||||||
|
return PatchResultSuccess()
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user