Skip to content

Instantly share code, notes, and snippets.

@ww24
Created January 16, 2012 12:41
Show Gist options
  • Save ww24/1620696 to your computer and use it in GitHub Desktop.
Save ww24/1620696 to your computer and use it in GitHub Desktop.
YouTube getVideoURL Bookmarklet
javascript:(function(){if(typeof(yt)==="undefined"){alert("このページでは実行できません");return false}var v=yt.playerConfig.args.url_encoded_fmt_stream_map.split(","),d=document,b=d.getElementsByTagName("body")[0],u=d.createElement("ul"),a,i;u.style["list-style-type"]="decimal";u.style.padding="10px 20px";u=b.insertBefore(u,b.firstChild);for(i=0;v.length>i;i++){v[i]=decodeURIComponent(v[i].split("url=")[1]).split("&type=");v[i][1]=v[i][1].split("&itag=").join(" [fmt=")+"]";a=d.createElement("a");a.href=v[i][0];a.innerText=v[i][1];u.appendChild(d.createElement("li")).appendChild(a)}})()
(function () {
if (typeof(yt) === "undefined") {
alert("このページでは実行できません");
return false;
}
var video_list = yt.playerConfig.args.url_encoded_fmt_stream_map.split(","),
d = document,
body = d.getElementsByTagName("body")[0],
ul = d.createElement("ul"),
a, i;
ul.style["list-style-type"] = "decimal";
ul.style.padding = "10px 20px";
ul = body.insertBefore(ul, body.firstChild);
for (i=0; video_list.length>i; i++) {
video_list[i] = decodeURIComponent(video_list[i].split("url=")[1]).split("&type=");
video_list[i][1] = video_list[i][1].split("&itag=").join(" [fmt=") + "]";
a = d.createElement("a");
a.href = video_list[i][0];
a.innerText = video_list[i][1];
ul.appendChild(d.createElement("li")).appendChild(a);
}
})();
@ww24
Copy link
Author

ww24 commented Jan 16, 2012

@ww24
Copy link
Author

ww24 commented Jan 19, 2012

YouTubeの仕様変更に伴い、
yt.getConfig("PLAYER_CONFIG") → yt.playerConfig
に変更。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment