Skip to content

Commit

Permalink
feat(YouTube - Hide Shorts components): Hide Shop, Location and `…
Browse files Browse the repository at this point in the history
…Save sound to playlist` buttons (#614)
  • Loading branch information
LisoUseInAIKyrios authored Apr 12, 2024
1 parent f055991 commit fec897a
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,16 @@ public final class ShortsFilter extends Filter {
private final StringFilterGroup joinButton;
private final StringFilterGroup shelfHeader;

private final StringFilterGroup suggestedActionPath;
private final ByteArrayFilterGroupList suggestedActions = new ByteArrayFilterGroupList();

private final StringFilterGroup actionBar;
private final ByteArrayFilterGroupList videoActionButtonGroupList = new ByteArrayFilterGroupList();

public ShortsFilter() {
//
// Identifier components.
//

var shorts = new StringFilterGroup(
null, // Setting is based on navigation state.
Expand All @@ -55,14 +60,17 @@ public ShortsFilter() {
);

// Home / subscription feed components.
var thanksButton = new StringFilterGroup(

var thanksButton = new StringFilterGroup( // Edit: Does this item show up anymore?
Settings.HIDE_SHORTS_THANKS_BUTTON,
"suggested_action"
);

addIdentifierCallbacks(shorts, shelfHeader, thanksButton);

//
// Path components.
//

// Shorts that appear in the feed/search when the device is using tablet layout.
shortsCompactFeedVideoPath = new StringFilterGroup(null, "compact_video.eml");
Expand Down Expand Up @@ -122,13 +130,21 @@ public ShortsFilter() {
"shorts_action_bar"
);

suggestedActionPath = new StringFilterGroup(
null,
"suggested_action.eml"
);

addPathCallbacks(
shortsCompactFeedVideoPath,
joinButton, subscribeButton, subscribeButtonPaused,
joinButton, subscribeButton, subscribeButtonPaused, suggestedActionPath,
channelBar, fullVideoLinkLabel, videoTitle, reelSoundMetadata,
soundButton, infoPanel, actionBar
);

//
// Action buttons
//
var shortsLikeButton = new ByteArrayFilterGroup(
Settings.HIDE_SHORTS_LIKE_BUTTON,
"shorts_like_button"
Expand Down Expand Up @@ -161,6 +177,24 @@ public ShortsFilter() {
shortsShareButton,
shortsRemixButton
);

//
// Suggested actions.
//
suggestedActions.addAll(
new ByteArrayFilterGroup(
Settings.HIDE_SHORTS_SHOP_BUTTON,
"yt_outline_bag_"
),
new ByteArrayFilterGroup(
Settings.HIDE_SHORTS_LOCATION_BUTTON,
"yt_outline_location_point_"
),
new ByteArrayFilterGroup(
Settings.HIDE_SHORTS_SAVE_SOUND_BUTTON,
"yt_outline_list_add_"
)
);
}

@Override
Expand All @@ -185,6 +219,14 @@ boolean isFiltered(@Nullable String identifier, String path, byte[] protobufBuff
return false;
}

if (matchedGroup == subscribeButton || matchedGroup == joinButton) {
// Filter only when reelChannelBar is visible to avoid false positives.
if (path.startsWith(REEL_CHANNEL_BAR_PATH)) return super.isFiltered(
identifier, path, protobufBufferArray, matchedGroup, contentType, contentIndex
);
return false;
}

// Video action buttons (like, dislike, comment, share, remix) have the same path.
if (matchedGroup == actionBar) {
if (videoActionButtonGroupList.check(protobufBufferArray).isFiltered()) return super.isFiltered(
Expand All @@ -193,14 +235,11 @@ boolean isFiltered(@Nullable String identifier, String path, byte[] protobufBuff
return false;
}

// Filter other path groups from pathFilterGroupList, only when reelChannelBar is visible
// to avoid false positives.
if (matchedGroup == subscribeButton ||
matchedGroup == joinButton
) {
if (path.startsWith(REEL_CHANNEL_BAR_PATH)) return super.isFiltered(
if (matchedGroup == suggestedActionPath) {
if (contentIndex == 0 && suggestedActions.check(protobufBufferArray).isFiltered()) return super.isFiltered(
identifier, path, protobufBufferArray, matchedGroup, contentType, contentIndex
); // else, return false.
);
// else, return false;
}

return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,9 @@ public class Settings extends BaseSettings {
public static final BooleanSetting HIDE_SHORTS_SUBSCRIBE_BUTTON = new BooleanSetting("revanced_hide_shorts_subscribe_button", TRUE);
public static final BooleanSetting HIDE_SHORTS_SUBSCRIBE_BUTTON_PAUSED = new BooleanSetting("revanced_hide_shorts_subscribe_button_paused", FALSE);
public static final BooleanSetting HIDE_SHORTS_THANKS_BUTTON = new BooleanSetting("revanced_hide_shorts_thanks_button", TRUE);
public static final BooleanSetting HIDE_SHORTS_SHOP_BUTTON = new BooleanSetting("revanced_hide_shorts_shop_button", TRUE);
public static final BooleanSetting HIDE_SHORTS_LOCATION_BUTTON = new BooleanSetting("revanced_hide_shorts_location_button", FALSE);
public static final BooleanSetting HIDE_SHORTS_SAVE_SOUND_BUTTON = new BooleanSetting("revanced_hide_shorts_save_sound_button", FALSE);
public static final BooleanSetting HIDE_SHORTS_LIKE_BUTTON = new BooleanSetting("revanced_hide_shorts_like_button", FALSE);
public static final BooleanSetting HIDE_SHORTS_DISLIKE_BUTTON = new BooleanSetting("revanced_hide_shorts_dislike_button", FALSE);
public static final BooleanSetting HIDE_SHORTS_COMMENTS_BUTTON = new BooleanSetting("revanced_hide_shorts_comments_button", FALSE);
Expand Down

0 comments on commit fec897a

Please sign in to comment.