Skip to content

Instantly share code, notes, and snippets.

@MisterGlass
Last active August 29, 2015 14:17
Show Gist options
  • Save MisterGlass/a946ae5900ae8024ac5f to your computer and use it in GitHub Desktop.
Save MisterGlass/a946ae5900ae8024ac5f to your computer and use it in GitHub Desktop.
bookmarklet to submit to youtube downloader script
javascript:(function(){
serverUrl = 'http://example.com/youtubedl.php';
re = /^https?:\/\/www\.youtube\.com\/watch\?v=([\w-]+)/;
if(matches = re.exec(location.href)) {
videoId = matches[1];
var form = document.createElement("form");
form.setAttribute("method", 'post');
form.setAttribute("action", serverUrl);
var field = document.createElement("input");
field.setAttribute("type", "hidden");
field.setAttribute("name", 'url');
field.setAttribute("value", videoId);
form.appendChild(field);
document.body.appendChild(form);
form.submit();
} else {
alert('Invalid page: not a youtube video page');
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment