Rules

Clash Verge Extended Script: Append Rules Without Wiping the Provider List

Extended Script (called Script config in v1.6.x, renamed in v1.7.x) fits dynamic logic Extended Configuration cannot express. A handful of everyday DIRECT/proxy exceptions is less work in the Edit Rules and Edit Proxy Groups editors on the profile right-click menu (Merge custom rules). More power, bigger blast radius—especially pasted megascripts.

Scripts are the only code path that appends to lists

Extended Configuration only overrides config keys: a rules or proxy-groups block there replaces the provider list wholesale, and keys like prepend-rules have not been parsed since v1.7.x. To append from code, use a script:

const myRules = [
  'DOMAIN-SUFFIX,example.com,DIRECT',
];

function main(config, profileName) {
  config.rules = [...myRules, ...config.rules];
  return config;
}

Proxy groups work the same way — merge the new group into config['proxy-groups'] and return the config. Execution order is global config, global script, profile config, profile script, so later stages can undo earlier ones. For a few static rules the prepend area of the visual editor gives the same result without a syntax error taking the whole profile down.

Before enable: code you understand or trust; backup first (backup); know the off switch.

Minimal trial

  1. Enable a tiny observable change (tag one test domain).
  2. Reload; confirm via connections/logs.
  3. Grow slowly—don’t paste hundreds of lines first.

Leave working default templates alone. Debug logs on while testing, off when stable to cut CPU/disk (CPU/RAM).

Not applying or making things worse

Disabled toggle, syntax errors, Extended Configuration fighting the same fields. Assigning config['proxy-groups'] instead of splicing it wipes the provider groups and the UI shows blank groups (blank groups). The entry is Edit Script on the profile right-click menu; v1.6.x called it Script config.

Scripts that fetch the network to rewrite rules are hard to debug and risky. Fixed exceptions for Steam or streaming belong in the prepend area of Edit Rules, not hard-coded in a script.

Performance and teams

Heavy logic on hot paths raises latency/CPU. Agree who edits, how to review, how to roll back—no private incompatible forks.

Stop-loss and acceptance

Disable → reload → confirm baseline → re-add in chunks. Done when the intended behavior appears, collateral is absent, and disable restores clean state. Use download center builds.

Failure-mode table

Symptom Likely cause
Script enabled, no effect Toggle off; syntax error aborts run
Groups go blank after enabling Assigned proxy-groups instead of splicing
Rules doubled or missing Extended Configuration fighting the same fields
High CPU / latency Heavy logic on every request path