Skip to content

Instantly share code, notes, and snippets.

@noskla
Created November 1, 2019 21:21
Show Gist options
  • Save noskla/938178d580e81a7bc2df8be0db63f5a8 to your computer and use it in GitHub Desktop.
Save noskla/938178d580e81a7bc2df8be0db63f5a8 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name z0r.de download button
// @include https://z0r.de/*
// @version 1
// @grant none
// ==/UserScript==
window.addEventListener('load', function(){
// New element
var button = document.createElement('a');
var button_text = document.createTextNode('Download');
button.appendChild(button_text);
// CSS
button.style.backgroundColor = "#555555";
button.style.color = "#dedede";
button.style.padding = "3px";
button.style.position = "fixed";
button.style.top = "5px";
button.style.right = "5px";
// Check if flash exists on site and get the data.
var flash = document.getElementsByTagName('object');
button.style.display = ( (flash[0] === undefined) ? "none" : "block" );
var flash_filename = flash[0].getAttribute("data");
// Set attributes to link element
button.setAttribute("href", `https://z0r.de${flash_filename}`);
button.setAttribute("download", flash_filename);
document.body.appendChild(button);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment