Greasy Fork is available in English.
添加GitHub、huggingface镜像下载链接,可直接在Linux服务器粘贴使用
当前为
// ==UserScript==
// @name 添加GitHub、huggingface镜像下载链接
// @namespace http://tampermonkey.net/
// @version 0.6
// @description 添加GitHub、huggingface镜像下载链接,可直接在Linux服务器粘贴使用
// @author HuanZhi
// @match https://github.com/*
// @match https://huggingface.co/*
// @match https://hf-mirror.com/*
// @grant unsafewindow
// @license MIT
// @run-at document-end
// ==/UserScript==
(function(){
var btn = document.createElement("button");
btn.setAttribute('style', "position:absolute; z-index:1000; right:15px; top:55px; height:28px; background-color:#3E8CD0; border:none; color:white; font-size:16px; cursor:pointer; border-radius:1em;");
btn.setAttribute('id', "btn");
document.body.appendChild(btn);
btn.onmouseover = function() {
this.style.backgroundColor="#e9686b"
};
btn.onmouseout = function() {
this.style.backgroundColor="#3E8CD0"
};
var url = window.location.href;
if (url.includes("github")) {
btn.innerText = "镜像地址";
btn.onclick = GitMirrorLink;
} else if (url.includes("huggingface")) {
btn.innerText = "镜像地址";
btn.onclick = HFMirrorLink;
} else if (url.includes("hf-mirror")) {
btn.innerText = "镜像地址";
btn.onclick = HFMirrorLink;
}
}
)()
function GitMirrorLink(){
var home_url = `git clone https://mirror.ghproxy.com/${document.querySelector('.form-control.input-monospace.input-sm.color-bg-subtle').value}`;
navigator.clipboard.writeText(home_url);
btn.innerText = "已复制";
}
function HFMirrorLink(){
var home_url = `huggingface-cli download --resume-download ${document.querySelector('a.break-words.font-mono.font-semibold.hover\\:text-blue-600').getAttribute('href').slice(1)} --local-dir ${document.querySelector('a.break-words.font-mono.font-semibold.hover\\:text-blue-600').getAttribute('href').split("/").slice(-1)}`;
navigator.clipboard.writeText(home_url);
btn.innerText = "已复制";
}