Last active
August 29, 2015 14:17
-
-
Save MisterGlass/a946ae5900ae8024ac5f to your computer and use it in GitHub Desktop.
bookmarklet to submit to youtube downloader script
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
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