mirror of
https://github.com/Mahdi-zarei/nekoray.git
synced 2025-12-19 13:50:12 +08:00
commit
f170e3f3fd
@ -567,14 +567,15 @@ namespace Configs {
|
|||||||
|
|
||||||
QJsonArray RoutingChain::get_route_rules(bool forView, std::map<int, QString> outboundMap) {
|
QJsonArray RoutingChain::get_route_rules(bool forView, std::map<int, QString> outboundMap) {
|
||||||
QJsonArray res;
|
QJsonArray res;
|
||||||
if (Configs::dataStore->adblock_enable) {
|
bool added_adblock;
|
||||||
|
auto createAdblockRule = []() -> QJsonObject {
|
||||||
QJsonObject obj;
|
QJsonObject obj;
|
||||||
obj["action"] = "reject";
|
obj["action"] = "reject";
|
||||||
QJsonArray jarray;
|
QJsonArray jarray;
|
||||||
jarray.append("throne-adblocksingbox");
|
jarray.append("throne-adblocksingbox");
|
||||||
obj["rule_set"] = jarray;
|
obj["rule_set"] = jarray;
|
||||||
res += obj;
|
return obj;
|
||||||
}
|
};
|
||||||
for (const auto &item: Rules) {
|
for (const auto &item: Rules) {
|
||||||
auto outboundTag = QString();
|
auto outboundTag = QString();
|
||||||
if (outboundMap.contains(item->outboundID)) outboundTag = outboundMap[item->outboundID];
|
if (outboundMap.contains(item->outboundID)) outboundTag = outboundMap[item->outboundID];
|
||||||
@ -583,8 +584,14 @@ namespace Configs {
|
|||||||
MW_show_log("Aborted generating routing section, an error has occurred");
|
MW_show_log("Aborted generating routing section, an error has occurred");
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
if (!added_adblock && Configs::dataStore->adblock_enable && rule_json["action"] == "route") {
|
||||||
|
res += createAdblockRule();
|
||||||
|
added_adblock = true;
|
||||||
|
}
|
||||||
res += rule_json;
|
res += rule_json;
|
||||||
}
|
}
|
||||||
|
if (!added_adblock && Configs::dataStore->adblock_enable)
|
||||||
|
res += createAdblockRule();
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user