Created
March 19, 2014 14:06
-
-
Save jimmystridh/9642320 to your computer and use it in GitHub Desktop.
UserScript to fetch the embed link from a Dropbox share link, and embed in youtrack
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 YouTrack Dropbox Embed | |
// @namespace http://visit.com/ | |
// @version 0.1 | |
// @description inserts an image from a dropbox url | |
// @match https://youtrack.internal.visit.com/* | |
// @copyright 2012+, Jimmy | |
// ==/UserScript== | |
(function(){ | |
document.addEventListener('keydown', function(e) { | |
// pressed alt+g | |
if (e.keyCode == 71 && e.shiftKey && !e.ctrlKey && e.altKey && !e.metaKey) { | |
var url = prompt("Dropbox url?",""); | |
if (url != null) | |
{ | |
GM_xmlhttpRequest({ // that would be "func1" | |
"method" : "GET", | |
"url" : url, // first url in the list | |
"onload" : function(xhr) | |
{ | |
var oPage = xhr.responseText; // page contents | |
console.log(oPage); | |
var link = /<a href="(https:\/\/dl.dropboxusercontent.*?)" id="download_button_link"/.exec(oPage)[1]; | |
var textarea = document.querySelector("textarea[name*=description]"); | |
textarea.innerHTML += "\n{html}<img src=\"" + link + "\" width=\"100%\" />{html}"; | |
} | |
}); | |
} | |
} | |
}, false); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment