mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-06-12 05:07:41 +02:00
refactor(hide-category-bar
): add Hide category bar in search results
setting
This commit is contained in:
@ -0,0 +1,22 @@
|
||||
package app.revanced.patches.youtube.layout.general.categorybar.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 SearchResultsChipBarFingerprint : MethodFingerprint(
|
||||
opcodes = listOf(
|
||||
Opcode.CONST,
|
||||
Opcode.INVOKE_VIRTUAL,
|
||||
Opcode.MOVE_RESULT,
|
||||
Opcode.INVOKE_VIRTUAL,
|
||||
Opcode.MOVE_RESULT_OBJECT
|
||||
),
|
||||
customFingerprint = { methodDef ->
|
||||
methodDef.implementation?.instructions?.any {
|
||||
it.opcode.ordinal == Opcode.CONST.ordinal &&
|
||||
(it as? WideLiteralInstruction)?.wideLiteral == SharedResourceIdPatch.barContainerHeightLabelId
|
||||
} == true
|
||||
}
|
||||
)
|
@ -16,6 +16,7 @@ import app.revanced.patcher.patch.annotations.Patch
|
||||
import app.revanced.patches.shared.annotation.YouTubeCompatibility
|
||||
import app.revanced.patches.youtube.layout.general.categorybar.fingerprints.FilterBarHeightFingerprint
|
||||
import app.revanced.patches.youtube.layout.general.categorybar.fingerprints.RelatedChipCloudFingerprint
|
||||
import app.revanced.patches.youtube.layout.general.categorybar.fingerprints.SearchResultsChipBarFingerprint
|
||||
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch
|
||||
import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch
|
||||
import app.revanced.util.integrations.Constants.GENERAL_LAYOUT
|
||||
@ -36,7 +37,8 @@ import org.jf.dexlib2.iface.instruction.TwoRegisterInstruction
|
||||
class CategoryBarPatch : BytecodePatch(
|
||||
listOf(
|
||||
FilterBarHeightFingerprint,
|
||||
RelatedChipCloudFingerprint
|
||||
RelatedChipCloudFingerprint,
|
||||
SearchResultsChipBarFingerprint
|
||||
)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext): PatchResult {
|
||||
@ -74,6 +76,23 @@ class CategoryBarPatch : BytecodePatch(
|
||||
}
|
||||
} ?: return RelatedChipCloudFingerprint.toErrorResult()
|
||||
|
||||
/**
|
||||
* Category Bar in search results
|
||||
*/
|
||||
SearchResultsChipBarFingerprint.result?.let {
|
||||
with (it.mutableMethod) {
|
||||
val targetIndex = it.scanResult.patternScanResult!!.endIndex - 2
|
||||
val register = (instruction(targetIndex) as OneRegisterInstruction).registerA
|
||||
|
||||
addInstructions(
|
||||
targetIndex + 1, """
|
||||
invoke-static {v$register}, $GENERAL_LAYOUT->hideCategoryBarInSearchResults(I)I
|
||||
move-result v$register
|
||||
"""
|
||||
)
|
||||
}
|
||||
} ?: return SearchResultsChipBarFingerprint.toErrorResult()
|
||||
|
||||
/*
|
||||
* Add settings
|
||||
*/
|
||||
|
Reference in New Issue
Block a user