Changeset 6167

Show
Ignore:
Timestamp:
02/04/08 22:28:31 (5 years ago)
Author:
hetappi
Message:

lang/javascript/userscripts/crossbooksearch.user.js: added edogawa city library and livedoor books

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/javascript/userscripts/crossbooksearch.user.js

    r6115 r6167  
    189189                  }, 
    190190                  funcs: { 
    191                       detail: function(html, lib) { 
    192                         return (/dispDetail\((\d+),0,0\)/.test(html) 
    193                           // deprecated: informal format 
    194                           ? { 
    195                             method: 'post', 
    196                             url: catUrl([lib.url, lib.context, 'Sopcsvis.sh']), 
    197                             params: 'hit_cnt=1&idx=1&kgrn=0&ryno=&tso=on&ksno=' + RegExp.$1 
    198                           } 
    199                           : null 
    200                         ); 
    201 //                    detail: function(html, lib) { 
    202 //                      return ( 
    203 //                        /dispDetail\((\d+),0,0\)/.test(html) 
    204 //                          ? catUrl([lib.url, lib.context, 'Sopcsvis.sh?hit_cnt=1&idx=1&kgrn=0&ryno=&tso=on&ksno=']) + RegExp.$1 
    205 //                          : null); 
     191                    detail: function(html, lib) { 
     192                      return ( 
     193                        /dispDetail\((\d+),0,0\)/.test(html) 
     194                          ? catUrl([lib.url, lib.context, 'Sopcsvis.sh?hit_cnt=1&idx=1&kgrn=0&ryno=&tso=on&ksno=']) + RegExp.$1 
     195                          : null); 
    206196                } } } 
    207197              ] 
     
    356346              opts: { 
    357347                overrideMimeType: 'text/html; charset=euc-jp' 
    358           } } } 
     348          } } }, 
    359349//          // 
    360350//          toritsu: { 
     
    393383//          // 
    394384//          katsushika: {}, 
    395 /*          // 
     385          // todo: kakowarui node dounika suru 
    396386          edogawa: { 
    397387            name: "江戸川", 
     
    406396                  req_uri: "opsearch_list_i.cgi", 
    407397                  content: "dsmax=500&dsppp=50&errcode=0&item5lg=AND&limterm=0&search=on&search=on&stdtl=1&stlst=1&stype=1&tandoku_isbn=$isbn&trgt=7", 
     398                  funcs: { 
     399                    detail: function(html, lib) { 
     400                      return ( 
     401                        /set_val\('\/www\/lib-bin\/opdtl_book_i\.cgi',\s+'1',\s+'1',\s+'1',\s+'(\d+)'\)/.test(html) 
     402                          // deprecated: informal format 
     403                          ? { method: "post", 
     404                              url: catUrl([lib.url, lib.context, "opdtl_book_i.cgi"]), 
     405                              params: 
     406                                "bidcod=" + RegExp.$1 + "&dsmax=500&dsppp=50&dsptn=3&dtcls=00&item1=1&item1lg=AND&item1mt=1&item2=2&item2lg=AND&item2mt=1&item3=3&" + 
     407                                "item3lg=AND&item3mt=1&item4=4&item4lg=AND&item4mt=1&item5=6&item5lg=AND&item5mt=1&kndcd=1&limterm=0&" + 
     408                                "schlistcgi=/www/lib-bin/opsearch_list_i.cgi&search[0]=on&search[1]=on&stdtl=1&stlst=1&stype=1&tandoku_isbn=$isbn&temp5lg=AND&" + 
     409                                "temp_isbn=$isbn&trgt=3&voldtl=1&vollst=1&volpp=50" 
     410                            } 
     411                          : null 
     412                      ); 
     413                  } }, 
    408414                  regexps: { 
    409                     // /<a href="javascript:hide_form\([^"]+'(\d{9})'/ 
    410                     // javascript:setYear();hide_form();set_val('/www/lib-bin/opsearch_list_i.cgi'); 
     415                    owned: /opdtl_book_i\.cgi/, 
     416                    bidcod: /set_val\('\/www\/lib-bin\/opdtl_book_i\.cgi',\s+'1',\s+'1',\s+'1',\s+'(\d+)'\)/ 
    411417                } }, 
    412418                { method: "post", 
    413419                  req_uri: "opdtl_book_i.cgi", 
    414                   content: "bidcod=&dsmax=500&dsppp=50&dsptn=3&dtcls=00&item1=1&item1lg=AND&item1mt=1&item2=2&item2lg=AND&item2mt=1&item3=3&item3lg=AND&item3mt=1&item4=4&item4lg=AND&item4mt=1&item5=6&item5lg=AND&item5mt=1&kndcd=1&limterm=0&schlistcgi=/www/lib-bin/opsearch_list_i.cgi&search[0]=on&search[1]=on&stdtl=1&stlst=1&stype=1&tandoku_isbn=$isbn&temp5lg=AND&temp_isbn=$isbn&trgt=3&voldtl=1&vollst=1&volpp=50", 
     420                  content: 
     421                    "bidcod=$bidcod&dsmax=500&dsppp=50&dsptn=3&dtcls=00&item1=1&item1lg=AND&item1mt=1&item2=2&item2lg=AND&item2mt=1&item3=3&" + 
     422                    "item3lg=AND&item3mt=1&item4=4&item4lg=AND&item4mt=1&item5=6&item5lg=AND&item5mt=1&kndcd=1&limterm=0&" + 
     423                    "schlistcgi=/www/lib-bin/opsearch_list_i.cgi&search[0]=on&search[1]=on&stdtl=1&stlst=1&stype=1&tandoku_isbn=$isbn&temp5lg=AND&" + 
     424                    "temp_isbn=$isbn&trgt=3&voldtl=1&vollst=1&volpp=50", 
    415425                  regexps: { 
    416                     enabled: /<th>\u5728\u3000\u5EAB<\/th>/ 
     426                    enabled: /<TH>\u5728\u3000\u5EAB<\/TH>/ 
    417427                } } 
    418               ] 
    419           } }, 
    420 */ 
     428              ], 
     429              opts: { 
     430                overrideMimeType: 'text/html; charset=shift_jis' 
     431          } } } 
    421432//          // 
    422433//          sumida: {}, 
     
    509520                    detail: /<link>(http:\/\/www\.bookoffonline\.co\.jp\/display\/.+)<\/link>/, 
    510521                    owned: /<link>http:\/\/www\.bookoffonline\.co\.jp\/display\/.+<\/link>/, 
    511                     price: /<li>\u4e2d\u53e4\u8ca9\u58f2\u4fa1\u683c\uff1a(.+)<\/li>/ 
     522                    price: /<li>\u4e2d\u53e4\u8ca9\u58f2\u4fa1\u683c\uff1a\uffe5(.+)<\/li>/ 
    512523                } }, 
    513524                { method: 'get', 
    514525                  regexps: { 
    515526                    enabled: /<div\sid="buyframe_old">/ 
    516           } } ] } } 
     527          } } ] } }, 
    517528//          ebookoff: {}, 
    518529//          ubook: {}, 
    519 //          livedorbooks: {} 
     530          livedorbooks: { 
     531            name: 'ライブドアブックス', 
     532            keys: { isbn13: true }, 
     533            enc: 'euc-jp', 
     534            url: 'http://books.livedoor.com', 
     535            context: '', 
     536            func: general, 
     537            args: { 
     538              reqs: [ 
     539                { method: 'get', 
     540                  req_uri: 'search/gci/?used=1&word=' + '$isbn', 
     541                  regexps: { 
     542                    owned: /中古価格/, 
     543                    enabled: /中古価格/, 
     544                    detail: /<dt><a\s+href="(http:\/\/books\.livedoor\.com\/item\d+\.html)">/, 
     545                    price: /中古価格:<span>([\d,]+)円/ 
     546          } } ] } } 
    520547      } } 
    521548    } 
     
    787814          var txt = r.name; 
    788815          if (r.price) 
    789             txt += '(' + r.price + ')'; 
     816            txt += '(' + r.price + ')'; 
    790817          if (typeof r.detail == 'string') { 
    791818            var link = document.createElement('a'); 
     
    863890  } 
    864891 
    865   // toriaezu isbn dake 
    866   function replaceKeys(url, keys, book) { 
    867     return url.replace('$isbn', getIsbn(keys, book)); 
     892  // todo: refactoring 
     893  function replaceKeys(s, keys, vals) { 
     894    while (/=\$(\w+)/g.test(s)) { 
     895      s = s.replace( 
     896        '$' + RegExp.$1, 
     897        (function(key, obj) { 
     898          var v; 
     899          if (obj instanceof Array) { 
     900            for (var i = 0, m = obj.length; i < m; ++i) { 
     901              if (v = getValue(keys, key, obj[i])) 
     902                return v; 
     903            } 
     904            return ''; 
     905          } else { 
     906            return (v = getValue(keys, key, obj)) ? v : ''; 
     907          } 
     908          function getValue(keys, key, obj) { 
     909            return key == 'isbn' ? getIsbn(keys, obj) : obj[key]; 
     910          } 
     911        })(RegExp.$1, vals)); 
     912    } 
     913    return s; 
    868914  } 
    869915 
     
    10151061    } 
    10161062    var idx = 0; 
    1017     var url = catUrl([lib.url, lib.context ? lib.context : '']); 
     1063    var url = catUrl([lib.url, lib.context ? lib.context : '.']); 
    10181064    send(catUrl([url, replaceKeys(lib.args.reqs[0].req_uri, lib.keys, book)])); 
    10191065 
     
    10261072          lib.args.opts && lib.args.opts.overrideMimeType 
    10271073            ? lib.args.opts.overrideMimeType : null, 
    1028         url: url, 
     1074        url: 
     1075          url.indexOf('http:') == 0 || url.indexOf('https:') == 0 
     1076            ? url : catUrl([lib.url, lib.context ? lib.context : '.', url]), 
    10291077        data: 
    10301078          lib.args.reqs[idx].method == 'post' 
    1031             ? replaceKeys(lib.args.reqs[idx].content, lib.keys, book) : null, 
     1079            ? replaceKeys(lib.args.reqs[idx].content, lib.keys, [book, result]) : null, 
    10321080        headers: 
    10331081          lib.args.reqs[idx].method == 'post'