diff --git a/instructions/README.md b/instructions/README.md index 2f70dac28..afaec7295 100644 --- a/instructions/README.md +++ b/instructions/README.md @@ -210,6 +210,7 @@ In this file, you can add subscription links and basic settings. "emoji": 1, //Add flag emoji "subgroup": "", "prefix": "", //Do not add node name prefix + "ex-node-name": "网站|流量|过期", //Filter nodes containing keywords "User-Agent":"clashmeta" //Set browser UA }, { @@ -270,6 +271,8 @@ In this file, you can add subscription links and basic settings. - `prefix`: Optional. Set a custom prefix that will be added to the beginning of the node names. If not set, no prefix will be added. +- `ex-node-name`: Optional. Filter nodes containing keywords. Multiple keywords are separated by "|" + - `User-Agent`: Optional. You can customize UA, such as setting UA to "clash.meta" or "sing-box"
diff --git a/main.py b/main.py index 763eb6a84..552838edb 100644 --- a/main.py +++ b/main.py @@ -49,6 +49,7 @@ def process_subscribes(subscribes): if _nodes and len(_nodes) > 0: add_prefix(_nodes, subscribe) add_emoji(_nodes, subscribe) + nodefilter(_nodes, subscribe) if subscribe.get('subgroup'): subscribe['tag'] = subscribe['tag'] + '-' + subscribe['subgroup'] + '-' + 'subgroup' if not nodes.get(subscribe['tag']): @@ -120,6 +121,15 @@ def add_emoji(nodes, subscribe): node['detour'] = tool.rename(node['detour']) +def nodefilter(nodes, subscribe): + if subscribe.get('ex-node-name'): + ex_nodename = subscribe['ex-node-name'].split('|') + for exns in ex_nodename: + for node in nodes[:]: # 遍历 nodes 的副本,以便安全地删除元素 + if exns in node['tag']: + nodes.remove(node) + + def get_nodes(url): if url.startswith('sub://'): url = tool.b64Decode(url[6:]).decode('utf-8')