見てるページをはてなアンテナに追加する FireGestures スクリプト
なんてことない単純なものだけど
gBrowser.loadURI("http://a.hatena.ne.jp/Azr_pp/append?" + encodeURIComponent(gBrowser.currentURI.spec));
Twitter のプロフィールページにおいて自己紹介欄のユーザー名の部分とハッシュタグにリンクを貼る Greasemonkey スクリプト
昨日のスクリプトの改良拡張版。
機能
Twitterの自己紹介欄(プロフィールページの右側)でよく「@fooもよろしくお願いします」や「#bar歓迎」というふうに、自分のサブ垢やBOT、よく使うハッシュタグを紹介しているのを見かける。このスクリプトは、その「foo」および「#bar」の部分に、タイムラインの表示と同じようにリンクを貼るもの。いちいちアドレスバーにコピペする手間を省く。
※ただし「@」や「#」がないと反応しません
ソース
// ==UserScript== // @name Twitter Append Link // @namespace http://d.hatena.ne.jp/Azr_pp/ // @include http://twitter.com/* // ==/UserScript== (function () { var profile = document.getElementById('bio').childNodes; var sentence = profile[2].textContent; var target = sentence.match(/(@|#)\w*/g); var newSpan = profile[2].cloneNode(true); newSpan.textContent = ""; var start = 0; var end = 0; for (var i = 0, l = target.length; i < l; i++) { if (target[i].search(/^@/) == 0) { var username = target[i].slice(1, target[i].length); var p_url = 'http://twitter.com/' + username; var p_link = document.createElement('a'); p_link.setAttribute('href', p_url); p_link.appendChild(document.createTextNode(username)); end = sentence.indexOf(target[i], start) + 1; newSpan.appendChild(document.createTextNode(sentence.slice(start, end))); newSpan.appendChild(p_link); start = end + target[i].length - 1; } else { var hashtag = target[i].slice(1, target[i].length); var h_url = 'http://twitter.com/#search?q=%23' + hashtag; var h_link = document.createElement('a'); h_link.setAttribute('href', h_url); h_link.appendChild(document.createTextNode(target[i])); end = sentence.indexOf(target[i], start); newSpan.appendChild(document.createTextNode(sentence.slice(start, end))); newSpan.appendChild(h_link); start = end + target[i].length; } } newSpan.appendChild(document.createTextNode(sentence.slice(start))); profile[2].parentNode.replaceChild(newSpan, profile[2]); })();
Twitter のプロフィールページにおいて自己紹介欄のユーザー名の部分にリンクを貼る Greasemonkey スクリプト
機能
Twitterの自己紹介欄(プロフィールページの右側)でよく「@hogehogeもよろしくお願いします」というふうに、自分のサブ垢やBOTを紹介しているのを見かけるが、この@以下の「hogehoge」の部分に、タイムラインの表示と同じようにリンクを貼るスクリプト。これで一手間省けるかなあと。
※ただし「@」がないと反応しません
ソース
// @name Twitter Username Link // @namespace http://d.hatena.ne.jp/Azr_pp/ // @include http://twitter.com/* // ==/UserScript== (function () { var profile = document.getElementById('bio').childNodes; var sentence = profile[2].textContent; var username = sentence.match(/@\w*/g); var newSpan = profile[2].cloneNode(true); newSpan.textContent = ""; var start = 0; var end = 0; for (var i = 0, l = username.length; i < l; i++) { var username2 = username[i].slice(1, username[i].length); var url = 'http://twitter.com/' + username2; var link = document.createElement('a'); link.setAttribute('href', url); link.appendChild(document.createTextNode(username2)); end = sentence.indexOf(username[i], start) + 1; newSpan.appendChild(document.createTextNode(sentence.slice(start, end))); newSpan.appendChild(link); start = end + username[i].length - 1; } newSpan.appendChild(document.createTextNode(sentence.slice(start))); profile[2].parentNode.replaceChild(newSpan, profile[2]); })();
TwitterGadget でフッターを付加する Greasemonkey スクリプト
機能
- Tweet 欄にフォーカスしたときに任意のフッターを付加する
- カーソルの位置を場合に応じて移動させる
問題点
- Reply や ReTweet したときは、フォーカスしなおさないとカーソルの位置が適切な位置に移動しない
スクリプト
// ==UserScript== // @name TwitterGadgetFooter // @namespace http://d.hatena.ne.jp/Azr_pp/ // @include http://www.twittergadget.com/gadget.asp* // ==/UserScript== var postBox = document.getElementById('ta'); var footer = " ここに付加したいテキストを入れる"; function appendFooter(){ postBox.value += footer; } function setCursor(position) { postBox.setSelectionRange(position, position); } postBox.addEventListener("focus", function(){ if (postBox.value.indexOf("RT @") == 0 && postBox.value.indexOf(footer) == -1) { } else if (postBox.value.indexOf(footer) == -1) { appendFooter(); setCursor(postBox.value.length - footer.length); } else if (postBox.value.indexOf("RT @") == 0 && postBox.value.indexOf(footer) == -1) { appendFooter(); postBox.value = " " + postBox.value; setCursor(0); } else if (postBox.value.indexOf("RT @") == 1) { setCursor(0); } else { setCursor(postBox.value.length - footer.length); } }, true);
プレイヤーの位置に関するニコ動ββ用Greasemonkeyスクリプト with jQuery
今までのスクリプトを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 });