Skip to content

Instantly share code, notes, and snippets.

@smbarbour
Last active June 2, 2025 14:28
Show Gist options
  • Save smbarbour/251e005ca1297ef29ac47858c76b5916 to your computer and use it in GitHub Desktop.
Save smbarbour/251e005ca1297ef29ac47858c76b5916 to your computer and use it in GitHub Desktop.
legacy.curseforge.com TamperMonkey script for MCUpdater
// ==UserScript==
// @name Curseforge MCUpdater URL getter
// @namespace http://tampermonkey.net/
// @version 0.2
// @description Copies the download URL for the mod jar for MCUpdater to clipboard
// @author edwardg
// @match https://legacy.curseforge.com/minecraft/mc-mods/*/files/*
// @grant GM_setClipboard
// ==/UserScript==
(function() {
'use strict';
// Article is the box that holds all the information about the file
var Article = document.getElementsByTagName("article");
// Buttons is the Download and Install buttons
let Buttons = Article[0].getElementsByClassName("flex")[3];
// Run on button click to copy to clipboard
function copyToClipboard()
{
var Article = document.getElementsByTagName("article");
var Filename = Article[0].getElementsByClassName("text-sm")[1].textContent;
var CurseURL = window.location.href;
var fileStrIndex = CurseURL.indexOf("files/");
var fileID = CurseURL.slice(fileStrIndex + 6); // Leaves with just 7 numbers from end of URL
var File_URL = "https://edge.forgecdn.net/files/";
File_URL = File_URL + fileID.slice(0,4) + "/" + fileID.slice(4) + "/" + Filename;
//alert(fileID + "\n" + Filename + "\n" + File_URL);
GM_setClipboard(File_URL);
}
// Adds the copy button next to the other buttons
function addCopyButton(Element)
{
var newButton = document.createElement("button");
newButton.innerHTML = "<img src=\"https://files.mcupdater.com/MCU_TM.png\"/>";
newButton.onclick = () => {
copyToClipboard();
}
newButton.style.marginRight = "10px";
Element.insertBefore(newButton, Buttons.childNodes[0]);
}
// This calls the run
addCopyButton(Buttons)
})();
// ==UserScript==
// @name Curseforge MCUpdater URL getter
// @namespace http://tampermonkey.net/
// @version 0.3
// @description Copies the download URL for the mod jar for MCUpdater to clipboard
// @author edwardg
// @match https://www.curseforge.com/minecraft/mc-mods/*/files/*
// @grant GM_setClipboard
// ==/UserScript==
// Run on button click to copy to clipboard
function copyToClipboard()
{
const filenameParagraph = document.querySelector('section.section-file-name p.wrap');
const Filename = filenameParagraph ? filenameParagraph.textContent.trim() : null;
var CurseURL = window.location.href;
var fileStrIndex = CurseURL.indexOf("files/");
var fileID = CurseURL.slice(fileStrIndex + 6); // Leaves with just 7 numbers from end of URL
var File_URL = "https://edge.forgecdn.net/files/";
File_URL = File_URL + fileID.slice(0,4) + "/" + fileID.slice(4) + "/" + Filename;
GM_setClipboard(File_URL);
}
// Adds the copy button next to the other buttons
function addCopyButton()
{
// Buttons is the Download and Install buttons
let Buttons = document.querySelector(".file-details>h2>.actions>.split-button");
var newButton = document.createElement("button");
newButton.innerHTML = "<img src=\"https://files.mcupdater.com/MCU_TM.png\"/>";
newButton.onclick = () => {
copyToClipboard();
}
newButton.style.marginRight = "10px";
Buttons.appendChild(newButton);
}
// Main
(function() {
'use strict';
// Wait a second for the page to load
setTimeout(addCopyButton, 1000);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment