mirror of
https://github.com/revanced/revanced-integrations.git
synced 2024-12-03 09:12:55 +01:00
fix(youtube/hide-video-action-buttons): fix 'hide share button' (#360)
This commit is contained in:
parent
f7c3543d4f
commit
a2af2c0c9f
@ -1,60 +1,30 @@
|
|||||||
package app.revanced.integrations.patches;
|
package app.revanced.integrations.patches;
|
||||||
|
|
||||||
import app.revanced.integrations.settings.SettingsEnum;
|
import app.revanced.integrations.settings.SettingsEnum;
|
||||||
import app.revanced.integrations.utils.LogHelper;
|
|
||||||
|
|
||||||
final class ButtonsPatch extends Filter {
|
final class ButtonsPatch extends Filter {
|
||||||
private final BlockRule actionButtonsRule;
|
|
||||||
private final BlockRule dislikeRule;
|
|
||||||
private final BlockRule actionBarRule;
|
private final BlockRule actionBarRule;
|
||||||
|
|
||||||
private final BlockRule[] rules;
|
|
||||||
|
|
||||||
public ButtonsPatch() {
|
public ButtonsPatch() {
|
||||||
BlockRule like = new BlockRule(SettingsEnum.HIDE_LIKE_BUTTON, "|like_button");
|
|
||||||
dislikeRule = new BlockRule(SettingsEnum.HIDE_DISLIKE_BUTTON, "dislike_button");
|
|
||||||
BlockRule download = new BlockRule(SettingsEnum.HIDE_DOWNLOAD_BUTTON, "download_button");
|
|
||||||
actionButtonsRule = new BlockRule(SettingsEnum.HIDE_ACTION_BUTTON, "ContainerType|video_action_button");
|
|
||||||
BlockRule playlist = new BlockRule(SettingsEnum.HIDE_PLAYLIST_BUTTON, "save_to_playlist_button");
|
|
||||||
rules = new BlockRule[]{like, dislikeRule, download, actionButtonsRule, playlist};
|
|
||||||
|
|
||||||
actionBarRule = new BlockRule(null, "video_action_bar");
|
actionBarRule = new BlockRule(null, "video_action_bar");
|
||||||
|
pathRegister.registerAll(
|
||||||
this.pathRegister.registerAll(
|
new BlockRule(SettingsEnum.HIDE_LIKE_DISLIKE_BUTTON, "|like_button", "dislike_button"),
|
||||||
like,
|
new BlockRule(SettingsEnum.HIDE_DOWNLOAD_BUTTON, "download_button"),
|
||||||
dislikeRule,
|
new BlockRule(SettingsEnum.HIDE_PLAYLIST_BUTTON, "save_to_playlist_button"),
|
||||||
download,
|
new BlockRule(SettingsEnum.HIDE_ACTION_BUTTONS, "ContainerType|video_action_button")
|
||||||
playlist
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean hideActionBar() {
|
private boolean canHideActionBar() {
|
||||||
for (BlockRule rule : rules) if (!rule.isEnabled()) return false;
|
for (BlockRule rule : pathRegister) if (!rule.isEnabled()) return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean filter(final String path, final String identifier) {
|
public boolean filter(final String path, final String identifier) {
|
||||||
if (hideActionBar() && actionBarRule.check(identifier).isBlocked()) return true;
|
// If everything is hidden, then also hide the video bar itself.
|
||||||
|
if (canHideActionBar() && actionBarRule.check(identifier).isBlocked()) return true;
|
||||||
|
|
||||||
var currentIsActionButton = actionButtonsRule.check(path).isBlocked();
|
return pathRegister.contains(path);
|
||||||
|
|
||||||
if (dislikeRule.check(path).isBlocked()) ActionButton.doNotBlockCounter = 4;
|
|
||||||
|
|
||||||
if (currentIsActionButton && ActionButton.doNotBlockCounter-- > 0) {
|
|
||||||
if (SettingsEnum.HIDE_SHARE_BUTTON.getBoolean()) {
|
|
||||||
LogHelper.printDebug(() -> "Hiding share button");
|
|
||||||
return true;
|
|
||||||
} else return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((currentIsActionButton && ActionButton.doNotBlockCounter <= 0 && actionButtonsRule.isEnabled()) || pathRegister.contains(path)) {
|
|
||||||
LogHelper.printDebug(() -> "Blocked: " + path);
|
|
||||||
return true;
|
|
||||||
} else return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
static class ActionButton {
|
|
||||||
public static int doNotBlockCounter = 4;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -71,12 +71,10 @@ public enum SettingsEnum {
|
|||||||
VIDEO_ADS_REMOVAL("revanced_video_ads_removal", BOOLEAN, TRUE, true),
|
VIDEO_ADS_REMOVAL("revanced_video_ads_removal", BOOLEAN, TRUE, true),
|
||||||
|
|
||||||
// Action buttons
|
// Action buttons
|
||||||
HIDE_ACTION_BUTTON("revanced_hide_action_button", BOOLEAN, FALSE),
|
HIDE_LIKE_DISLIKE_BUTTON("revanced_hide_like_dislike_button", BOOLEAN, FALSE),
|
||||||
HIDE_DISLIKE_BUTTON("revanced_hide_dislike_button", BOOLEAN, FALSE),
|
|
||||||
HIDE_DOWNLOAD_BUTTON("revanced_hide_download_button", BOOLEAN, FALSE),
|
HIDE_DOWNLOAD_BUTTON("revanced_hide_download_button", BOOLEAN, FALSE),
|
||||||
HIDE_LIKE_BUTTON("revanced_hide_like_button", BOOLEAN, FALSE),
|
|
||||||
HIDE_PLAYLIST_BUTTON("revanced_hide_playlist_button", BOOLEAN, FALSE),
|
HIDE_PLAYLIST_BUTTON("revanced_hide_playlist_button", BOOLEAN, FALSE),
|
||||||
HIDE_SHARE_BUTTON("revanced_hide_share_button", BOOLEAN, FALSE),
|
HIDE_ACTION_BUTTONS("revanced_hide_action_buttons", BOOLEAN, FALSE),
|
||||||
|
|
||||||
// Layout settings
|
// Layout settings
|
||||||
DISABLE_STARTUP_SHORTS_PLAYER("revanced_startup_shorts_player_enabled", BOOLEAN, FALSE),
|
DISABLE_STARTUP_SHORTS_PLAYER("revanced_startup_shorts_player_enabled", BOOLEAN, FALSE),
|
||||||
|
Loading…
Reference in New Issue
Block a user