Last active
June 17, 2016 13:51
-
-
Save victordarras/6058a9a825cc5e5b7e94844a28842f8a to your computer and use it in GitHub Desktop.
This file contains 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 tinygrab download | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description try to take over the world! | |
// @author You | |
// @match http://grab.by/* | |
// @grant none | |
// @require https://npmcdn.com/clipboard@1.5.10/dist/clipboard.min.js | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
var buttonStyles = ` | |
.cpButton, .dlButton { | |
cursor:pointer; | |
display:block; | |
position:fixed; | |
z-index: 99; | |
top:0; | |
right: 0; | |
padding:.5em 1em; | |
margin:1em; | |
color:white; | |
} | |
.dlButton { | |
background:tomato; | |
} | |
.cpButton { | |
right:10em; | |
background:#5082e6; | |
} | |
.cpButton:hover, .dlButton:hover { | |
color: #fff; | |
box-shadow: inset 0 0 0 999em rgba(255,255,255,0.1); | |
} | |
.cpButton:active, .dlButton:active { | |
box-shadow: inset 0 0 0 999em rgba(255,255,255,0.4) | |
} | |
`; | |
var style = document.createElement('style') | |
style.appendChild(document.createTextNode(buttonStyles)); | |
style.type = 'text/css'; | |
document.head.appendChild(style); | |
var dlButton = document.createElement('a'); | |
var cpButton = document.createElement('a'); | |
dlButton.classList.add('dlButton'); | |
cpButton.classList.add('cpButton'); | |
dlButton.href = document.getElementById('thegrab').src; | |
cpButton.dataset.clipboardText = document.getElementById('thegrab').src; | |
dlButton.innerHTML = "TÉLÉCHARGER"; | |
cpButton.innerHTML = "COPIER LE LIEN"; | |
body.appendChild(dlButton); | |
body.appendChild(cpButton); | |
var clipboardButton = new Clipboard('.cpButton'); | |
clipboardButton | |
.on('success', function(){ | |
cpButton.innerHTML = "COPIÉ" | |
}) | |
.on('error', function(){ | |
cpButton.innerHTML = "ERROR" | |
}) | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment