forked from angelux079/revanced-patches
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(youtube/hide-info-cards): remove initial popup of info-cards (#992)
Co-authored-by: oSumAtrIX <[email protected]>
- Loading branch information
Showing
9 changed files
with
172 additions
and
107 deletions.
There are no files selected for viewing
19 changes: 0 additions & 19 deletions
19
...patches/youtube/ad/infocardsuggestions/fingerprints/HideInfocardSuggestionsFingerprint.kt
This file was deleted.
Oops, something went wrong.
19 changes: 0 additions & 19 deletions
19
...s/youtube/ad/infocardsuggestions/fingerprints/HideInfocardSuggestionsParentFingerprint.kt
This file was deleted.
Oops, something went wrong.
67 changes: 0 additions & 67 deletions
67
...app/revanced/patches/youtube/ad/infocardsuggestions/patch/HideInfocardSuggestionsPatch.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
...vanced/patches/youtube/layout/hideinfocards/fingerprints/InfocardsIncognitoFingerprint.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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") | ||
) |
17 changes: 17 additions & 0 deletions
17
.../patches/youtube/layout/hideinfocards/fingerprints/InfocardsIncognitoParentFingerprint.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"), | ||
) |
25 changes: 25 additions & 0 deletions
25
...anced/patches/youtube/layout/hideinfocards/fingerprints/InfocardsMethodCallFingerprint.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} | ||
) |
71 changes: 71 additions & 0 deletions
71
...main/kotlin/app/revanced/patches/youtube/layout/hideinfocards/patch/HideInfocardsPatch.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
...evanced/patches/youtube/layout/hideinfocards/resource/patch/HideInfocardsResourcePatch.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() | ||
} | ||
} |