mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-29 05:10:20 +02:00
rollback: hide-account-menu
patch does not remove 'Your videos' and 'Downloads' menus in the library tab
This commit is contained in:
parent
92f47d94b5
commit
784feb2c7b
@ -1,14 +0,0 @@
|
|||||||
package app.revanced.patches.youtube.layout.general.accountmenu.fingerprints
|
|
||||||
|
|
||||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
|
||||||
import org.jf.dexlib2.Opcode
|
|
||||||
|
|
||||||
object LibraryMenuFingerprint : MethodFingerprint(
|
|
||||||
returnType = "V",
|
|
||||||
parameters = listOf("L", "L"),
|
|
||||||
opcodes = listOf(
|
|
||||||
Opcode.INVOKE_STATIC,
|
|
||||||
Opcode.MOVE_RESULT_OBJECT,
|
|
||||||
Opcode.IGET_OBJECT
|
|
||||||
)
|
|
||||||
)
|
|
@ -1,21 +0,0 @@
|
|||||||
package app.revanced.patches.youtube.layout.general.accountmenu.fingerprints
|
|
||||||
|
|
||||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
|
||||||
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch
|
|
||||||
import org.jf.dexlib2.Opcode
|
|
||||||
import org.jf.dexlib2.iface.instruction.WideLiteralInstruction
|
|
||||||
|
|
||||||
object LibraryMenuParentFingerprint : MethodFingerprint(
|
|
||||||
opcodes = listOf(
|
|
||||||
Opcode.CONST,
|
|
||||||
Opcode.CONST_4,
|
|
||||||
Opcode.INVOKE_VIRTUAL,
|
|
||||||
Opcode.MOVE_RESULT_OBJECT
|
|
||||||
),
|
|
||||||
customFingerprint = { methodDef ->
|
|
||||||
methodDef.implementation?.instructions?.any {
|
|
||||||
it.opcode.ordinal == Opcode.CONST.ordinal &&
|
|
||||||
(it as? WideLiteralInstruction)?.wideLiteral == SharedResourceIdPatch.compactListLabelId
|
|
||||||
} == true
|
|
||||||
}
|
|
||||||
)
|
|
@ -8,14 +8,14 @@ import app.revanced.patcher.data.BytecodeContext
|
|||||||
import app.revanced.patcher.extensions.addInstruction
|
import app.revanced.patcher.extensions.addInstruction
|
||||||
import app.revanced.patcher.extensions.instruction
|
import app.revanced.patcher.extensions.instruction
|
||||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
|
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
|
||||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprintResult
|
|
||||||
import app.revanced.patcher.patch.BytecodePatch
|
import app.revanced.patcher.patch.BytecodePatch
|
||||||
import app.revanced.patcher.patch.PatchResult
|
import app.revanced.patcher.patch.PatchResult
|
||||||
import app.revanced.patcher.patch.PatchResultSuccess
|
import app.revanced.patcher.patch.PatchResultSuccess
|
||||||
import app.revanced.patcher.patch.annotations.DependsOn
|
import app.revanced.patcher.patch.annotations.DependsOn
|
||||||
import app.revanced.patcher.patch.annotations.Patch
|
import app.revanced.patcher.patch.annotations.Patch
|
||||||
import app.revanced.patches.shared.annotation.YouTubeCompatibility
|
import app.revanced.patches.shared.annotation.YouTubeCompatibility
|
||||||
import app.revanced.patches.youtube.layout.general.accountmenu.fingerprints.*
|
import app.revanced.patches.youtube.layout.general.accountmenu.fingerprints.AccountMenuFingerprint
|
||||||
|
import app.revanced.patches.youtube.layout.general.accountmenu.fingerprints.AccountMenuParentFingerprint
|
||||||
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch
|
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch
|
||||||
import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch
|
import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch
|
||||||
import app.revanced.util.integrations.Constants.GENERAL_LAYOUT
|
import app.revanced.util.integrations.Constants.GENERAL_LAYOUT
|
||||||
@ -34,23 +34,34 @@ import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
|||||||
@Version("0.0.1")
|
@Version("0.0.1")
|
||||||
class AccountMenuPatch : BytecodePatch(
|
class AccountMenuPatch : BytecodePatch(
|
||||||
listOf(
|
listOf(
|
||||||
AccountMenuParentFingerprint,
|
AccountMenuParentFingerprint
|
||||||
LibraryMenuParentFingerprint
|
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
override fun execute(context: BytecodeContext): PatchResult {
|
override fun execute(context: BytecodeContext): PatchResult {
|
||||||
|
|
||||||
AccountMenuParentFingerprint.result?.let { parentResult ->
|
AccountMenuParentFingerprint.result?.let { parentResult ->
|
||||||
AccountMenuFingerprint.also { it.resolve(context, parentResult.classDef) }.result?.let {
|
AccountMenuFingerprint.also { it.resolve(context, parentResult.classDef) }.result?.let {
|
||||||
insert(parentResult, it, "hideAccountMenu", "compactLink")
|
with (it.mutableMethod) {
|
||||||
} ?: return AccountMenuFingerprint.toErrorResult()
|
val targetIndex = it.scanResult.patternScanResult!!.startIndex + 1
|
||||||
} ?: return AccountMenuParentFingerprint.toErrorResult()
|
val register = (instruction(targetIndex) as OneRegisterInstruction).registerA
|
||||||
|
|
||||||
LibraryMenuParentFingerprint.result?.let { parentResult ->
|
addInstruction(
|
||||||
LibraryMenuFingerprint.also { it.resolve(context, parentResult.classDef) }.result?.let {
|
targetIndex + 1,
|
||||||
insert(parentResult, it, "hideLibraryMenu", "libraryList")
|
"invoke-static {v$register}, $GENERAL_LAYOUT->hideAccountMenu(Landroid/text/Spanned;)V"
|
||||||
} ?: return LibraryMenuFingerprint.toErrorResult()
|
)
|
||||||
} ?: return LibraryMenuParentFingerprint.toErrorResult()
|
}
|
||||||
|
} ?: return AccountMenuFingerprint.toErrorResult()
|
||||||
|
|
||||||
|
with (parentResult.mutableMethod) {
|
||||||
|
val endIndex = parentResult.scanResult.patternScanResult!!.endIndex
|
||||||
|
val register = (instruction(endIndex) as OneRegisterInstruction).registerA
|
||||||
|
|
||||||
|
addInstruction(
|
||||||
|
endIndex + 1,
|
||||||
|
"sput-object v$register, $GENERAL_LAYOUT->compactLink:Landroid/view/View;"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
} ?: return AccountMenuParentFingerprint.toErrorResult()
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Add settings
|
* Add settings
|
||||||
@ -66,32 +77,4 @@ class AccountMenuPatch : BytecodePatch(
|
|||||||
|
|
||||||
return PatchResultSuccess()
|
return PatchResultSuccess()
|
||||||
}
|
}
|
||||||
private companion object {
|
}
|
||||||
fun insert(
|
|
||||||
viewResult: MethodFingerprintResult,
|
|
||||||
spanResult: MethodFingerprintResult,
|
|
||||||
targetMethod: String,
|
|
||||||
targetField: String
|
|
||||||
) {
|
|
||||||
with (spanResult.mutableMethod) {
|
|
||||||
val targetIndex = spanResult.scanResult.patternScanResult!!.startIndex + 1
|
|
||||||
val register = (instruction(targetIndex) as OneRegisterInstruction).registerA
|
|
||||||
|
|
||||||
addInstruction(
|
|
||||||
targetIndex + 1,
|
|
||||||
"invoke-static {v$register}, $GENERAL_LAYOUT->$targetMethod(Landroid/text/Spanned;)V"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
with (viewResult.mutableMethod) {
|
|
||||||
val endIndex = viewResult.scanResult.patternScanResult!!.endIndex
|
|
||||||
val register = (instruction(endIndex) as OneRegisterInstruction).registerA
|
|
||||||
|
|
||||||
addInstruction(
|
|
||||||
endIndex + 1,
|
|
||||||
"sput-object v$register, $GENERAL_LAYOUT->$targetField:Landroid/view/View;"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -24,7 +24,6 @@ class SharedResourceIdPatch : ResourcePatch {
|
|||||||
var bottomUiContainerResourceId: Long = -1
|
var bottomUiContainerResourceId: Long = -1
|
||||||
var chapterRepeatOnResourceId: Long = -1
|
var chapterRepeatOnResourceId: Long = -1
|
||||||
var compactLinkLabelId: Long = -1
|
var compactLinkLabelId: Long = -1
|
||||||
var compactListLabelId: Long = -1
|
|
||||||
var controlsLayoutStubResourceId: Long = -1
|
var controlsLayoutStubResourceId: Long = -1
|
||||||
var donationCompanionResourceId: Long = -1
|
var donationCompanionResourceId: Long = -1
|
||||||
var emptyColorLabelId: Long = -1
|
var emptyColorLabelId: Long = -1
|
||||||
@ -59,7 +58,6 @@ class SharedResourceIdPatch : ResourcePatch {
|
|||||||
bottomUiContainerResourceId = findSharedResourceId("id", "bottom_ui_container_stub")
|
bottomUiContainerResourceId = findSharedResourceId("id", "bottom_ui_container_stub")
|
||||||
chapterRepeatOnResourceId = findSharedResourceId("string", "chapter_repeat_on")
|
chapterRepeatOnResourceId = findSharedResourceId("string", "chapter_repeat_on")
|
||||||
compactLinkLabelId = findSharedResourceId("layout", "compact_link")
|
compactLinkLabelId = findSharedResourceId("layout", "compact_link")
|
||||||
compactListLabelId = findSharedResourceId("layout", "compact_list_item")
|
|
||||||
controlsLayoutStubResourceId = findSharedResourceId("id", "controls_layout_stub")
|
controlsLayoutStubResourceId = findSharedResourceId("id", "controls_layout_stub")
|
||||||
donationCompanionResourceId = findSharedResourceId("layout", "donation_companion")
|
donationCompanionResourceId = findSharedResourceId("layout", "donation_companion")
|
||||||
emptyColorLabelId = findSharedResourceId("color", "inline_time_bar_colorized_bar_empty_color_dark")
|
emptyColorLabelId = findSharedResourceId("color", "inline_time_bar_colorized_bar_empty_color_dark")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user