Ubuntu10.10でビットマップフォントを無効にする

実際には10.04からなんだけど、Firefoxなどでフォントの大きさによってアンチエイリアスが効かなくなってビットマップフォントが適用されることがある。これは美しくないので修正した。

修正するファイル:
/etc/fonts/conf.avail/69-language-selector-ja-jp.conf

ファイル下方、170行目くらいにある

<test name="pixelsize" compare="less_eq">
    <double>18</double>
</test>

コメントアウトするなりして無効にすればおk

追記

然るべきフォントが入っていないと意味ありませんでした…

幸福に生きよ!

【希実香】
「文学じゃ敵は倒せないよ……敵を倒す学問は化学と物理のみ!」
ざくろ
「くす、くす、でも文学は負けないよ」
【希実香】
「負けない?」
ざくろ
「文学は勝つための学問じゃなくて……負けないための学問だよ……」
「だから、私は戦えるんだよ……」

素晴らしき日々〜不連続存在〜

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」の部分に、タイムラインの表示と同じようにリンクを貼るスクリプト。これで一手間省けるかなあと。
※ただし「@」がないと反応しません

追加予定

ハッシュタグにも同じようにリンクを貼る。(2009.9.23 追記: 実装しました)

ソース

// @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で書き直してみた。(広告削除はStylishAdblock Plusに任せるw)
ニコ動は微妙にテーブルレイアウトだったりするのでjQueryセレクタで要素を指定していくほうが見やすい。そしてラク

機能

  • 読み込み時にプレイヤーまで自動スクロール (ディスプレイが大きい人はいらないかも)
  • 動画のタイトルを常に省略せずに表示する
  • 詳細情報・メニューが動画の右側に表示されるのでプレイヤーが下にズレない

問題点(疑問点)

  • @requireで『jQuery-1.3.2.js』ではなく『jQuery-1.3.2.min.js』を取り込むと動作しない
  • prependで要素を追加(移動)したらそれより下のプログラムが何故か動かない。そのため『要素をコピー→要素を移動→スタイル変更→その他』の流れが『スタイル変更→要素をコピー→スタイルを戻す→その他→要素を移動』と複雑化している
  • タグ編集時にもズレないようにしたかったけど、$.getがうまく動いたり動かなかったりしたので諦めた

追記

  • 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
});