--- title: 情報は集約されていなければ意味がない! author: kazu634 date: 2007-10-27 url: /2007/10/27/_675/ wordtwit_post_info: - 'O:8:"stdClass":13:{s:6:"manual";b:0;s:11:"tweet_times";i:1;s:5:"delay";i:0;s:7:"enabled";i:1;s:10:"separation";s:2:"60";s:7:"version";s:3:"3.7";s:14:"tweet_template";b:0;s:6:"status";i:2;s:6:"result";a:0:{}s:13:"tweet_counter";i:2;s:13:"tweet_log_ids";a:1:{i:0;i:3283;}s:9:"hash_tags";a:0:{}s:8:"accounts";a:1:{i:0;s:7:"kazu634";}}' categories: - つれづれ ---

 自分はFirefoxというブラウザを使っているのですが、そのFirefoxはGreasemonkeyというもので機能を拡張できます。そこで色々なことが出来るのですが、例えばAmazonの商品ページで図書館や他のオンライン書店へとリンクをつけることが出来ます。これは結構便利なんです(興味がある人は「Greasemonkey – Mozilla Firefox まとめサイト」を見てみてください)。

 でも、不満もありました。一つ一つが独立しているために、Amazon側で商品ページを変更されてしまうと、個別にインストールしなければいけなかったのです。これは面倒くさい。また、ASIN(Amazonが商品に割り当てているユニークな番号のこと。書籍だとISBNを割り当てている)を日本の書籍に決めうちしているのも不満点でした。これだと洋書が検索できないではないか!

 というわけで、自分が活用していたGreasemonkeyスクリプトを一つのスクリプトに統合しました。情報はやっぱり集約されていないと、意味がないと思います。結局こんな感じになりました(画像左下に注目!)。

my amazon


// ==UserScript==<br />// @name          Amazon Link Aggregator<br />// @namespace     <br />// @description  Temporary Script.<br />// @include       <a href="http://*.amazon.*" onclick="__gaTracker('send', 'event', 'outbound-article', 'http://*.amazon.*', 'http://*.amazon.*');" target="_blank">http://*.amazon.*</a><br />// ==/UserScript==</p> <p>// HTML文章でなければ、何もせずに終了<br />if(document.contentType != 'text/html') return;</p> <p>// ASINを探す<br />document.body.parentNode.innerHTML.match(/name=\"ASIN\" value=\"([0-9A-Z]{10})([/-_a-zA-Z0-9]*)/i);</p> <p>// ASINを見つけられなければ、何もせずに終了<br />if (RegExp.$1 == '')    return;</p> <p>// 変数asinにASINを代入<br />var asin = RegExp.$1</p> <p>// ISBN13の値を一応計算<br />isbn13 = cvISBN13(asin);</p> <p>// 楽天Booksへのリンク作成<br />var raku_link = document.createElement('a');<br />raku_link.setAttribute('href', '<a href="http://esearch.rakuten.co.jp/rms/sd/esearch/vc?sitem='" onclick="__gaTracker('send', 'event', 'outbound-article', 'http://esearch.rakuten.co.jp/rms/sd/esearch/vc?sitem=\'', 'http://esearch.rakuten.co.jp/rms/sd/esearch/vc?sitem=’');" target="_blank">http://esearch.rakuten.co.jp/rms/sd/esearch/vc?sitem=’</a> + asin + '&sv=30');</p> <p>// 本やタウンへのリンク作成<br />var honya_link = document.createElement('a');<br />honya_link.setAttribute('href', '<a href="http://www.honya-town.co.jp/hst/HTdispatch?free=&free_andor=0&title=&title_andor=0&title_title=1&title_subtitle=1&title_series=1&title_original=1&author=&author_list=0&publisher=&date_yy_from=&date_mm_from=&date_yy_to=&date_mm_to=&vague_search=1&list_kensu=20&stamp_style=0&price_from=&price_to=&isbn_cd='" onclick="__gaTracker('send', 'event', 'outbound-article', 'http://www.honya-town.co.jp/hst/HTdispatch?free=&free_andor=0&title=&title_andor=0&title_title=1&title_subtitle=1&title_series=1&title_original=1&author=&author_list=0&publisher=&date_yy_from=&date_mm_from=&date_yy_to=&date_mm_to=&vague_search=1&list_kensu=20&stamp_style=0&price_from=&price_to=&isbn_cd=\'', 'http://www.honya-town.co.jp/hst/HTdispatch?free=&free_andor=0&title=&title_andor=0&title_title=1&title_subtitle=1&title_series=1&title_original=1&author=&author_list=0&publisher=&date_yy_from=&date_mm_from=&date_yy_to=&date_mm_to=&vague_search=1&list_kensu=20&stamp_style=0&price_from=&price_to=&isbn_cd=’');" target="_blank">http://www.honya-town.co.jp/hst/HTdispatch?free=&free_andor=0&title=&title_andor=0&title_title=1&title_subtitle=1&title_series=1&title_original=1&author=&author_list=0&publisher=&date_yy_from=&date_mm_from=&date_yy_to=&date_mm_to=&vague_search=1&list_kensu=20&stamp_style=0&price_from=&price_to=&isbn_cd=’</a> + asin + '&pub_stat=2&submit.x=78&submit.y=10&nips_cd=');</p> <p>// G-Toolsへのリンク作成<br />var gtools_link = document.createElement('a');<br />gtools_link.setAttribute('href', '<a href="http://www.umizoi.com/g-tools/foward_ecs4.php?view=detail®ion=jp&asin='" onclick="__gaTracker('send', 'event', 'outbound-article', 'http://www.umizoi.com/g-tools/foward_ecs4.php?view=detail®ion=jp&asin=\'', 'http://www.umizoi.com/g-tools/foward_ecs4.php?view=detail&region=jp&asin=’');" target="_blank">http://www.umizoi.com/g-tools/foward_ecs4.php?view=detail&region=jp&asin=’</a> + asin);</p> <p>// Lead2Amazonへのリンク作成<br />var bibtex_link = document.createElement('a');<br />bibtex_link.setAttribute('href', '<a href="http://keijisaito.info/lead2amazon/j/?key='" onclick="__gaTracker('send', 'event', 'outbound-article', 'http://keijisaito.info/lead2amazon/j/?key=\'', 'http://keijisaito.info/lead2amazon/j/?key=’');" target="_blank">http://keijisaito.info/lead2amazon/j/?key=’</a> + asin + '&si=all&op=bt&so=sa&ht=jp');</p> <p>// Yahoo! Booksへのリンク作成<br />var yahoo_link = document.createElement('a');<br />yahoo_link.setAttribute('href', '<a href="http://books.yahoo.co.jp/book_search/isbn?os=1&isbn='" onclick="__gaTracker('send', 'event', 'outbound-article', 'http://books.yahoo.co.jp/book_search/isbn?os=1&isbn=\'', 'http://books.yahoo.co.jp/book_search/isbn?os=1&isbn=’');" target="_blank">http://books.yahoo.co.jp/book_search/isbn?os=1&isbn=’</a> + asin);</p> <p>// BOOK OFFへのリンク作成<br />var bookoff_link = document.createElement('a');<br />bookoff_link.setAttribute('href', '<a href="http://www.bookoffonline.co.jp/display/L001,st=u,q='" onclick="__gaTracker('send', 'event', 'outbound-article', 'http://www.bookoffonline.co.jp/display/L001,st=u,q=\'', 'http://www.bookoffonline.co.jp/display/L001,st=u,q=’');" target="_blank">http://www.bookoffonline.co.jp/display/L001,st=u,q=’</a> + asin);</p> <p>// addallへのリンク作成<br />var addall_link = document.createElement('a');<br />addall_link.setAttribute('href', '<a href="http://used.addall.com/SuperRare/submitRare.cgi?author=&title=&keyword=&isbn='" onclick="__gaTracker('send', 'event', 'outbound-article', 'http://used.addall.com/SuperRare/submitRare.cgi?author=&title=&keyword=&isbn=\'', 'http://used.addall.com/SuperRare/submitRare.cgi?author=&title=&keyword=&isbn=’');" target="_blank">http://used.addall.com/SuperRare/submitRare.cgi?author=&title=&keyword=&isbn=’</a> + asin + '&order=PRICE&ordering=ASC&dispCurr=JPY&binding=Any+Binding&min=&max=&timeout=20&match=Y&store=Abebooks&store=AbebooksDE&store=AbebooksFR&store=AbebooksUK&store=Alibris&store=Amazon&store=AmazonCA&store=AmazonUK&store=AmazonDE&store=AmazonFR&store=Antiqbook&store=Biblio&store=Biblion&store=Bibliophile&store=Bibliopoly&store=Booksandcollectibles&store=Half&store=ILAB&store=LivreRareBook&store=Maremagnum&store=Powells&store=Strandbooks&store=Tomfolio&store=ZVAB');</p> <p>// 表示する情報パネルの設定<br />var GM_infoPanel = document.createElement('div')</p> <p>with(GM_infoPanel.style) {<br />     bottom = 0;<br />     left = 0;<br />     padding = '2px';<br />     opacity = 0.8;<br />     fontsize = 'x-small';<br />     color = '#000000';<br />     backgroundColor = '#EEEEEE';<br />     border = '1px solid #C0C0C0';<br />     <br />     zIndex = 100;<br />     position = 'fixed';<br />}</p> <p>// 実際の表示部分作成<br />GM_infoPanel.innerHTML = 'Link Search<br />[ISBN10(ASIN): ' + asin + ']<br />[ISBN13: ' + isbn13 + ']<br />BibTex Search: <a target="blank" href="./%27%20+%20bibtex_link%20+%20%27">Lead2Amazon</a><br />Blog: <a target="blank" href="./%27%20+%20gtools_link%20+%20%27">G-Tools</a><br />Books (New): <a target="blank" href="./%27%20+%20honya_link%20+%20%27">HonyaTown</a> / <a target="blank" href="./%27%20+%20raku_link%20+%20%27">Rakuten</a> / <a target="blank" href="./%27%20+%20yahoo_link%20+%20%27">Yahoo!</a><br />Books (Used): <a target="blank" href="./%27%20+%20bookoff_link%20+%20%27">BookOff</a> / <a target="blank" href="./%27%20+%20addall_link%20+%20%27">AddAll</a><br />Libraries: <a href="http://www.library.tohoku.ac.jp/opac/expert-query" onclick="__gaTracker('send', 'event', 'outbound-article', 'http://www.library.tohoku.ac.jp/opac/expert-query', 'Tohoku Univ');" target="blank">Tohoku Univ</a> / <a href="http://www.library.pref.miyagi.jp/WoDetail.html" onclick="__gaTracker('send', 'event', 'outbound-article', 'http://www.library.pref.miyagi.jp/WoDetail.html', 'Miyagi Pref');" target="blank">Miyagi Pref</a> / <a href="https://lib-www.smt.city.sendai.jp/licsxp-opac/WOpacTifSchCmpdDispAction.do" onclick="__gaTracker('send', 'event', 'outbound-article', 'https://lib-www.smt.city.sendai.jp/licsxp-opac/WOpacTifSchCmpdDispAction.do', 'Sendai City');" target="blank">Sendai City</a>';</p> <p>// 表示<br />document.body.appendChild(GM_infoPanel);</p> <p>// ISBN10 to ISBN13<br />// 基本的に丸ごとぱくりでやす。。。<br />// Thanks to <a href="http://d.hatena.ne.jp/natu_n/" onclick="__gaTracker('send', 'event', 'outbound-article', 'http://d.hatena.ne.jp/natu_n/', 'http://d.hatena.ne.jp/natu_n/');" target="_blank">http://d.hatena.ne.jp/natu_n/</a></p> <p>function cvISBN13(ISBN){<br />     _odd = 0;<br />     _even = 0;<br />     _bISBN = "978" + String(ISBN).substr(0,9);<br />     for(var i=0;i<11;i+=2){<br />          _odd += Number(_bISBN.substr(i,1));<br />     }<br />     for(var i=1;i<12;i+=2){<br />          _even += Number(_bISBN.substr(i,1<br /> ));<br />     }<br />     _even = _even * 3;<br />     _SUM = String(_odd + _even);<br />     _Mod = Number(_SUM.substr<span class="footnote"><a href="/sirocco634/#f1" name="fn1" title="_SUM.length - 1),1">*1</a></span>;<br />     if (_Mod == 0){<br />          _Mod = "0";<br />     } else {<br />          _Mod = 10 - _Mod;<br />     }<br />     ISBN = Number(_bISBN.substr(0,12) + _Mod);<br />     return ISBN;<br />}<br />

*1:_SUM.length – 1),1