基于yacd的clash-core定时选择最快节点

先来一个干货,github加速,执行这个命令,clone github项目直接起飞

git config --global http.https://github.com.proxy socks5://127.0.0.1:7891

当然,前提是运行了clash,且socks协议的端口是7891。

安装和配置clash就不说了,主要说一下如何在yacd这个clash前端实现自动选择最快节点。

找到yacd的index.html文件,在那一堆之间插入如下代码。

<script>
setTimeout(clock,5000)
var int=self.setInterval("clock()",60000);
var count = 1;
function clock()
{
    document.querySelector("#app > div > div.AwL8oIubvP > ul > li > button").click()
    console.log("第" + count + "次测试延迟,选择最快节点...")
    count++;
    if(count % 5 == 0) console.clear();
}</script>

原理就是每隔1分钟自动模拟点击一下测速按钮,然后就会自动选择最快节点了。

再把yacd这个标签页锁定一下,就不容易被关掉了。标签页得一直开着,否则是无法自动切换的。

下面是我的完整版index.html. 不同版本的yacd可能不一样。

<!doctype html><html lang="en"><head><meta charset="UTF-8"><link rel="shortcut icon" href="yacd.ico"><link rel="icon" type="image/png" sizes="64x64" href="yacd-64.png"><link rel="icon" type="image/png" sizes="128x128" href="yacd-128.png"><link rel="preload" href="/open-sans-latin-400.woff2" as="font" type="font/woff2" crossorigin><link rel="preload" href="/open-sans-latin-700.woff2" as="font" type="font/woff2" crossorigin><link rel="preload" href="/roboto-mono-latin-400.woff2" as="font" type="font/woff2" crossorigin><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><meta name="application-name" content="yacd"><meta name="description" content="Yet Another Clash Dashboard"><meta name="theme-color" content="#202020"><title>yacd - Yet Another Clash Dashboard</title><meta property="og:image" content="https://user-images.githubusercontent.com/1166872/47304841-536f3d80-d65a-11e8-8908-1917127dafc5.png"><meta property="og:site_name" content="yacd"><meta property="og:type" content="object"><meta property="og:title" content="yacd"><meta property="og:url" content="http://yacd.haishan.me"><meta property="og:description" content="Yet Another Clash Dashboard"><script defer="defer" src="runtime.30479c2b09f71505cee3.js"></script><script defer="defer" src="core-js~app.4e0935a458133ffa9ca3.js"></script><script defer="defer" src="react~app.10618449a8e9b56a1845.js"></script><script>
setTimeout(clock,5000)
var int=self.setInterval("clock()",60000);
var count = 1;
function clock()
{
    document.querySelector("#app > div > div.AwL8oIubvP > ul > li > button").click()
    console.log("第" + count + "次测试延迟,选择最快节点...")
    count++;
    if(count % 5 == 0) console.clear();
}</script><script defer="defer" src="app.a84ae01ae5f5532284ad.js"></script><link href="app.bb773b8bdd4263de9ffd.css" rel="stylesheet"></head><body><div id="app"></div></body></html>

你可能感兴趣的:(Linux,js,linux)