Adguard: support for important

pull/214/head
M66B 1 year ago
parent f28a086090
commit dc3dd30017

@ -52,6 +52,7 @@ public class Adguard {
return null; return null;
List<String> removes = new ArrayList<>(); List<String> removes = new ArrayList<>();
List<String> importants = new ArrayList<>();
List<String> excepts = new ArrayList<>(); List<String> excepts = new ArrayList<>();
try (BufferedReader br = new BufferedReader( try (BufferedReader br = new BufferedReader(
@ -92,6 +93,7 @@ public class Adguard {
} }
String remove = null; String remove = null;
boolean important = false;
boolean matches = true; boolean matches = true;
for (String modifier : modifiers) { for (String modifier : modifiers) {
int equal = modifier.indexOf('='); int equal = modifier.indexOf('=');
@ -153,10 +155,12 @@ public class Adguard {
if (and != matches) if (and != matches)
break; break;
} }
} else if ("important".equals(name)) {
important = true;
Log.w("Adguard important=" + param);
} else { } else {
if (!"document".equals(name) && if (!"document".equals(name) &&
!"image".equals(name) && !"image".equals(name) &&
!"important".equals(name) &&
!"script".equals(name) && !"script".equals(name) &&
!(name.startsWith("~") && !name.equals("~document"))) { !(name.startsWith("~") && !name.equals("~document"))) {
if (!ADGUARD_IGNORE.contains(name)) if (!ADGUARD_IGNORE.contains(name))
@ -225,6 +229,8 @@ public class Adguard {
} else { } else {
if (!removes.contains(remove)) if (!removes.contains(remove))
removes.add(remove); removes.add(remove);
if (important && !importants.contains(remove))
importants.add(remove);
} }
} }
} catch (Throwable ex) { } catch (Throwable ex) {
@ -242,12 +248,13 @@ public class Adguard {
String value = uri.getQueryParameter(key); String value = uri.getQueryParameter(key);
if (omitParam(remove, key, value)) { if (omitParam(remove, key, value)) {
omit = true; omit = true;
for (String except : excepts) if (!importants.contains(remove))
if (omitParam(except, key, value)) { for (String except : excepts)
Log.i("Adguard except=" + except); if (omitParam(except, key, value)) {
omit = false; Log.i("Adguard except=" + except);
break; omit = false;
} break;
}
} }
} }

Loading…
Cancel
Save