今までのスクリプトをjQueryで書き直してみた。(広告削除はStylishとAdblock Plusに任せるw)
ニコ動は微妙にテーブルレイアウトだったりするのでjQueryのセレクタで要素を指定していくほうが見やすい。そしてラク!
機能
- 読み込み時にプレイヤーまで自動スクロール (ディスプレイが大きい人はいらないかも)
- 動画のタイトルを常に省略せずに表示する
- 詳細情報・メニューが動画の右側に表示されるのでプレイヤーが下にズレない
問題点(疑問点)
追記
- 2009.07.18 | ニコ動のレイアウトが微妙に変わっていたので修正した
スクリプト
// ==UserScript== // @name jNicoScrollAndFix // @namespace http://d.hatena.ne.jp/Azr_pp/ // @include http://www.nicovideo.jp/watch/* // @require http://jqueryjs.googlecode.com/files/jquery-1.3.2.js // ==/UserScript== $(function(){ //スクロール $('html, body').animate({scrollTop: $('div#WATCHHEADER').offset().top}, 1000); //読み込み時の表示状態による分岐 if ($('div#des_1').attr("style").search(/.+none.+/) == 0) { $('embed#flvplayer').css({width: 552}); } else { $('div#des_2').css({display: "block"}); } //タイトルを常に省略せずに表示 $('div#des_1 td a') .text($('div#des_2 h1 a:first').text()) .after($('div#des_2 h1 a:last').clone()); $('div#des_1 td span').remove(); $('div#des_2 td').css({paddingBottom: 3}); $('div#des_2 h1').css({paddingTop: 1}); //詳細情報をプレイヤ右に収まるように加工 $('div#des_2 table:first').removeAttr("width"); $('div#des_2 table:first td:last p:first').css({display: "none"}); $('div#des_2 h1').css({display: "none"}); $('div#des_2 img.video_des_top').css({width:390}); $('div#des_2 table:last').removeAttr("width"); $('div#des_2 table:last td:eq(4)').remove(); $('div#des_2 table:last td').wrap('<tr></tr>'); //ここで保存 var sideBox = $('div#des_2').clone(); //元に戻す $('div#des_2 table:first').attr("width", 984); $('div#des_2 table:first td:last p:first').css({display: "block"}); $('div#des_2 h1').css({display: "block"}); //タグより上の表示が変化しないようにする $('div#des_2').children(':not(table)').remove(); $('div#des_2 table:last').remove(); $('div#des_2 td:first').remove(); $('div#des_2 p.TXT12').remove(); $('div#des_2 p:last').remove(); if ($('div#des_1').attr("style").search(/.+block.+/) == 0) { $('div#des_1 + div#des_2').css({display: "none"}); } //マウスイベント $('div#des_1 > p > a').click(function(){ $('embed#flvplayer').css({width: 552}); }); $('div#des_2 > table p > a').click(function(){ $('embed#flvplayer').css({width: 952}); }); //プレイヤ右に配置 $('div#flvplayer_container') .css({position: "relative"}) .prepend( sideBox .css({ position: "absolute", right: 16, width: 400, height: 512, overflowX: "hidden", overflowY: "auto" }) .removeAttr("id") ); //ここより下のプログラムは何故か動かないorz });