Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
surge wifi changed ,auto change proxy
/**
* @description
* 如果是家里WI-FI则开启直连模式
* 如果不是家里WI-FI则开启代理模式
*/
const WIFI_DONT_NEED_PROXYS = ['xiaomi_Alan_5G'];
if (WIFI_DONT_NEED_PROXYS.includes($network.wifi.ssid)) {
$surge.setOutboundMode('direct');
$notification.post('Surge', 'Wi-Fi changed', 'use direct mode');
} else {
$surge.setSelectGroupPolicy('Final-select', 'Group');
$surge.setOutboundMode('rule');
$notification.post('Surge', 'Wi-Fi changed', 'use rule-based proxy mode');
}
$done();
@alanhg

This comment has been minimized.

Copy link
Owner Author

@alanhg alanhg commented Feb 6, 2021

对应配置如下

[Script]
script1 = type=event,event-name=network-changed,script-path=wifi-changed.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment