Created
October 21, 2011 04:01
-
-
Save samrat/1303069 to your computer and use it in GitHub Desktop.
Videodropper bookmarklet- under progress
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
if (!($ = window.jQuery)) { // typeof jQuery=='undefined' works too | |
script = document.createElement('script'); | |
script.src = 'http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js'; | |
script.onload = videodropper_bookmarklet; | |
document.body.appendChild(script); | |
} | |
else { | |
videodropper_bookmarklet(); | |
} | |
d = document; b = d.body; | |
origTitle = d.title; | |
func = function(data) { alert(data.message); d.title = origTitle; | |
}; | |
var page_url = document.location.href; | |
function videodropper_bookmarklet() { | |
d.title = "(Videodropping..)" + d.title; | |
//z = d.createElement('div') | |
//z.setAttribute('style', '') | |
function gup(name) { | |
name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]"); | |
var regexS = "[\\?&]" + name + "=([^&#]*)"; | |
var regex = new RegExp(regexS); | |
var results = regex.exec(page_url); | |
if (results === null) { | |
return ""; | |
} | |
else { | |
return results[1]; | |
} | |
} | |
videoid = gup('v'); | |
url = "http://gdata.youtube.com/feeds/api/videos/" + videoid + "?v=2&alt=json-in-script&callback=?"; | |
$.getJSON(url, function(json) { | |
send_url = "http://videodropper.ep.io/bookmarklet?video_url=" + encodeURIComponent(json.entry["media$group"]["media$player"].url); | |
var request = $.ajax({ | |
url: send_url, | |
type: 'GET', | |
dataType: 'jsonp', | |
//success: function func(data) { | |
// alert(data.message); | |
//} | |
}); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment