Created
December 9, 2011 08:41
-
-
Save satyr/1450766 to your computer and use it in GitHub Desktop.
mondraminiurl
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== | |
// @id mdmu_satyr | |
// @name mondraminiurl | |
// @version 0.1 | |
// @namespace http://satyr.github.com | |
// @author satyr | |
// @description Minifies the deck URL, copying it if possible. | |
// @include http://w001.monsterdragon.jp/deck/index* | |
// ==/UserScript== | |
*/ | |
(function(){ | |
var input; | |
input = document.getElementById('monste-deck-url'); | |
this.textContent = 'Minify'; | |
this.accessKey = 'm'; | |
this.addEventListener('click', function(){ | |
this.parentNode.removeChild(this); | |
return GM_xmlhttpRequest({ | |
method: 'POST', | |
url: 'https://www.googleapis.com/urlshortener/v1/url', | |
headers: { | |
'Content-Type': 'application/json' | |
}, | |
data: JSON.stringify({ | |
longUrl: input.value | |
}), | |
onload: function(it){ | |
var u; | |
u = input.value = JSON.parse(it.responseText).id; | |
if (typeof GM_setClipboard == 'function') { | |
GM_setClipboard(u); | |
} | |
input.focus(); | |
document.execCommand('selectAll'); | |
document.execCommand('copy'); | |
} | |
}); | |
}, false); | |
input.parentNode.insertBefore(this, input.previousSibling.previousSibling); | |
}.call(document.createElement('button'))); |
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== | |
// @id mdmu_satyr | |
// @name mondraminiurl | |
// @version 0.1 | |
// @namespace http://satyr.github.com | |
// @author satyr | |
// @description Minifies the deck URL, copying it if possible. | |
// @include http://w001.monsterdragon.jp/deck/index* | |
// ==/UserScript== | |
*/ | |
with document.createElement \button | |
input = document.getElementById \monste-deck-url | |
@textContent = \Minify | |
@accessKey = \m | |
@addEventListener \click -> | |
@parentNode.removeChild this | |
GM_xmlhttpRequest do | |
method : \POST | |
url : \https://www.googleapis.com/urlshortener/v1/url | |
headers : \Content-Type : \application/json | |
data : JSON.stringify longUrl: input.value | |
onload : !-> | |
u = input.value = JSON.parse it.responseText .id | |
GM_setClipboard? u | |
input.focus! | |
document.execCommand \selectAll | |
document.execCommand \copy | |
, false | |
input.parentNode.insertBefore this, input.previousSibling.previousSibling |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment