Greasemonkey は firefox の addon で、特定のページを見るときに登録した script が動くようにするものである。
中身は簡単な javascript です。Header の @include の行で、script が働くurl を指定します。適当な file にこのような script を書いて、これを Greasemonkey に登録します。
Amazon の wishlist のページで、左側の navigation と右側の本のリストの位置を入れ替える script
// ==UserScript== // @name change arrange of amazon wishlist // @namespace // @include http://www.amazon.co.jp/gp/registry/wishlist/* // @include https://www.amazon.co.jp/gp/registry/wishlist/* function do_script() { var smallTable=document.evaluate("//table[@class='small']", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_ TYPE, null).snapshotItem(0); var hidari = smallTable.parentNode; var migi = hidari.nextSibling; hidari.parentNode.removeChild(hidari); migi.parentNode.insertBefore(hidari, migi.netxSibling); }; do_script() //.user.jsript
簡単に説明すると、load したページの object tree から class が small に指定されている table 要素を探す。これが navi なので、これの親の td 要素を兄弟の td 要素と入れ替えている。
もちろん、ページのデザインを変えられたら動かなくなります。