Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(YouTube - Hide layout components): Filter home/search results by keywords #2853

Merged
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
b8858f7
feat(YouTube): Add `Hide keyword content` patch
LisoUseInAIKyrios Feb 15, 2024
9cd5a63
refactor: move code into `HideLayoutComponents`
LisoUseInAIKyrios Mar 8, 2024
cc19666
feat: Support unicode keyword and custom filters
LisoUseInAIKyrios Mar 8, 2024
2c65188
fix: Use unsorted
LisoUseInAIKyrios Mar 8, 2024
f6bc936
adjust text
LisoUseInAIKyrios Mar 8, 2024
bc25b65
fix: Do not reset keywords or custom filter. Show a toast and leave …
LisoUseInAIKyrios Mar 9, 2024
dfc8e88
fix: Automatically filter capitalized first letter of each sentence.
LisoUseInAIKyrios Mar 9, 2024
86f24c8
refactor: Rename class
LisoUseInAIKyrios Mar 9, 2024
e82f6a2
fix: adjust settings text
LisoUseInAIKyrios Mar 10, 2024
bdf2bd7
Merge remote-tracking branch 'upstream/dev' into filter_keyword_content
LisoUseInAIKyrios Mar 11, 2024
d89490b
fix: adjust settings text
LisoUseInAIKyrios Mar 11, 2024
944b755
feat: Selective filtering of search/home/subscriptions
LisoUseInAIKyrios Mar 14, 2024
1e2f8a1
refactor: break apart NavigationButtonsPatch into subpatch
LisoUseInAIKyrios Mar 14, 2024
293ab6b
Merge remote-tracking branch 'upstream/dev' into filter_keyword_content
LisoUseInAIKyrios Mar 15, 2024
5368457
Adjust setting strings
LisoUseInAIKyrios Mar 17, 2024
83545b4
refactor: Use existing class name
LisoUseInAIKyrios Mar 17, 2024
75220ac
refactor: Simplify
LisoUseInAIKyrios Mar 17, 2024
05c03f3
refactor: Cleanup
LisoUseInAIKyrios Mar 19, 2024
5a89194
Merge remote-tracking branch 'upstream/dev' into filter_keyword_content
LisoUseInAIKyrios Mar 19, 2024
b8aa8ea
fix: Detect some keywords that will always hide all videos
LisoUseInAIKyrios Mar 19, 2024
2094b9d
fix: Adjust settings text
LisoUseInAIKyrios Mar 21, 2024
0de51bf
fix: Hook the 'You' library tab
LisoUseInAIKyrios Mar 21, 2024
1db7ddb
refactor: No fingerprint opcodes. Changes needed for future YT 19.10…
LisoUseInAIKyrios Mar 24, 2024
79154f2
Merge remote-tracking branch 'upstream/dev' into filter_keyword_content
LisoUseInAIKyrios Mar 26, 2024
001d210
adjust description
oSumAtrIX Mar 26, 2024
c7d18e2
refactor
oSumAtrIX Mar 26, 2024
4a0ce3b
remove obsolete class
oSumAtrIX Mar 26, 2024
4f11db0
return to predicate
oSumAtrIX Mar 27, 2024
6eae942
refactor
oSumAtrIX Mar 27, 2024
70d5c7a
refactor: Throw an exception if the filter matched nothing
LisoUseInAIKyrios Mar 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ object HideLayoutComponentsPatch : BytecodePatch(
"Lapp/revanced/integrations/youtube/patches/components/DescriptionComponentsFilter;"
private const val CUSTOM_FILTER_CLASS_NAME =
"Lapp/revanced/integrations/youtube/patches/components/CustomFilter;"
private const val KEYWORD_FILTER_CLASS_NAME =
"Lapp/revanced/integrations/youtube/patches/components/HideKeywordContentFilter;"

override fun execute(context: BytecodeContext) {
AddResourcesPatch(this::class)
Expand Down Expand Up @@ -113,6 +115,17 @@ object HideLayoutComponentsPatch : BytecodePatch(
SwitchPreference("revanced_hide_search_result_shelf_header"),
)

SettingsPatch.PreferenceScreen.FEED.addPreferences(
PreferenceScreen(
key = "revanced_hide_keyword_content_preference_screen",
sorting = Sorting.UNSORTED,
preferences = setOf(
SwitchPreference("revanced_hide_keyword_content"),
TextPreference("revanced_hide_keyword_content_phrases", inputType = InputType.TEXT_MULTI_LINE),
),
)
)

SettingsPatch.PreferenceScreen.GENERAL_LAYOUT.addPreferences(
SwitchPreference("revanced_hide_gray_separator"),
PreferenceScreen(
Expand All @@ -132,6 +145,7 @@ object HideLayoutComponentsPatch : BytecodePatch(

LithoFilterPatch.addFilter(LAYOUT_COMPONENTS_FILTER_CLASS_DESCRIPTOR)
LithoFilterPatch.addFilter(DESCRIPTION_COMPONENTS_FILTER_CLASS_NAME)
LithoFilterPatch.addFilter(KEYWORD_FILTER_CLASS_NAME)
LithoFilterPatch.addFilter(CUSTOM_FILTER_CLASS_NAME)

// region Mix playlists
Expand Down
10 changes: 9 additions & 1 deletion src/main/resources/addresources/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,17 @@
<string name="revanced_custom_filter_summary_off">Custom filter is disabled</string>
<string name="revanced_custom_filter_strings_title">Custom filter</string>
<string name="revanced_custom_filter_strings_summary">List of component path builder strings to filter separated by new line</string>
<string name="revanced_custom_filter_toast_invalid_characters">Invalid custom filter (must be ASCII only): %s</string>
<string name="revanced_custom_filter_toast_invalid_syntax">Invalid custom filter: %s</string>
<string name="revanced_custom_filter_toast_reset">Custom filter reset to default</string>
<string name="revanced_hide_keyword_content_preference_screen_title">Hide keyword content</string>
<string name="revanced_hide_keyword_content_preference_screen_summary">Hide feed and search result videos using keyword filters</string>
<string name="revanced_hide_keyword_content_title">Enable keyword filtering</string>
<string name="revanced_hide_keyword_content_summary_on">Feed/search is filtered to hide content that matches keyword phrases\n\nLimitations\n• Some UI elements may not be hidden\n• Some Shorts may not be hidden\n• Searching for a keyword may show no results</string>
<string name="revanced_hide_keyword_content_summary_off">Feed/search results are not filtered</string>
<string name="revanced_hide_keyword_content_phrases_title">Keywords to hide</string>
<string name="revanced_hide_keyword_content_phrases_summary">Keywords and phrases to hide, separated by new lines.\n\nText specified here automatically include some uppercase and lowercase variations, but some text requires entering the exact casing (ie: LeBlanc, John Doe, etc)</string>
oSumAtrIX marked this conversation as resolved.
Show resolved Hide resolved
<string name="revanced_hide_keyword_toast_invalid_length" formatted="false">Invalid keyword length (must be at least %s characters): %s</string>
LisoUseInAIKyrios marked this conversation as resolved.
Show resolved Hide resolved
<string name="revanced_hide_keyword_toast_reset">Keywords reset to default</string>
</patch>
<patch id="ad.general.HideAdsResourcePatch">
<string name="revanced_hide_general_ads_title">Hide general ads</string>
Expand Down
Loading