mirror of
https://github.com/revanced/revanced-integrations.git
synced 2025-01-20 08:47:33 +01:00
refactor: move Extensions.any
to BlockRule.contains
This commit is contained in:
parent
570f9eaba1
commit
e978ed2c14
@ -15,25 +15,7 @@ import app.revanced.integrations.settings.SettingsEnum;
|
|||||||
import app.revanced.integrations.utils.LogHelper;
|
import app.revanced.integrations.utils.LogHelper;
|
||||||
import app.revanced.integrations.utils.ReVancedUtils;
|
import app.revanced.integrations.utils.ReVancedUtils;
|
||||||
|
|
||||||
/**
|
class BlockRule {
|
||||||
* Helper functions.
|
|
||||||
*/
|
|
||||||
final class Extensions {
|
|
||||||
static boolean any(LithoBlockRegister register, String path) {
|
|
||||||
for (var rule : register) {
|
|
||||||
if (!rule.isEnabled()) continue;
|
|
||||||
|
|
||||||
var result = rule.check(path);
|
|
||||||
if (result.isBlocked()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
final class BlockRule {
|
|
||||||
final static class BlockResult {
|
final static class BlockResult {
|
||||||
private final boolean blocked;
|
private final boolean blocked;
|
||||||
private final SettingsEnum setting;
|
private final SettingsEnum setting;
|
||||||
@ -120,6 +102,19 @@ final class LithoBlockRegister implements Iterable<BlockRule> {
|
|||||||
public Spliterator<BlockRule> spliterator() {
|
public Spliterator<BlockRule> spliterator() {
|
||||||
return blocks.spliterator();
|
return blocks.spliterator();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean contains(String path) {
|
||||||
|
for (var rule : this) {
|
||||||
|
if (!rule.isEnabled()) continue;
|
||||||
|
|
||||||
|
var result = rule.check(path);
|
||||||
|
if (result.isBlocked()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public final class LithoFilterPatch {
|
public final class LithoFilterPatch {
|
||||||
@ -162,7 +157,7 @@ final class CommentsPatch extends Filter {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
boolean filter(String path, String _identifier) {
|
boolean filter(String path, String _identifier) {
|
||||||
if (!Extensions.any(pathRegister, path)) return false;
|
if (!pathRegister.contains(path)) return false;
|
||||||
|
|
||||||
LogHelper.debug(CommentsPatch.class, "Blocked: " + path);
|
LogHelper.debug(CommentsPatch.class, "Blocked: " + path);
|
||||||
|
|
||||||
@ -215,7 +210,7 @@ final class ButtonsPatch extends Filter {
|
|||||||
} else return false;
|
} else return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((currentIsActionButton && ActionButton.doNotBlockCounter <= 0 && actionButtonsRule.isEnabled()) || Extensions.any(pathRegister, path)) {
|
if ((currentIsActionButton && ActionButton.doNotBlockCounter <= 0 && actionButtonsRule.isEnabled()) || pathRegister.contains(path)) {
|
||||||
LogHelper.debug(ButtonsPatch.class, "Blocked: " + path);
|
LogHelper.debug(ButtonsPatch.class, "Blocked: " + path);
|
||||||
return true;
|
return true;
|
||||||
} else return false;
|
} else return false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user