Changeset 6167
- Timestamp:
- 02/04/08 22:28:31 (5 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
lang/javascript/userscripts/crossbooksearch.user.js
r6115 r6167 189 189 }, 190 190 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); 206 196 } } } 207 197 ] … … 356 346 opts: { 357 347 overrideMimeType: 'text/html; charset=euc-jp' 358 } } } 348 } } }, 359 349 // // 360 350 // toritsu: { … … 393 383 // // 394 384 // katsushika: {}, 395 /* // 385 // todo: kakowarui node dounika suru 396 386 edogawa: { 397 387 name: "江戸川", … … 406 396 req_uri: "opsearch_list_i.cgi", 407 397 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 } }, 408 414 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+)'\)/ 411 417 } }, 412 418 { method: "post", 413 419 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", 415 425 regexps: { 416 enabled: /< th>\u5728\u3000\u5EAB<\/th>/426 enabled: /<TH>\u5728\u3000\u5EAB<\/TH>/ 417 427 } } 418 ] 419 } }, 420 */ 428 ], 429 opts: { 430 overrideMimeType: 'text/html; charset=shift_jis' 431 } } } 421 432 // // 422 433 // sumida: {}, … … 509 520 detail: /<link>(http:\/\/www\.bookoffonline\.co\.jp\/display\/.+)<\/link>/, 510 521 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>/ 512 523 } }, 513 524 { method: 'get', 514 525 regexps: { 515 526 enabled: /<div\sid="buyframe_old">/ 516 } } ] } } 527 } } ] } }, 517 528 // ebookoff: {}, 518 529 // 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 } } ] } } 520 547 } } 521 548 } … … 787 814 var txt = r.name; 788 815 if (r.price) 789 txt += '( ' + r.price + ')';816 txt += '(¥' + r.price + ')'; 790 817 if (typeof r.detail == 'string') { 791 818 var link = document.createElement('a'); … … 863 890 } 864 891 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; 868 914 } 869 915 … … 1015 1061 } 1016 1062 var idx = 0; 1017 var url = catUrl([lib.url, lib.context ? lib.context : ' ']);1063 var url = catUrl([lib.url, lib.context ? lib.context : '.']); 1018 1064 send(catUrl([url, replaceKeys(lib.args.reqs[0].req_uri, lib.keys, book)])); 1019 1065 … … 1026 1072 lib.args.opts && lib.args.opts.overrideMimeType 1027 1073 ? 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]), 1029 1077 data: 1030 1078 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, 1032 1080 headers: 1033 1081 lib.args.reqs[idx].method == 'post'
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)