Greasy Fork

Greasy Fork is available in English.

添加GitHub、huggingface镜像下载链接

添加GitHub、huggingface镜像下载链接,可直接在Linux服务器粘贴使用

当前为 2024-08-09 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==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 = "已复制";
}