AutoPagerizeをGoogleイメージ検索(画像検索)で動作させる
最近は、AutoPagerize + LDRize + KeyConfig + functions for KeyConfigなどを使って、キーボードでFirefoxを操作するのになれてしまったが、Googleイメージ検索ではautopagerizeが機能してくれない。
何かいい方法はないかと検索した結果、次のGreasemonkeyスクリプトをインストールするとautopagerizeが機能するようになることを知った。
風柳亭 - 別館:書庫のある庵 -: AutoPagerize/AutoPagerlike:Google イメージ検索への対応を試みる
このページにある「Google イメージ検索対応のおまじない」というスクリプトをインストールし、ユーザースクリプトの管理を開いてAutoPagerizeの上に移動させる。
その後、AutoPagerizeのファイルを開き、SITEINFOの所に次のように書き足す。(リンク先サイトにある「AutoPagerize ver 0.0.26+パッチ版」というのはたぶん下記のサイトインフォを書き足しただけだと思う。現在のAutoPagerizeのバージョンは0.0.31なので、自分で書き足した方がよさげ。他にもSITEINFOを書き足してるし。)
var SITEINFO = [ { name: 'Googleイメージ検索', url: 'http://images\\.google\\..+/images\\?.+', nextLink: 'id("nn")/parent::a', pageElement: '//table[tbody/tr/td/a[starts-with(@href,"/imgres")]]', },
これは自分で書き足したもので、パッチ版は以下のようになっている。
var SITEINFO = [ { url : 'http://images\\.google\\..+/images\\?.+' , nextLink : 'id("nn")/parent::a' , pageElement : '//table[tbody/tr/td/a[starts-with(@href,"/imgres")]]' , insertBefore : 'id("ImgContent")/following-sibling::node()' , exampleUrl : 'http://images.google.com/images?gbv=2&hl=ja&safe=off&q=%E3%83%9A%E3%83%BC%E3%82%B8' },
これで、Googleイメージ検索でAutoPagerizeが実行されるようになる。
そしてさらにLDRizeを動作させるため、こちらも編集していく。
{ name: 'Googleイメージ検索', domain: 'http://images.google.*/', paragraph: '//img/parent::a/parent::td', link: 'a', },
これで、j,kのキーを押すたびに各画像の位置まで移動できる。
目的の画像の場所でO(オー)を押すと新規タブでそのサイトが開くが、画像が直接開かれるわけじゃなく、Googleのフレームページを経る必要がある。
これはかなり面倒くさいので、これも飛ばしていく。
自分用にGreasemonkeyのスクリプトを新規作成し、次のように書く。
url = content.document.location.href; if (url.match(/images.google.com\/imgres/)) { var href = document.title; href = href.replace(/^.*(http.*)$/, "$1"); if (href.match(/blogs.yahoo.*\/(.*?)\/folder/)) { var blogId = RegExp.$1; href = "http://blogs.yahoo.co.jp/" + blogId + "/GALLERY/show_image_v2.html?id=" + href; } location.href = href; }