Created
January 18, 2024 14:44
-
-
Save rf5860/bb5267399ef42782fd89b41616f7737c to your computer and use it in GitHub Desktop.
Add a button to copy direct-download links for GGUF models to the clipboard
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name HuggingFaceGGUFModelToClipboard | |
// @namespace https://huggingface.co | |
// @version 0.1 | |
// @description Add a button to copy direct-download links for GGUF models to the clipboard | |
// @author rjf89 | |
// @match https://huggingface.co/* | |
// @grant GM_setClipboard | |
// @grant GM_addStyle | |
// ==/UserScript== | |
GM_addStyle(` | |
.copyDirectLink { | |
cursor: pointer; | |
margin-left: 5px; | |
}`); | |
(function () { | |
const getDesiredLink = e => e.target.parentElement.querySelector("a").href.replace("/blob/", "/resolve/") + "?download=true" | |
const setClipboard = e => GM_setClipboard(getDesiredLink(e)) | |
const addClipboard = a => { | |
const span = document.createElement("span"); | |
span.classList.add("copyDirectLink"); | |
span.addEventListener("mouseup", setClipboard, false); | |
span.textContent = "📋"; | |
a.parentElement.appendChild(span); | |
}; | |
[...document.querySelectorAll('a[rel="noopener nofollow"')] | |
.filter(e => e.href.endsWith(".gguf")) | |
.forEach(addClipboard) | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment