1
mirror of https://github.com/revanced/revanced-integrations synced 2024-11-22 05:02:19 +01:00

fix(YouTube - Hide Shorts components): Correctly hide join button

This commit is contained in:
oSumAtrIX 2024-03-26 01:52:41 +01:00
parent 59165de801
commit b7a8995f79
No known key found for this signature in database
GPG Key ID: A9B3094ACDB604B4
2 changed files with 28 additions and 12 deletions

View File

@ -30,7 +30,8 @@ public final class LayoutComponentsFilter extends Filter {
private final ByteArrayFilterGroup searchResultRecommendations; private final ByteArrayFilterGroup searchResultRecommendations;
private final StringFilterGroup searchResultVideo; private final StringFilterGroup searchResultVideo;
private final StringFilterGroup compactChannelBarInner; private final StringFilterGroup compactChannelBarInner;
private final ByteArrayFilterGroup joinMembership; private final StringFilterGroup compactChannelBarInnerButton;
private final ByteArrayFilterGroup joinMembershipButton;
static { static {
mixPlaylistsExceptions.addPatterns( mixPlaylistsExceptions.addPatterns(
@ -39,6 +40,7 @@ public final class LayoutComponentsFilter extends Filter {
); );
} }
@RequiresApi(api = Build.VERSION_CODES.N) @RequiresApi(api = Build.VERSION_CODES.N)
public LayoutComponentsFilter() { public LayoutComponentsFilter() {
exceptions.addPatterns( exceptions.addPatterns(
@ -201,9 +203,14 @@ public final class LayoutComponentsFilter extends Filter {
"compact_channel_bar_inner" "compact_channel_bar_inner"
); );
joinMembership = new ByteArrayFilterGroup( compactChannelBarInnerButton = new StringFilterGroup(
Settings.HIDE_JOIN_MEMBERSHIP_BUTTON, null,
"Join this channel" "|button.eml|"
);
joinMembershipButton = new ByteArrayFilterGroup(
null,
"sponsorships"
); );
final var channelWatermark = new StringFilterGroup( final var channelWatermark = new StringFilterGroup(
@ -265,12 +272,6 @@ public final class LayoutComponentsFilter extends Filter {
} }
} }
if (matchedGroup == compactChannelBarInner) {
if (joinMembership.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.
if (matchedGroup == notifyMe || matchedGroup == inFeedSurvey || matchedGroup == expandableMetadata) if (matchedGroup == notifyMe || matchedGroup == inFeedSurvey || matchedGroup == expandableMetadata)
@ -278,6 +279,18 @@ public final class LayoutComponentsFilter extends Filter {
if (exceptions.matches(path)) return false; // Exceptions are not filtered. if (exceptions.matches(path)) return false; // Exceptions are not filtered.
if (matchedGroup == compactChannelBarInner) {
if (compactChannelBarInnerButton.check(path).isFiltered()) {
// The filter may be broad, but in the context of a compactChannelBarInnerButton,
// it's safe to assume that the button is the only thing that should be hidden.
if (joinMembershipButton.check(protobufBufferArray).isFiltered()) {
return super.isFiltered(identifier, path, protobufBufferArray, matchedGroup, contentType, contentIndex);
}
}
return false;
}
// TODO: This also hides the feed Shorts shelf header // TODO: This also hides the feed Shorts shelf header
if (matchedGroup == searchResultShelfHeader && contentIndex != 0) return false; if (matchedGroup == searchResultShelfHeader && contentIndex != 0) return false;

View File

@ -27,6 +27,7 @@ public final class ShortsFilter extends Filter {
private final StringFilterGroup subscribeButtonPaused; private final StringFilterGroup subscribeButtonPaused;
private final StringFilterGroup soundButton; private final StringFilterGroup soundButton;
private final StringFilterGroup infoPanel; private final StringFilterGroup infoPanel;
private final StringFilterGroup joinButton;
private final StringFilterGroup shelfHeader; private final StringFilterGroup shelfHeader;
private final StringFilterGroup actionBar; private final StringFilterGroup actionBar;
@ -66,7 +67,7 @@ public final class ShortsFilter extends Filter {
"/frame0.jpg"); "/frame0.jpg");
// Shorts player components. // Shorts player components.
var joinButton = new StringFilterGroup( joinButton = new StringFilterGroup(
Settings.HIDE_SHORTS_JOIN_BUTTON, Settings.HIDE_SHORTS_JOIN_BUTTON,
"sponsor_button" "sponsor_button"
); );
@ -182,7 +183,9 @@ public final class ShortsFilter extends Filter {
// Filter other path groups from pathFilterGroupList, only when reelChannelBar is visible // Filter other path groups from pathFilterGroupList, only when reelChannelBar is visible
// to avoid false positives. // to avoid false positives.
if (matchedGroup == subscribeButton) { if (matchedGroup == subscribeButton ||
matchedGroup == joinButton
) {
if (path.startsWith(REEL_CHANNEL_BAR_PATH)) return super.isFiltered( if (path.startsWith(REEL_CHANNEL_BAR_PATH)) return super.isFiltered(
identifier, path, protobufBufferArray, matchedGroup, contentType, contentIndex identifier, path, protobufBufferArray, matchedGroup, contentType, contentIndex
); );