YouTubeリンク作成 幅指定&テキストリンク&はてブ数付き
by
linclip
2013-04-24 [2013/04/24 22:05:39]
YouTubeリンク 幅指定&テキストリンク&はてブ数付き - 幅指定したい。テキストリンク入れたい。はてなブックマークの登録数入れたい。YouTubeへのリンク作成をカンタンにするブックマークレット。
@@ -21,7 +21,7 @@
var html = '<iframe width="' + userWidth + '" height="' + userHeight +'" src="http://www.youtube.com/embed/' + url + '" frameborder="0" allowfullscreen></iframe>';
- html += '<br /><a href="http://www.youtuve.com/watch?v=' + url + '" target="_blank">' + title + '</a>';
+ html += '<br /><a href="http://www.youtube.com/watch?v=' + url + '" target="_blank">' + title + '</a>';
html += '<a href="http://b.hatena.ne.jp/entry/http://www.youtube.com/watch?v=' + url + '" target="_blank" rel="nofollow"><img src="http://b.hatena.ne.jp/entry/image/http://www.youtube.com/watch?v=' + url + '" alt="" style="border:none" /></a>';
/*
* @title YouTubeリンク作成 幅指定&テキストリンク&はてブ数付き
* @description YouTubeリンク 幅指定&テキストリンク&はてブ数付き - 幅指定したい。テキストリンク入れたい。はてなブックマークの登録数入れたい。YouTubeへのリンク作成をカンタンにするブックマークレット。
* @include http://*
* @license MIT License
* @require
* @require jQuery
*/
var url = $("meta[name='twitter:player']").eq(0).attr("content").match(/embed\/(.*)/);
var width = $("meta[name='twitter:player:width']").eq(0).attr("content");
var height = $("meta[name='twitter:player:height']").eq(0).attr("content");
var title = $("meta[name='title']").eq(0).attr("content");
url = RegExp.$1;
var userWidth = window.prompt("width", "450");
if (userWidth){
var userHeight = Math.floor(userWidth / width * height);
var html = '<iframe width="' + userWidth + '" height="' + userHeight +'" src="http://www.youtube.com/embed/' + url + '" frameborder="0" allowfullscreen></iframe>';
html += '<br /><a href="http://www.youtube.com/watch?v=' + url + '" target="_blank">' + title + '</a>';
html += '<a href="http://b.hatena.ne.jp/entry/http://www.youtube.com/watch?v=' + url + '" target="_blank" rel="nofollow"><img src="http://b.hatena.ne.jp/entry/image/http://www.youtube.com/watch?v=' + url + '" alt="" style="border:none" /></a>';
window.prompt("copy this code!", html);
}
- Permalink
- このページへの個別リンクです。
- RAW
- 書かれたコードへの直接のリンクです。
- Packed
- 文字列が圧縮された書かれたコードへのリンクです。
- Userscript
- Greasemonkey 等で利用する場合の .user.js へのリンクです。
- Loader
- @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
- Metadata
- コード中にコメントで @xxx と書かれたメタデータの JSON です。