mirror of
https://github.com/revanced/revanced-integrations.git
synced 2024-09-01 20:16:27 +02:00
feat: hide-video-buttons
patch
This commit is contained in:
parent
e78a8014bc
commit
bf82e0219f
@ -115,7 +115,8 @@ final class LithoBlockRegister implements Iterable<BlockRule> {
|
|||||||
|
|
||||||
public final class LithoFilterPatch {
|
public final class LithoFilterPatch {
|
||||||
private static final Filter[] filters = new Filter[]{
|
private static final Filter[] filters = new Filter[]{
|
||||||
new GeneralBytecodeAdsPatch()
|
new GeneralBytecodeAdsPatch(),
|
||||||
|
new ButtonsPatch()
|
||||||
};
|
};
|
||||||
|
|
||||||
public static boolean filter(final StringBuilder pathBuilder, final String identifier) {
|
public static boolean filter(final StringBuilder pathBuilder, final String identifier) {
|
||||||
@ -132,6 +133,62 @@ public final class LithoFilterPatch {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final class ButtonsPatch extends Filter {
|
||||||
|
private final BlockRule actionButtonsRule;
|
||||||
|
private final BlockRule dislikeRule;
|
||||||
|
private final BlockRule actionBarRule;
|
||||||
|
|
||||||
|
private final BlockRule[] rules;
|
||||||
|
|
||||||
|
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");
|
||||||
|
|
||||||
|
this.register.registerAll(
|
||||||
|
like,
|
||||||
|
dislikeRule,
|
||||||
|
download,
|
||||||
|
playlist
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean hideActionBar() {
|
||||||
|
for (BlockRule rule : rules) if (!rule.isEnabled()) return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean filter(final String path, final String identifier) {
|
||||||
|
if (hideActionBar() && actionBarRule.check(identifier).isBlocked()) return true;
|
||||||
|
|
||||||
|
var currentIsActionButton = actionButtonsRule.check(path).isBlocked();
|
||||||
|
|
||||||
|
if (dislikeRule.check(path).isBlocked()) ActionButton.doNotBlockCounter = 4;
|
||||||
|
|
||||||
|
if (currentIsActionButton && ActionButton.doNotBlockCounter-- > 0) {
|
||||||
|
if (SettingsEnum.HIDE_SHARE_BUTTON.getBoolean()) {
|
||||||
|
LogHelper.debug(ButtonsPatch.class, "Hiding share button");
|
||||||
|
return true;
|
||||||
|
} else return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((currentIsActionButton && ActionButton.doNotBlockCounter <= 0 && actionButtonsRule.isEnabled()) || Extensions.any(register, path)) {
|
||||||
|
LogHelper.debug(ButtonsPatch.class, "Blocked: " + path);
|
||||||
|
return true;
|
||||||
|
} else return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
static class ActionButton {
|
||||||
|
public static int doNotBlockCounter = 4;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class GeneralBytecodeAdsPatch extends Filter {
|
class GeneralBytecodeAdsPatch extends Filter {
|
||||||
private final BlockRule identifierBlock;
|
private final BlockRule identifierBlock;
|
||||||
|
|
||||||
|
@ -45,6 +45,13 @@ public enum SettingsEnum {
|
|||||||
ADREMOVER_SUGGESTIONS_REMOVAL("revanced_adremover_hide_suggestions", true, ReturnType.BOOLEAN, true),
|
ADREMOVER_SUGGESTIONS_REMOVAL("revanced_adremover_hide_suggestions", true, ReturnType.BOOLEAN, true),
|
||||||
ADREMOVER_HIDE_LATEST_POSTS("revanced_adremover_hide_latest_posts", true, ReturnType.BOOLEAN, true),
|
ADREMOVER_HIDE_LATEST_POSTS("revanced_adremover_hide_latest_posts", true, ReturnType.BOOLEAN, true),
|
||||||
ADREMOVER_HIDE_CHANNEL_GUIDELINES("revanced_adremover_hide_channel_guidelines", true, ReturnType.BOOLEAN, true),
|
ADREMOVER_HIDE_CHANNEL_GUIDELINES("revanced_adremover_hide_channel_guidelines", true, ReturnType.BOOLEAN, true),
|
||||||
|
// Buttons
|
||||||
|
HIDE_LIKE_BUTTON("revanced_like_button", false, ReturnType.BOOLEAN, false),
|
||||||
|
HIDE_DISLIKE_BUTTON("revanced_dislike_button", false, ReturnType.BOOLEAN, false),
|
||||||
|
HIDE_DOWNLOAD_BUTTON("revanced_download_button", false, ReturnType.BOOLEAN, false),
|
||||||
|
HIDE_PLAYLIST_BUTTON("revanced_playlist_button", false, ReturnType.BOOLEAN, false),
|
||||||
|
HIDE_ACTION_BUTTON("revanced_action_button", false, ReturnType.BOOLEAN, false),
|
||||||
|
HIDE_SHARE_BUTTON("revanced_share_button", false, ReturnType.BOOLEAN, false),
|
||||||
|
|
||||||
//Layout settings
|
//Layout settings
|
||||||
REEL_BUTTON_SHOWN("revanced_reel_button_enabled", false, ReturnType.BOOLEAN, true),
|
REEL_BUTTON_SHOWN("revanced_reel_button_enabled", false, ReturnType.BOOLEAN, true),
|
||||||
|
Loading…
Reference in New Issue
Block a user