1
mirror of https://github.com/revanced/revanced-integrations synced 2024-11-24 20:07:14 +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 StringFilterGroup searchResultVideo;
private final StringFilterGroup compactChannelBarInner;
private final ByteArrayFilterGroup joinMembership;
private final StringFilterGroup compactChannelBarInnerButton;
private final ByteArrayFilterGroup joinMembershipButton;
static {
mixPlaylistsExceptions.addPatterns(
@ -39,6 +40,7 @@ public final class LayoutComponentsFilter extends Filter {
);
}
@RequiresApi(api = Build.VERSION_CODES.N)
public LayoutComponentsFilter() {
exceptions.addPatterns(
@ -201,9 +203,14 @@ public final class LayoutComponentsFilter extends Filter {
"compact_channel_bar_inner"
);
joinMembership = new ByteArrayFilterGroup(
Settings.HIDE_JOIN_MEMBERSHIP_BUTTON,
"Join this channel"
compactChannelBarInnerButton = new StringFilterGroup(
null,
"|button.eml|"
);
joinMembershipButton = new ByteArrayFilterGroup(
null,
"sponsorships"
);
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.
// Filter them separately here.
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 (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
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 soundButton;
private final StringFilterGroup infoPanel;
private final StringFilterGroup joinButton;
private final StringFilterGroup shelfHeader;
private final StringFilterGroup actionBar;
@ -66,7 +67,7 @@ public final class ShortsFilter extends Filter {
"/frame0.jpg");
// Shorts player components.
var joinButton = new StringFilterGroup(
joinButton = new StringFilterGroup(
Settings.HIDE_SHORTS_JOIN_BUTTON,
"sponsor_button"
);
@ -182,7 +183,9 @@ public final class ShortsFilter extends Filter {
// Filter other path groups from pathFilterGroupList, only when reelChannelBar is visible
// to avoid false positives.
if (matchedGroup == subscribeButton) {
if (matchedGroup == subscribeButton ||
matchedGroup == joinButton
) {
if (path.startsWith(REEL_CHANNEL_BAR_PATH)) return super.isFiltered(
identifier, path, protobufBufferArray, matchedGroup, contentType, contentIndex
);