免费节点不稳定,总是需要手动更换节点。每次更新配置文件之后会覆盖所有修改,所以写个脚本自动把配置文件改成自动选择节点。问小白AI倾情奉献。 ```js // Define main function (script entry) function main(config, profileName) { // 确保配置中有代理组 if (!config['proxy-groups']) { config['proxy-groups'] = []; console.log('⚠️ 未找到代理组配置'); return config; } // 查找目标组 "🔰 选择节点" let targetGroupIndex = -1; for (let i = 0; i < config['proxy-groups'].length; i++) { if (config['proxy-groups'][i].name === "🔰 选择节点") { targetGroupIndex = i; break; } } if (targetGroupIndex === -1) { console.log('❌ 未找到名为 "🔰 选择节点" 的代理组'); return config; } // 收集所有可用的代理服务器(排除 DIRECT 和 REJECT) const allProxies = []; if (config.proxies) { config.proxies.forEach(proxy => { if (proxy.name !== 'DIRECT' && proxy.name !== 'REJECT' && proxy.type !== 'direct' && proxy.type !== 'reject') { allProxies.push(proxy.name); } }); } // 如果有可用的代理服务器,更新目标组 if (allProxies.length > 0) { // 更新原有组配置,保持名称不变 config['proxy-groups'][targetGroupIndex] = { name: "🔰 选择节点", // 保持原名称 type: "url-test", // 改为自动测速类型 proxies: allProxies, // 替换为所有可用节点 url: "http://www.gstatic.com/generate_204", interval: 15, tolerance: 200, lazy: false }; console.log(`✅ 已将 "🔰 选择节点" 组更新为自动选择模式`); console.log(`📊 包含 ${allProxies.length} 个节点:${allProxies.slice(0, 5).join(', ')}${allProxies.length > 5 ? '...' : ''}`); } else { console.log('⚠️ 未找到可用的代理节点,保持原有配置不变'); } return config; } ``` 说明: 1. **精准定位**:专门查找并覆盖名为 `🔰 选择节点` 的代理组(**需要将上述脚本中的`🔰 选择节点`改为你的配置文件中的代理组名称**) 2. **保持兼容**: * 维持原有组名称,确保其他规则的引用不受影响 * 只是将类型从 **`select` 改为** `url-test` 3. **全面覆盖**:将所有可用的代理节点都加入到自动选择中 Loading... 免费节点不稳定,总是需要手动更换节点。每次更新配置文件之后会覆盖所有修改,所以写个脚本自动把配置文件改成自动选择节点。问小白AI倾情奉献。 ```js // Define main function (script entry) function main(config, profileName) { // 确保配置中有代理组 if (!config['proxy-groups']) { config['proxy-groups'] = []; console.log('⚠️ 未找到代理组配置'); return config; } // 查找目标组 "🔰 选择节点" let targetGroupIndex = -1; for (let i = 0; i < config['proxy-groups'].length; i++) { if (config['proxy-groups'][i].name === "🔰 选择节点") { targetGroupIndex = i; break; } } if (targetGroupIndex === -1) { console.log('❌ 未找到名为 "🔰 选择节点" 的代理组'); return config; } // 收集所有可用的代理服务器(排除 DIRECT 和 REJECT) const allProxies = []; if (config.proxies) { config.proxies.forEach(proxy => { if (proxy.name !== 'DIRECT' && proxy.name !== 'REJECT' && proxy.type !== 'direct' && proxy.type !== 'reject') { allProxies.push(proxy.name); } }); } // 如果有可用的代理服务器,更新目标组 if (allProxies.length > 0) { // 更新原有组配置,保持名称不变 config['proxy-groups'][targetGroupIndex] = { name: "🔰 选择节点", // 保持原名称 type: "url-test", // 改为自动测速类型 proxies: allProxies, // 替换为所有可用节点 url: "http://www.gstatic.com/generate_204", interval: 15, tolerance: 200, lazy: false }; console.log(`✅ 已将 "🔰 选择节点" 组更新为自动选择模式`); console.log(`📊 包含 ${allProxies.length} 个节点:${allProxies.slice(0, 5).join(', ')}${allProxies.length > 5 ? '...' : ''}`); } else { console.log('⚠️ 未找到可用的代理节点,保持原有配置不变'); } return config; } ``` 说明: 1. **精准定位**:专门查找并覆盖名为 `🔰 选择节点` 的代理组(**需要将上述脚本中的`🔰 选择节点`改为你的配置文件中的代理组名称**) 2. **保持兼容**: * 维持原有组名称,确保其他规则的引用不受影响 * 只是将类型从 **`select` 改为** `url-test` 3. **全面覆盖**:将所有可用的代理节点都加入到自动选择中 最后修改:2025 年 10 月 30 日 © 允许规范转载 赞 别打赏,我怕忍不住购买辣条与续命水