fix(YouTube - Hide ads): Hide new type of ad (#545)

Co-authored-by: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com>
Co-authored-by: oSumAtrIX <johan.melkonyan1@web.de>
This commit is contained in:
nullptr 2023-12-25 20:51:43 +00:00 committed by GitHub
parent 7584090ac2
commit e28b8cc59a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 4 deletions

View File

@ -3,8 +3,11 @@ package app.revanced.integrations.patches.components;
import android.app.Instrumentation; import android.app.Instrumentation;
import android.view.KeyEvent; import android.view.KeyEvent;
import android.view.View; import android.view.View;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import app.revanced.integrations.settings.SettingsEnum; import app.revanced.integrations.settings.SettingsEnum;
import app.revanced.integrations.utils.LogHelper;
import app.revanced.integrations.utils.ReVancedUtils; import app.revanced.integrations.utils.ReVancedUtils;
import app.revanced.integrations.utils.StringTrieSearch; import app.revanced.integrations.utils.StringTrieSearch;
@ -52,7 +55,8 @@ public final class AdsFilter extends Filter {
"_ad_with", "_ad_with",
"text_image_button_group_layout", "text_image_button_group_layout",
"video_display_button_group_layout", "video_display_button_group_layout",
"landscape_image_wide_button_layout" "landscape_image_wide_button_layout",
"video_display_carousel_button_group_layout"
); );
final var generalAds = new StringFilterGroup( final var generalAds = new StringFilterGroup(
@ -160,6 +164,8 @@ public final class AdsFilter extends Filter {
if (currentTime - lastTimeClosedFullscreenAd < 10000) return; if (currentTime - lastTimeClosedFullscreenAd < 10000) return;
lastTimeClosedFullscreenAd = currentTime; lastTimeClosedFullscreenAd = currentTime;
LogHelper.printDebug(() -> "Closing fullscreen ad");
ReVancedUtils.runOnMainThreadDelayed(() -> instrumentation.sendKeyDownUpSync(KeyEvent.KEYCODE_BACK), 1000); ReVancedUtils.runOnMainThreadDelayed(() -> instrumentation.sendKeyDownUpSync(KeyEvent.KEYCODE_BACK), 1000);
} }
} }

View File

@ -43,6 +43,7 @@ public final class LayoutComponentsFilter extends Filter {
exceptions.addPatterns( exceptions.addPatterns(
"home_video_with_context", "home_video_with_context",
"related_video_with_context", "related_video_with_context",
"search_video_with_context",
"comment_thread", // Whitelist comments "comment_thread", // Whitelist comments
"|comment.", // Whitelist comment replies "|comment.", // Whitelist comment replies
"library_recent_shelf" "library_recent_shelf"
@ -252,8 +253,11 @@ public final class LayoutComponentsFilter extends Filter {
@Override @Override
public boolean isFiltered(@Nullable String identifier, String path, byte[] protobufBufferArray, public boolean isFiltered(@Nullable String identifier, String path, byte[] protobufBufferArray,
StringFilterGroup matchedGroup, FilterContentType contentType, int contentIndex) { StringFilterGroup matchedGroup, FilterContentType contentType, int contentIndex) {
if (matchedGroup == searchResultVideo) if (matchedGroup == searchResultVideo) {
return searchResultRecommendations.check(protobufBufferArray).isFiltered(); if (searchResultRecommendations.check(protobufBufferArray).isFiltered()) {
return super.isFiltered(identifier, path, protobufBufferArray, matchedGroup, contentType, contentIndex);
}
}
// The groups are excluded from the filter due to the exceptions list below. // The groups are excluded from the filter due to the exceptions list below.
// Filter them separately here. // Filter them separately here.