mirror of
https://github.com/revanced/revanced-patches
synced 2024-11-08 16:57:01 +01:00
feat: hide-email-address
patch (#578)
This commit is contained in:
parent
1dd0d16e87
commit
82cb6321be
@ -0,0 +1,13 @@
|
||||
package app.revanced.patches.youtube.layout.personalinformation.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.34.35", "17.34.36", "17.36.37")
|
||||
)]
|
||||
)
|
||||
@Target(AnnotationTarget.CLASS)
|
||||
@Retention(AnnotationRetention.RUNTIME)
|
||||
internal annotation class HideEmailAddressCompatibility
|
@ -0,0 +1,46 @@
|
||||
package app.revanced.patches.youtube.layout.personalinformation.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.personalinformation.annotations.HideEmailAddressCompatibility
|
||||
import org.jf.dexlib2.AccessFlags
|
||||
import org.jf.dexlib2.Opcode
|
||||
|
||||
@Name("account-switcher-accessibility-label-fingerprint")
|
||||
@MatchingMethod("Lqvs;", "mH")
|
||||
@FuzzyPatternScanMethod(3)
|
||||
@HideEmailAddressCompatibility
|
||||
@Version("0.0.1")
|
||||
object AccountSwitcherAccessibilityLabelFingerprint : MethodFingerprint(
|
||||
"V",
|
||||
AccessFlags.PUBLIC or AccessFlags.FINAL or AccessFlags.BRIDGE or AccessFlags.SYNTHETIC,
|
||||
listOf("L", "L"),
|
||||
listOf(
|
||||
Opcode.CHECK_CAST,
|
||||
Opcode.IGET_OBJECT,
|
||||
Opcode.NEW_INSTANCE,
|
||||
Opcode.IGET_OBJECT,
|
||||
Opcode.INVOKE_DIRECT,
|
||||
Opcode.CONST_4,
|
||||
Opcode.INVOKE_INTERFACE,
|
||||
Opcode.IGET,
|
||||
Opcode.CONST_4,
|
||||
Opcode.ADD_INT_2ADDR,
|
||||
Opcode.IF_EQZ,
|
||||
Opcode.IGET_OBJECT,
|
||||
Opcode.IF_NEZ,
|
||||
Opcode.SGET_OBJECT,
|
||||
Opcode.GOTO,
|
||||
Opcode.MOVE_OBJECT,
|
||||
Opcode.INVOKE_STATIC,
|
||||
Opcode.MOVE_RESULT_OBJECT,
|
||||
Opcode.IGET_OBJECT,
|
||||
Opcode.INVOKE_VIRTUAL,
|
||||
Opcode.IGET_OBJECT,
|
||||
Opcode.IGET_OBJECT,
|
||||
)
|
||||
)
|
@ -0,0 +1,76 @@
|
||||
package app.revanced.patches.youtube.layout.personalinformation.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.personalinformation.annotations.HideEmailAddressCompatibility
|
||||
import app.revanced.patches.youtube.layout.personalinformation.fingerprints.AccountSwitcherAccessibilityLabelFingerprint
|
||||
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
|
||||
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
|
||||
import org.jf.dexlib2.Opcode
|
||||
import org.jf.dexlib2.builder.instruction.BuilderInstruction35c
|
||||
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
import org.jf.dexlib2.iface.instruction.WideLiteralInstruction
|
||||
import org.jf.dexlib2.iface.reference.MethodReference
|
||||
|
||||
@Patch
|
||||
@DependsOn([IntegrationsPatch::class, SettingsPatch::class, ResourceMappingResourcePatch::class])
|
||||
@Name("hide-email-address")
|
||||
@Description("Hides the email address in the account switcher.")
|
||||
@HideEmailAddressCompatibility
|
||||
@Version("0.0.1")
|
||||
class HideEmailAddressPatch : BytecodePatch(
|
||||
listOf(
|
||||
AccountSwitcherAccessibilityLabelFingerprint
|
||||
)
|
||||
) {
|
||||
override fun execute(data: BytecodeData): PatchResult {
|
||||
SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(
|
||||
SwitchPreference(
|
||||
"revanced_hide_email_address",
|
||||
StringResource("revanced_hide_email_address_title", "Hide the email address"),
|
||||
false,
|
||||
StringResource("revanced_hide_email_address_summary_on", "Email address is hidden"),
|
||||
StringResource("revanced_hide_email_address_summary_off", "Email address is visible")
|
||||
)
|
||||
)
|
||||
|
||||
val accountSwitcherAccessibilityLabelId =
|
||||
ResourceMappingResourcePatch.resourceMappings.single {
|
||||
it.type == "string" && it.name == "account_switcher_accessibility_label"
|
||||
}.id
|
||||
|
||||
val accountSwitcherAccessibilityLabelMethod = AccountSwitcherAccessibilityLabelFingerprint.result!!.mutableMethod
|
||||
val accountSwitcherAccessibilityLabelInstruction = accountSwitcherAccessibilityLabelMethod.implementation!!.instructions
|
||||
|
||||
val setVisibilityConstIndex = accountSwitcherAccessibilityLabelInstruction.indexOfFirst {
|
||||
(it as? WideLiteralInstruction)?.wideLiteral == accountSwitcherAccessibilityLabelId
|
||||
} - 2
|
||||
|
||||
val setVisibilityConstRegister = (accountSwitcherAccessibilityLabelInstruction[setVisibilityConstIndex] as OneRegisterInstruction).registerA
|
||||
val toggleRegister = (setVisibilityConstRegister - 3)
|
||||
|
||||
accountSwitcherAccessibilityLabelMethod.addInstructions(
|
||||
setVisibilityConstIndex + 1, """
|
||||
invoke-static {}, Lapp/revanced/integrations/patches/HideEmailAddressPatch;->hideEmailAddress()Z
|
||||
move-result v$toggleRegister
|
||||
if-eqz v$toggleRegister, :hide
|
||||
const/16 v$setVisibilityConstRegister, 0x8
|
||||
:hide
|
||||
nop
|
||||
"""
|
||||
)
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user