Skip to content

Instantly share code, notes, and snippets.

@satyr
Created December 9, 2011 08:41
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save satyr/1450766 to your computer and use it in GitHub Desktop.
Save satyr/1450766 to your computer and use it in GitHub Desktop.
mondraminiurl
/*
// ==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')));
/*
// ==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