diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/general/categorybar/fingerprints/SearchResultsChipBarFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/general/categorybar/fingerprints/SearchResultsChipBarFingerprint.kt
new file mode 100644
index 000000000..b8ec6d437
--- /dev/null
+++ b/src/main/kotlin/app/revanced/patches/youtube/layout/general/categorybar/fingerprints/SearchResultsChipBarFingerprint.kt
@@ -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
+ }
+)
\ No newline at end of file
diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/general/categorybar/patch/CategoryBarPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/general/categorybar/patch/CategoryBarPatch.kt
index 920a0f976..4c1b3bc11 100644
--- a/src/main/kotlin/app/revanced/patches/youtube/layout/general/categorybar/patch/CategoryBarPatch.kt
+++ b/src/main/kotlin/app/revanced/patches/youtube/layout/general/categorybar/patch/CategoryBarPatch.kt
@@ -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
*/
diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/resourceid/patch/SharedResourceIdPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/resourceid/patch/SharedResourceIdPatch.kt
index af8bef174..c526e3ce2 100644
--- a/src/main/kotlin/app/revanced/patches/youtube/misc/resourceid/patch/SharedResourceIdPatch.kt
+++ b/src/main/kotlin/app/revanced/patches/youtube/misc/resourceid/patch/SharedResourceIdPatch.kt
@@ -20,6 +20,7 @@ class SharedResourceIdPatch : ResourcePatch {
var accountSwitcherAccessibilityLabelId: Long = -1
var appearanceStringId: Long = -1
var backgroundCategoryLabelId: Long = -1
+ var barContainerHeightLabelId: Long = -1
var bottomUiContainerResourceId: Long = -1
var chapterRepeatOnResourceId: Long = -1
var compactLinkLabelId: Long = -1
@@ -54,6 +55,7 @@ class SharedResourceIdPatch : ResourcePatch {
accountSwitcherAccessibilityLabelId = findSharedResourceId("string", "account_switcher_accessibility_label")
appearanceStringId = findSharedResourceId("string", "app_theme_appearance_dark")
backgroundCategoryLabelId = findSharedResourceId("string", "pref_background_and_offline_category")
+ barContainerHeightLabelId = findSharedResourceId("dimen", "bar_container_height")
bottomUiContainerResourceId = findSharedResourceId("id", "bottom_ui_container_stub")
chapterRepeatOnResourceId = findSharedResourceId("string", "chapter_repeat_on")
compactLinkLabelId = findSharedResourceId("layout", "compact_link")
diff --git a/src/main/resources/youtube/settings/host/values/strings.xml b/src/main/resources/youtube/settings/host/values/strings.xml
index 61e9a8620..ea1a1de84 100644
--- a/src/main/resources/youtube/settings/host/values/strings.xml
+++ b/src/main/resources/youtube/settings/host/values/strings.xml
@@ -320,6 +320,7 @@ Please do not report any issues you encounter while using this feature."Hide cast button
Hide category bar in feed
Hide category bar in related video
+ Hide category bar in search results
Category bar is shown
Category bar is hidden
Channel watermark is shown
diff --git a/src/main/resources/youtube/settings/xml/revanced_prefs.xml b/src/main/resources/youtube/settings/xml/revanced_prefs.xml
index 09d677315..f4eefc731 100644
--- a/src/main/resources/youtube/settings/xml/revanced_prefs.xml
+++ b/src/main/resources/youtube/settings/xml/revanced_prefs.xml
@@ -118,7 +118,8 @@
+
+ SETTINGS: HIDE_CATEGORY_BAR -->