mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-11 12:04:39 +02:00
feat(youtube): add hide-trending-searches
patch
This commit is contained in:
parent
c5fa1aa807
commit
0d3d9bbe9f
@ -0,0 +1,19 @@
|
|||||||
|
package app.revanced.patches.youtube.general.trendingsearches.fingerprints
|
||||||
|
|
||||||
|
import app.revanced.patcher.extensions.or
|
||||||
|
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||||
|
import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.YtOutlineArrowTimeBlack
|
||||||
|
import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.YtOutlineFireBlack
|
||||||
|
import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.YtOutlineSearchBlack
|
||||||
|
import app.revanced.util.bytecode.isWideLiteralExists
|
||||||
|
import org.jf.dexlib2.AccessFlags
|
||||||
|
|
||||||
|
object SearchBarEntryFingerprint : MethodFingerprint(
|
||||||
|
returnType = "L",
|
||||||
|
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||||
|
customFingerprint = { methodDef, _ ->
|
||||||
|
methodDef.isWideLiteralExists(YtOutlineArrowTimeBlack)
|
||||||
|
&& methodDef.isWideLiteralExists(YtOutlineFireBlack)
|
||||||
|
&& methodDef.isWideLiteralExists(YtOutlineSearchBlack)
|
||||||
|
}
|
||||||
|
)
|
@ -0,0 +1,82 @@
|
|||||||
|
package app.revanced.patches.youtube.general.trendingsearches.patch
|
||||||
|
|
||||||
|
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.InstructionExtensions.addInstructions
|
||||||
|
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||||
|
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.youtube.general.trendingsearches.fingerprints.SearchBarEntryFingerprint
|
||||||
|
import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility
|
||||||
|
import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch
|
||||||
|
import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch
|
||||||
|
import app.revanced.util.bytecode.getWideLiteralIndex
|
||||||
|
import app.revanced.util.integrations.Constants.GENERAL
|
||||||
|
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
||||||
|
import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.YtOutlineArrowTimeBlack
|
||||||
|
import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.YtOutlineFireBlack
|
||||||
|
import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.YtOutlineSearchBlack
|
||||||
|
import org.jf.dexlib2.iface.instruction.TwoRegisterInstruction
|
||||||
|
|
||||||
|
@Patch
|
||||||
|
@Name("hide-trending-searches")
|
||||||
|
@Description("Hide trending searches in the search bar.")
|
||||||
|
@DependsOn(
|
||||||
|
[
|
||||||
|
SettingsPatch::class,
|
||||||
|
SharedResourceIdPatch::class
|
||||||
|
]
|
||||||
|
)
|
||||||
|
@YouTubeCompatibility
|
||||||
|
@Version("0.0.1")
|
||||||
|
class TrendingSearchesPatch : BytecodePatch(
|
||||||
|
listOf(SearchBarEntryFingerprint)
|
||||||
|
) {
|
||||||
|
override fun execute(context: BytecodeContext): PatchResult {
|
||||||
|
|
||||||
|
SearchBarEntryFingerprint.result?.let {
|
||||||
|
it.mutableMethod.apply {
|
||||||
|
SearchTerm.values()
|
||||||
|
.map { searchTerm -> getWideLiteralIndex(searchTerm.resourceId) to searchTerm.value }
|
||||||
|
.sortedBy { searchTerm -> searchTerm.first }
|
||||||
|
.reversed()
|
||||||
|
.forEach { (index, value) ->
|
||||||
|
val freeRegister = getInstruction<OneRegisterInstruction>(index).registerA
|
||||||
|
val viewRegister = getInstruction<TwoRegisterInstruction>(index - 1).registerA
|
||||||
|
|
||||||
|
addInstructions(
|
||||||
|
index, """
|
||||||
|
const/4 v$freeRegister, $value
|
||||||
|
invoke-static {v$viewRegister, v$freeRegister}, $GENERAL->hideTrendingSearches(Landroid/widget/ImageView;Z)V
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} ?: return SearchBarEntryFingerprint.toErrorResult()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add settings
|
||||||
|
*/
|
||||||
|
SettingsPatch.addPreference(
|
||||||
|
arrayOf(
|
||||||
|
"PREFERENCE: GENERAL_SETTINGS",
|
||||||
|
"SETTINGS: HIDE_TRENDING_SEARCHES"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
SettingsPatch.updatePatchStatus("hide-trending-searches")
|
||||||
|
|
||||||
|
return PatchResultSuccess()
|
||||||
|
}
|
||||||
|
private enum class SearchTerm(val resourceId: Long, val value: Int) {
|
||||||
|
HISTORY(YtOutlineArrowTimeBlack, 0),
|
||||||
|
SEARCH(YtOutlineSearchBlack, 0),
|
||||||
|
TRENDING(YtOutlineFireBlack, 1)
|
||||||
|
}
|
||||||
|
}
|
@ -81,6 +81,9 @@ class SharedResourceIdPatch : ResourcePatch {
|
|||||||
var VideoZoomIndicatorLayout: Long = -1
|
var VideoZoomIndicatorLayout: Long = -1
|
||||||
var WordMarkHeader: Long = -1
|
var WordMarkHeader: Long = -1
|
||||||
var YoutubeControlsOverlay: Long = -1
|
var YoutubeControlsOverlay: Long = -1
|
||||||
|
var YtOutlineArrowTimeBlack: Long = -1
|
||||||
|
var YtOutlineFireBlack: Long = -1
|
||||||
|
var YtOutlineSearchBlack: Long = -1
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun execute(context: ResourceContext): PatchResult {
|
override fun execute(context: ResourceContext): PatchResult {
|
||||||
@ -148,6 +151,9 @@ class SharedResourceIdPatch : ResourcePatch {
|
|||||||
VideoZoomIndicatorLayout = find(ID, "video_zoom_indicator_layout")
|
VideoZoomIndicatorLayout = find(ID, "video_zoom_indicator_layout")
|
||||||
WordMarkHeader = find(ATTR, "ytWordmarkHeader")
|
WordMarkHeader = find(ATTR, "ytWordmarkHeader")
|
||||||
YoutubeControlsOverlay = find(ID, "youtube_controls_overlay")
|
YoutubeControlsOverlay = find(ID, "youtube_controls_overlay")
|
||||||
|
YtOutlineArrowTimeBlack = find(DRAWABLE, "yt_outline_arrow_time_black_24")
|
||||||
|
YtOutlineFireBlack = find(DRAWABLE, "yt_outline_fire_black_24")
|
||||||
|
YtOutlineSearchBlack = find(DRAWABLE, "yt_outline_search_black_24")
|
||||||
|
|
||||||
return PatchResultSuccess()
|
return PatchResultSuccess()
|
||||||
}
|
}
|
||||||
|
@ -472,6 +472,9 @@ Only available on YouTube v18.24.37+"</string>
|
|||||||
<string name="revanced_hide_time_stamp_summary_off">Time stamp is shown</string>
|
<string name="revanced_hide_time_stamp_summary_off">Time stamp is shown</string>
|
||||||
<string name="revanced_hide_time_stamp_summary_on">Time stamp is hidden</string>
|
<string name="revanced_hide_time_stamp_summary_on">Time stamp is hidden</string>
|
||||||
<string name="revanced_hide_time_stamp_title">Hide time stamp</string>
|
<string name="revanced_hide_time_stamp_title">Hide time stamp</string>
|
||||||
|
<string name="revanced_hide_trending_searches_summary_off">Trending searches are shown</string>
|
||||||
|
<string name="revanced_hide_trending_searches_summary_on">Trending searches are hidden</string>
|
||||||
|
<string name="revanced_hide_trending_searches_title">Hide trending searches</string>
|
||||||
<string name="revanced_hide_video_ads_summary_off">Video ads are shown</string>
|
<string name="revanced_hide_video_ads_summary_off">Video ads are shown</string>
|
||||||
<string name="revanced_hide_video_ads_summary_on">Video ads are hidden</string>
|
<string name="revanced_hide_video_ads_summary_on">Video ads are hidden</string>
|
||||||
<string name="revanced_hide_video_ads_title">Hide video ads</string>
|
<string name="revanced_hide_video_ads_title">Hide video ads</string>
|
||||||
|
@ -175,6 +175,9 @@
|
|||||||
<!-- SETTINGS: HIDE_SUGGESTIONS_SHELF
|
<!-- SETTINGS: HIDE_SUGGESTIONS_SHELF
|
||||||
<SwitchPreference android:title="@string/revanced_hide_suggestions_shelf_title" android:key="revanced_hide_suggestions_shelf" android:defaultValue="false" android:summaryOn="@string/revanced_hide_suggestions_shelf_summary_on" android:summaryOff="@string/revanced_hide_suggestions_shelf_summary_off" />SETTINGS: HIDE_SUGGESTIONS_SHELF -->
|
<SwitchPreference android:title="@string/revanced_hide_suggestions_shelf_title" android:key="revanced_hide_suggestions_shelf" android:defaultValue="false" android:summaryOn="@string/revanced_hide_suggestions_shelf_summary_on" android:summaryOff="@string/revanced_hide_suggestions_shelf_summary_off" />SETTINGS: HIDE_SUGGESTIONS_SHELF -->
|
||||||
|
|
||||||
|
<!-- SETTINGS: HIDE_TRENDING_SEARCHES
|
||||||
|
<SwitchPreference android:title="@string/revanced_hide_trending_searches_title" android:key="revanced_hide_trending_searches" android:defaultValue="true" android:summaryOn="@string/revanced_hide_trending_searches_summary_on" android:summaryOff="@string/revanced_hide_trending_searches_summary_off" />SETTINGS: HIDE_TRENDING_SEARCHES -->
|
||||||
|
|
||||||
<!-- SETTINGS: HEADER_SWITCH
|
<!-- SETTINGS: HEADER_SWITCH
|
||||||
<SwitchPreference android:title="@string/revanced_override_premium_header_title" android:key="revanced_override_premium_header" android:defaultValue="false" android:summaryOn="@string/revanced_override_premium_header_summary_on" android:summaryOff="@string/revanced_override_premium_header_summary_off" />SETTINGS: HEADER_SWITCH -->
|
<SwitchPreference android:title="@string/revanced_override_premium_header_title" android:key="revanced_override_premium_header" android:defaultValue="false" android:summaryOn="@string/revanced_override_premium_header_summary_on" android:summaryOff="@string/revanced_override_premium_header_summary_off" />SETTINGS: HEADER_SWITCH -->
|
||||||
|
|
||||||
@ -310,6 +313,7 @@
|
|||||||
<Preference android:title="hide-mix-playlists" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
<Preference android:title="hide-mix-playlists" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||||
<Preference android:title="hide-snack-bar" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
<Preference android:title="hide-snack-bar" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||||
<Preference android:title="hide-suggestions-shelf" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
<Preference android:title="hide-suggestions-shelf" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||||
|
<Preference android:title="hide-trending-searches" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||||
|
|
||||||
<Preference android:title=" " android:selectable="false" android:summary="@string/revanced_misc" />
|
<Preference android:title=" " android:selectable="false" android:summary="@string/revanced_misc" />
|
||||||
<Preference android:title="bypass-ambient-mode-restrictions" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
<Preference android:title="bypass-ambient-mode-restrictions" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user