可以根据时间选择节点,避免在晚高峰的时候速度慢,也避免告诉流量消耗过快。

演示 Twitch分组 每天21点和1点自动切换到对应的节点!

/Surge Profiles/20200624.conf(ProxySwitch script: 每天 21 时、1 时自动执行一次 ProxySwitch.js)

[General]
...

[Proxy]
利刃 = 
搬瓦工 = 
...

[Proxy Group]
🐈 自建节点 = select, 利刃, 搬瓦工
...

[Rule]
...

[Script]
ProxySwitch = type=cron,cronexp="0 21,1 * * *",script-path=ProxySwitch.js

/Surge Profiles/ProxySwitch.js(根据被调用时的时间不同切换至不同线路,然后发通知,写 Log)

var d = new Date();
var h = d.getHours();

const ProxyDay   = '利刃';
const ProxyNight = '搬瓦工';

if (h >= 21 || h <1) {
    var ProxyNewPolicy = ProxyNight;
} else {
    var ProxyNewPolicy = ProxyDay;
}

$surge.setSelectGroupPolicy('🐈 自建节点', ProxyNewPolicy);
$notification.post("Script called", "ProxySwitch.js", "'🐈 自建节点' switched to '" + ProxyNewPolicy + "'");
console.log("ProxySwitch.js script: '🐈 自建节点' switched to '" + ProxyNewPolicy + "'");

$done();

然后,记得打开 Scripting(脚本)功能开关:Surge iOS 的在首页;Surge Mac 的在 Surge 托盘图标右键菜单 -> Capabilities -> Enable Scripting。 最后,脚本更新后要重新加载一下配置文件,因为 Surge 好像是启动时会缓存要用的脚本,而不是每次到要执行的时候都重新请求资源。Mac 端重新加载配置文件:Surge 托盘图标上右键,然后 Reload Profile from File (⌘R)。

上文 参考

题外相关: Surge 配置文件参考:SurgeProMax.conf