ニコニコ動画:Zero用 iframeタグ取得支援 bookmarklet

5月1日に、「ニコニコ動画:Zero」が開始された訳ですけれど、それまであった幾つかの機能が相変わらず提供されていないままになっています。



未実装機能について
ZeroWatchではリリース時一部機能が未実装になります。
これらの機能は、検討の上追って対応していきます。

・マイリスト表示
・共有ボタン
・マーキー:地震共有広場へのリンク
・コモンズツリー、@BGM、@CM、投稿者コメントなどの動画情報の表示
・過去ランキングの表示
・コミュニティへの登録
・チャンネルお気に入り登録ボタン

この内、「共有ボタン」の機能に含まれる、ニコニコ動画の動画情報を blog に埋め込む用の iflameタグ を取得したいので、以前に使っていた、取得を支援する bookmarkletニコニコ動画:Zero用に更新しました。それに合わせて、外部プレイヤーを呼び出す bookmarklet も更新しました。


bookmarkletの実行は自己責任で。

使い方

ニコニコ動画の動画再生ページで実行し、Ctrl+Cを押すだけ。
ニコニコ動画ログイン。
FireFox12.0 で動作確認。多分、他でも動くはず。

bookmarklet (iflameタグ取得支援)

IE, FireFox 両用

javascript:(function(){var src;var insert;var frame;var match_str='/www.nicovideo.jp/watch/';var src_base='http://www.nicovideo.jp/embed/';var pos=location.href.lastIndexOf(match_str);if(pos>-1){src=location.href.substring(pos+match_str.length);}else{alert('%E5%8B%95%E7%94%BBURL%E5%8F%96%E5%BE%97%E5%A4%B1%E6%95%97');return;}insert=document.getElementById('content');if(!insert||(insert.tagName!='DIV')){insert=document.getElementById('body');if(!insert||(insert.tagName!='DIV')){insert=document.body;}}frame=document.createElement('iframe');frame.style.width='100%';frame.src=src_base+src;if(document.all){frame.onreadystatechange=function(){if(this.readyState=='complete'){var code=frame.contentWindow.document.form_iframe.iframe_code;alert(code.value);code.focus();code.select();clipboardData.setData('text',code.value);this.onreadystatechange=null;}}}else{frame.onload=function(){var code=frame.contentWindow.document.form_iframe.iframe_code;code.focus();code.select();};}insert.insertBefore(frame,insert.firstChild);})();


はてなダイアリーでの動画の埋め込み

javascript:(function(){var src;var insert;var frame;var match_str='/www.nicovideo.jp/watch/';var src_base='http://www.nicovideo.jp/embed/';var pos=location.href.lastIndexOf(match_str);if(pos>-1){src=location.href.substring(pos+match_str.length);}else{alert('%E5%8B%95%E7%94%BBURL%E5%8F%96%E5%BE%97%E5%A4%B1%E6%95%97');return;}insert=document.getElementById('content');if(!insert||(insert.tagName!='DIV')){insert=document.getElementById('body');if(!insert||(insert.tagName!='DIV')){insert=document.body;}}frame=document.createElement('iframe');frame.style.width='100%';frame.src=src_base+src;if(document.all){frame.onreadystatechange=function(){if(this.readyState=='complete'){var code=frame.contentWindow.document.form_iframe.iframe_code;alert(code.value);code.value+='[niconico:'+src+']';code.focus();code.select();clipboardData.setData('text',code.value);this.onreadystatechange=null;}}}else{frame.onload=function(){var code=frame.contentWindow.document.form_iframe.iframe_code;code.value+='[niconico:'+src+']';code.focus();code.select();};}insert.insertBefore(frame,insert.firstChild);})();


自分用(FireFox only + はてなダイアリー

javascript:(function(){var src;var insert;var frame;var match_str='/www.nicovideo.jp/watch/';var src_base='http://www.nicovideo.jp/embed/';var pos=location.href.lastIndexOf(match_str);if(pos>-1){src=location.href.substring(pos+match_str.length);}else{alert('%E5%8B%95%E7%94%BBURL%E5%8F%96%E5%BE%97%E5%A4%B1%E6%95%97');return;}insert=document.getElementById('content');if(!insert||(insert.tagName!='DIV')){insert=document.getElementById('body');if(!insert||(insert.tagName!='DIV')){insert=document.body;}}frame=document.createElement('iframe');frame.style.width='100%';frame.src=src_base+src;frame.onload=function(){var code=frame.contentWindow.document.form_iframe.iframe_code;code.value+='[niconico:'+src+']';code.focus();code.select();};insert.insertBefore(frame,insert.firstChild);})();

bookmarklet (外部プレイヤー呼び出し)

*1

javascript:(function(){var match_str='/www.nicovideo.jp/watch/';var scr_src_base='http://ext.nicovideo.jp/thumb_watch/';var scr_src;var scr;var pos;var insert;var out;var bk_func=null;pos=location.href.lastIndexOf(match_str);if(pos>-1){scr_src=scr_src_base+location.href.substring(pos+match_str.length);}else{alert('%E5%8B%95%E7%94%BBURL%E5%8F%96%E5%BE%97%E5%A4%B1%E6%95%97');return;}insert=document.getElementById('content');if(!insert||(insert.tagName!='DIV')){insert=document.getElementById('body');if(!insert||(insert.tagName!='DIV')){insert=document.body;}}out=document.createElement('div');insert.insertBefore(out,insert.firstChild);if((typeof(HTMLDocument)!='undefined')&&HTMLDocument.prototype){HTMLDocument.prototype.write=function(str){try{out.innerHTML+=str;}catch(e){return;}};}else{bk_func=document.write;document.write=function(str){try{out.innerHTML+=str;}catch(e){return;}};}scr=document.createElement('script');scr.charset='UTF-8';scr.src=scr_src;document.body.appendChild(scr);setTimeout(function(){if(!bk_func){delete HTMLDocument.prototype.write;}else{document.write=bk_func;}},5000);})()

外部プレイヤーが便利な点。

  • cookieの有効期限切れで怒られたりしない
  • 動画を観る以外に機能が付いていない
  • ログインすることすら面倒臭くても観れる