Last active
June 23, 2025 18:37
-
-
Save devwolf75/8ea522aa06aefa22ae1e8cdda810c722 to your computer and use it in GitHub Desktop.
Add download URL button to Vimm's Vault pages
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 Vimm's Lair Download Button | |
| // @homepage https://gist.github.com/devwolf75/8ea522aa06aefa22ae1e8cdda810c722 | |
| // @version 0.1 | |
| // @description Vimm's Lair script to add a 'Download URL' button on the page, copies URL to clipboard. | |
| // @icon https://www.google.com/s2/favicons?sz=64&domain=vimm.net | |
| // @author devwolf75 | |
| // @match https://vimm.net/vault/* | |
| // @include https://vimm.net/vault/* | |
| // @grant none | |
| // @require https://code.jquery.com/jquery-3.6.0.min.js | |
| // @downloadURL https://gist.githubusercontent.com/devwolf75/8ea522aa06aefa22ae1e8cdda810c722/raw/63a667d2fe1102f94ba886bf0c5749b1b530ee86/vimm_download_url.js | |
| // @updateURL https://gist.githubusercontent.com/devwolf75/8ea522aa06aefa22ae1e8cdda810c722/raw/63a667d2fe1102f94ba886bf0c5749b1b530ee86/vimm_download_url.js | |
| // ==/UserScript== | |
| var buttonInserted = false; | |
| var mediaId = ""; | |
| var url = ""; | |
| window.addEventListener("load", function () { | |
| addButton(); | |
| document.getElementById("disc_number").addEventListener("change", function() { | |
| removeButton(); | |
| addButton(); | |
| }); | |
| }); | |
| window.addEventListener("focus", function () { | |
| addButton(); | |
| document.getElementById("disc_number").addEventListener("change", function() { | |
| removeButton(); | |
| addButton(); | |
| }); | |
| }); | |
| function addButton(url) { | |
| mediaId = document.querySelector("input[name='mediaId']").value; | |
| url = `https://dl3.vimm.net/?mediaId=${mediaId}`; | |
| let button = $("#dl_form").append( | |
| '<button type="button" style="width:100%" id="copy_url">Copy URL</button>' | |
| ); | |
| button.on("click", function () { | |
| if (document.hasFocus()) { | |
| (async () => { | |
| await navigator.clipboard.writeText(url); | |
| })(); | |
| } | |
| }); | |
| buttonInserted=true; | |
| } | |
| function removeButton() { | |
| let button = document.getElementById("copy_url").remove(); | |
| buttonInserted = false; | |
| } | |
| function clearText() { | |
| (async () => { | |
| await navigator.clipboard.writeText(url); | |
| })(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment