play:gameからamazon.deへジャンプ(ボードゲームを日本語で検索できるbookmarklet)

  • /*
     * @title        play:gameからamazon.deへジャンプ(ボードゲームを日本語で検索できるbookmarklet)
     * @description  play:game(www.gamers-jp.com/playgame/)で実行するとドイツAmazon(amazon.de)へジャンプ
     * @description  それ以外のサイトで実行した場合はplay:gameへジャンプします
     * @include      http://*
     * @require      http://let.hatelabo.jp/Koonies/let/gYC-xJrjgYrCYg.packed.js
     */
    
    function getTitle(){
      var xpath='//table[@class="jHeaderWhite"]/tbody/tr[2]/td';
      var ele=document.evaluate(xpath,document,null,7,null).snapshotItem(0);
      return !!ele.textContent?ele.textContent:ele.innerText;
    }
    if (location.href.match(/http:\/\/www\.gamers-jp\.com\/playgame\/db_.+\?game_id=.+/))
    {
      location.href='http://www.amazon.de/gp/search/ref=sr_nr_p_6_3?rh=n:12950651,k:'+encodeURIComponent(getTitle())+',p_6:A3JWKAKR8XB7XF&bbn=12950651&ie=UTF8&rnid=367784011&tag=koonies-21';
    }
    else if (location.href.match(/http:\/\/www\.gamers-jp\.com\/playgame\/db_searchlist\.php\?.+/))
    {
      alert("リストから選択した後で再度実行してください");
    }
    else
    {
      var word=(!!window.getSelection)?window.getSelection().toString():document.selection.createRange().text;
      if(!word)if(frames.length)for(var i=0;i<frames.length;i++)if(((!!frames[i].getSelection)||(!!frames[i].document))&&(word=(!!frames[i].getSelection)?frames[i].getSelection().toString():frames[i].document.selection.createRange().text))break;
      if(word.length==0)word=prompt("検索キーワードを入力 (例.カルカソンヌ)\n\n※ジャンプ後個別ページで再実行のこと!","");
      if(word!=null)location.href='http://www.gamers-jp.com/playgame/db_searchlist.php?mode=1&order=1&search_str='+encodeURIComponent(word);
    }
  • Permalink
    このページへの個別リンクです。
    RAW
    書かれたコードへの直接のリンクです。
    Packed
    文字列が圧縮された書かれたコードへのリンクです。
    Userscript
    Greasemonkey 等で利用する場合の .user.js へのリンクです。
    Loader
    @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
    Metadata
    コード中にコメントで @xxx と書かれたメタデータの JSON です。

History

  1. 2011/08/30 22:05:11 - 2011-08-30
  2. 2011/06/28 21:29:27 - 2011-06-28
  3. 2010/09/02 01:54:53 - 2010-09-02
  4. 2010/09/02 01:44:35 - 2010-09-02