-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwifi-changed.js
More file actions
34 lines (33 loc) · 909 Bytes
/
wifi-changed.js
File metadata and controls
34 lines (33 loc) · 909 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/**
* @description
* 如果是家里WI-FI则开启直连模式
* 如果不是家里WI-FI则开启代理模式
*/
const WIFI_DONT_NEED_PROXYS = ['ASUS_5G'];
if (wifiChanged()) {
if (WIFI_DONT_NEED_PROXYS.includes($network.wifi.ssid)) {
$surge.setOutboundMode('direct');
$notification.post(
'Surge',
`Wi-Fi changed to ${$network.wifi.ssid}`,
'use direct mode'
);
} else {
$surge.setSelectGroupPolicy('Final-select', 'Group');
$surge.setOutboundMode('rule');
$notification.post(
'Surge',
`Wi-Fi changed to ${$network.wifi.ssid}`,
'use rule-based proxy mode'
);
}
}
function wifiChanged() {
const currentWifiSSid = $persistentStore.read('current_wifi_ssid');
const changed = currentWifiSSid !== $network.wifi.ssid;
if (changed) {
$persistentStore.write($network.wifi.ssid, 'current_wifi_ssid');
}
return changed;
}
$done();