Skip to content
This repository has been archived by the owner on Dec 11, 2024. It is now read-only.

Commit

Permalink
feat(YouTube/Hide action buttons): add `Disable Like and Dislike butt…
Browse files Browse the repository at this point in the history
…on glow` setting
  • Loading branch information
inotia00 authored and anddea committed Jun 14, 2024
1 parent b3e0c9f commit ffb9a08
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,22 @@

@SuppressWarnings("unused")
public final class ActionButtonsFilter extends Filter {
private static final String VIDEO_ACTION_BAR_PATH_PREFIX = "video_action_bar.eml";
private static final String ANIMATED_VECTOR_TYPE_PATH = "AnimatedVectorType";

private static final String VIDEO_ACTION_BAR_PATH = "video_action_bar.eml";

private final StringFilterGroup actionBarRule;
private final StringFilterGroup bufferFilterPathRule;
private final StringFilterGroup likeSubscribeGlow;
private final ByteArrayFilterGroupList bufferButtonsGroupList = new ByteArrayFilterGroupList();

public ActionButtonsFilter() {
actionBarRule = new StringFilterGroup(
null,
VIDEO_ACTION_BAR_PATH
);
addIdentifierCallbacks(actionBarRule);


bufferFilterPathRule = new StringFilterGroup(
null,
"|ContainerType|button.eml|"
);
likeSubscribeGlow = new StringFilterGroup(
Settings.DISABLE_LIKE_DISLIKE_GLOW,
"animated_button_border.eml"
);
addPathCallbacks(
new StringFilterGroup(
Settings.HIDE_LIKE_DISLIKE_BUTTON,
Expand All @@ -50,7 +47,8 @@ public ActionButtonsFilter() {
Settings.HIDE_REWARDS_BUTTON,
"account_link_button"
),
bufferFilterPathRule
bufferFilterPathRule,
likeSubscribeGlow
);

bufferButtonsGroupList.addAll(
Expand All @@ -77,27 +75,22 @@ public ActionButtonsFilter() {
);
}

private boolean isEveryFilterGroupEnabled() {
for (StringFilterGroup group : pathCallbacks)
if (!group.isEnabled()) return false;

for (ByteArrayFilterGroup group : bufferButtonsGroupList)
if (!group.isEnabled()) return false;

return true;
}

@Override
public boolean isFiltered(String path, @Nullable String identifier, String allValue, byte[] protobufBufferArray,
StringFilterGroup matchedGroup, FilterContentType contentType, int contentIndex) {
if (!path.startsWith(VIDEO_ACTION_BAR_PATH)) {
if (!path.startsWith(VIDEO_ACTION_BAR_PATH_PREFIX)) {
return false;
}
if (matchedGroup == actionBarRule && !isEveryFilterGroupEnabled()) {
return false;
if (matchedGroup == likeSubscribeGlow) {
if (!path.contains(ANIMATED_VECTOR_TYPE_PATH)) {
return false;
}
}
if (matchedGroup == bufferFilterPathRule) {
return bufferButtonsGroupList.check(protobufBufferArray).isFiltered();
// In case the group list has no match, return false.
if (!bufferButtonsGroupList.check(protobufBufferArray).isFiltered()) {
return false;
}
}

return super.isFiltered(path, identifier, allValue, protobufBufferArray, matchedGroup, contentType, contentIndex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ public class Settings extends BaseSettings {


// PreferenceScreen: Player - Action buttons
public static final BooleanSetting DISABLE_LIKE_DISLIKE_GLOW = new BooleanSetting("revanced_disable_like_dislike_glow", FALSE);
public static final BooleanSetting HIDE_CLIP_BUTTON = new BooleanSetting("revanced_hide_clip_button", FALSE);
public static final BooleanSetting HIDE_DOWNLOAD_BUTTON = new BooleanSetting("revanced_hide_download_button", FALSE);
public static final BooleanSetting HIDE_LIKE_DISLIKE_BUTTON = new BooleanSetting("revanced_hide_like_dislike_button", FALSE);
Expand Down

0 comments on commit ffb9a08

Please sign in to comment.