remove dead code

This commit is contained in:
inotia00 2023-02-23 19:59:39 +09:00
parent 33b57d58c8
commit 25a0d981b3
6 changed files with 8 additions and 155 deletions

View File

@ -1,27 +0,0 @@
package app.revanced.patches.youtube.layout.general.mixplaylists.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.Opcode
object CreateMixPlaylistFingerprint : MethodFingerprint(
returnType = "V",
access = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR,
parameters = listOf("L", "L", "L", "L", "L", "L", "L"),
opcodes = listOf(
Opcode.INVOKE_DIRECT,
Opcode.IPUT_OBJECT,
Opcode.INVOKE_VIRTUAL,
Opcode.IPUT_OBJECT,
Opcode.IPUT_OBJECT,
Opcode.IPUT_OBJECT,
Opcode.IPUT_OBJECT,
Opcode.NEW_INSTANCE,
Opcode.INVOKE_DIRECT,
Opcode.IPUT_OBJECT,
Opcode.IPUT_OBJECT,
Opcode.IPUT_OBJECT,
Opcode.INVOKE_VIRTUAL
)
)

View File

@ -1,23 +0,0 @@
package app.revanced.patches.youtube.layout.general.mixplaylists.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourcdIdPatch
import org.jf.dexlib2.Opcode
import org.jf.dexlib2.iface.instruction.WideLiteralInstruction
object FourthCreateMixPlaylistFingerprint : MethodFingerprint(
opcodes = listOf(
Opcode.CONST,
Opcode.CONST_4,
Opcode.INVOKE_VIRTUAL,
Opcode.MOVE_RESULT_OBJECT,
Opcode.MOVE_OBJECT,
Opcode.CHECK_CAST
),
customFingerprint = { methodDef ->
methodDef.implementation?.instructions?.any {
it.opcode.ordinal == Opcode.CONST.ordinal &&
(it as? WideLiteralInstruction)?.wideLiteral == SharedResourcdIdPatch.abclistmenuitemLabelId
} == true
}
)

View File

@ -1,27 +0,0 @@
package app.revanced.patches.youtube.layout.general.mixplaylists.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.Opcode
object SecondCreateMixPlaylistFingerprint : MethodFingerprint(
returnType = "V",
access = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR,
parameters = listOf("L", "L", "L", "L", "L", "L"),
opcodes = listOf(
Opcode.INVOKE_DIRECT,
Opcode.IPUT_OBJECT,
Opcode.INVOKE_VIRTUAL,
Opcode.IPUT_OBJECT,
Opcode.IPUT_OBJECT,
Opcode.IPUT_OBJECT,
Opcode.IPUT_OBJECT,
Opcode.NEW_INSTANCE,
Opcode.INVOKE_DIRECT,
Opcode.IPUT_OBJECT,
Opcode.IPUT_OBJECT,
Opcode.INVOKE_VIRTUAL,
Opcode.RETURN_VOID
)
)

View File

@ -1,23 +0,0 @@
package app.revanced.patches.youtube.layout.general.mixplaylists.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourcdIdPatch
import org.jf.dexlib2.Opcode
import org.jf.dexlib2.iface.instruction.WideLiteralInstruction
object ThirdCreateMixPlaylistFingerprint : MethodFingerprint(
opcodes = listOf(
Opcode.INVOKE_STATIC,
Opcode.MOVE_RESULT_OBJECT,
Opcode.CONST_4,
Opcode.INVOKE_VIRTUAL,
Opcode.MOVE_RESULT_OBJECT,
Opcode.IPUT_OBJECT
),
customFingerprint = { methodDef ->
methodDef.implementation?.instructions?.any {
it.opcode.ordinal == Opcode.CONST.ordinal &&
(it as? WideLiteralInstruction)?.wideLiteral == SharedResourcdIdPatch.bottompaneloverlaytextLabelId
} == true
}
)

View File

@ -1,56 +1,32 @@
package app.revanced.patches.youtube.layout.general.mixplaylists.patch
import app.revanced.extensions.injectHideCall
import app.revanced.extensions.toErrorResult
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.instruction
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprintResult
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.patches.shared.annotation.YouTubeCompatibility
import app.revanced.patches.youtube.layout.general.mixplaylists.fingerprints.*
import app.revanced.patches.youtube.misc.litho.patch.LithoFilterPatch
import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch
import org.jf.dexlib2.iface.instruction.Instruction
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
import org.jf.dexlib2.iface.instruction.TwoRegisterInstruction
import org.jf.dexlib2.iface.instruction.formats.Instruction21c
@Patch
@Name("hide-mix-playlists")
@Description("Removes mix playlists from home feed and video player.")
@DependsOn([SettingsPatch::class])
@DependsOn(
[
LithoFilterPatch::class,
SettingsPatch::class
]
)
@YouTubeCompatibility
@Version("0.0.1")
class MixPlaylistsPatch : BytecodePatch(
listOf(
CreateMixPlaylistFingerprint,
SecondCreateMixPlaylistFingerprint,
ThirdCreateMixPlaylistFingerprint,
FourthCreateMixPlaylistFingerprint
)
) {
class MixPlaylistsPatch : BytecodePatch() {
override fun execute(context: BytecodeContext): PatchResult {
arrayOf(
CreateMixPlaylistFingerprint,
SecondCreateMixPlaylistFingerprint
).forEach {
it.result?.addHook() ?: return it.toErrorResult()
}
arrayOf(
ThirdCreateMixPlaylistFingerprint to true,
FourthCreateMixPlaylistFingerprint to false
).map { (fingerprint, boolean) ->
fingerprint.result?.hookMixPlaylists(boolean) ?: return fingerprint.toErrorResult()
}
/*
* Add settings
*/
@ -65,23 +41,4 @@ class MixPlaylistsPatch : BytecodePatch(
return PatchResultSuccess()
}
private fun MethodFingerprintResult.addHook() {
val insertIndex = scanResult.patternScanResult!!.endIndex - 3
val register = (mutableMethod.instruction(insertIndex - 2) as OneRegisterInstruction).registerA
mutableMethod.implementation!!.injectHideCall(insertIndex, register, "layout/GeneralLayoutPatch", "hideMixPlaylists")
}
private fun MethodFingerprintResult.hookMixPlaylists(isThirdFingerprint: Boolean) {
fun getRegister(instruction: Instruction): Int {
if (isThirdFingerprint) return (instruction as TwoRegisterInstruction).registerA
return (instruction as Instruction21c).registerA
}
val endIndex = scanResult.patternScanResult!!.endIndex
val instruction = method.implementation!!.instructions.elementAt(endIndex)
val register = getRegister(instruction)
mutableMethod.implementation!!.injectHideCall(endIndex, register, "layout/GeneralLayoutPatch", "hideMixPlaylists")
}
}

View File

@ -16,12 +16,10 @@ import app.revanced.patches.shared.patch.mapping.ResourceMappingPatch
@Version("0.0.1")
class SharedResourcdIdPatch : ResourcePatch {
internal companion object {
var abclistmenuitemLabelId: Long = -1
var accessibilityProgressTimeLabelId: Long = -1
var accountSwitcherAccessibilityLabelId: Long = -1
var appearanceStringId: Long = -1
var backgroundCategoryLabelId: Long = -1
var bottompaneloverlaytextLabelId: Long = -1
var bottomUiContainerResourceId: Long = -1
var controlsLayoutStubResourceId: Long = -1
var donationCompanionResourceId: Long = -1
@ -47,12 +45,10 @@ class SharedResourcdIdPatch : ResourcePatch {
.resourceMappings
.single { it.type == type && it.name == name }.id
abclistmenuitemLabelId = findSharedResourceId("layout", "abc_list_menu_item_layout")
accessibilityProgressTimeLabelId = findSharedResourceId("string", "accessibility_player_progress_time")
accountSwitcherAccessibilityLabelId = findSharedResourceId("string", "account_switcher_accessibility_label")
appearanceStringId = findSharedResourceId("string", "app_theme_appearance_dark")
backgroundCategoryLabelId = findSharedResourceId("string", "pref_background_and_offline_category")
bottompaneloverlaytextLabelId = findSharedResourceId("id", "bottom_panel_overlay_text")
bottomUiContainerResourceId = findSharedResourceId("id", "bottom_ui_container_stub")
controlsLayoutStubResourceId = findSharedResourceId("id", "controls_layout_stub")
donationCompanionResourceId = findSharedResourceId("layout", "donation_companion")