Changeset 5971
- Timestamp:
- 02/01/08 00:40:50 (5 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
lang/javascript/userscripts/crossbooksearch.user.js
r5963 r5971 25 25 // @include http://books.yahoo.co.jp/book_detail/* 26 26 // @include http://www.asahiya.com/book_search/book_search_BookDetail.asp 27 // @include http://lib.city.shinagawa.tokyo.jp/cgi-bin/Sopcsvis.sh 27 28 // ==/UserScript== 28 29 … … 127 128 xpaths: { 128 129 isbn10: '//table[@class="BookDetails"]//tr[contains(th/text(), "ISBN")]/td[string-length(text())=10]/text()' 130 } }, 131 { url: "^http://lib\\.city\\.shinagawa\\.tokyo\\.jp/cgi-bin/Sopcsvis\\.sh", 132 xpaths: { 133 isbn10: 'translate(//tr[contains(td, "ISBN")]/td[3], "-", "")' 129 134 } } 130 135 ]; … … 184 189 }, 185 190 funcs: { 186 detail: function(html, lib) { 187 return ( 188 /dispDetail\((\d+),0,0\)/.test(html) 189 ? catUrl([lib.url, lib.context, 'Sopcsvis.sh?hit_cnt=1&idx=1&kgrn=0&ryno=&tso=on&ksno=']) + RegExp.$1 190 : null); 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 206 } } } 192 207 ] … … 532 547 cursor: move; 533 548 } 549 div.cbs_link_enabled { 550 display:inline; 551 cursor: pointer; 552 text-decoration: underline; 553 font-size: 12px; 554 color: blue; 555 } 556 div.cbs_link_enabled:hover { 557 text-decoration: underline; 558 } 559 div.cbs_link_notenabled { 560 display:inline; 561 cursor: pointer; 562 text-decoration: underline; 563 font-size: 12px; 564 color: gray; 565 } 566 div.cbs_link_notenabled:hover { 567 text-decoration: underline; 568 } 534 569 ]]></css>; 535 570 … … 683 718 targets = eval(targets); 684 719 var names = keys(targets); 685 720 var resps = {}; 686 721 next(); 687 722 688 723 function response(resp) { 689 724 GM_log(arguments.callee.name); 690 GM_log(resp.name + ', ' + resp.owned + ', ' + resp.enabled + ', ' + resp.detail); 725 GM_log( 726 resp.name + ', ' + resp.owned + ', ' + resp.enabled + ', ' + 727 (typeof resp.detail == 'string' ? resp.detail : uneval(resp.detail))); 691 728 692 729 var unit = document.createElement('div'); 693 730 unit.className = 'cbs_unit'; 694 731 695 if (resp.owned) { 696 var txt = resp.name; 697 if (resp.price) 698 txt += '(' + resp.price + ')'; 699 var link = document.createElement('a'); 700 link.className = resp.enabled ? 'cbs_enabled' : 'cbs_notenabled'; 701 link.href = resp.detail; 702 link.appendChild(document.createTextNode(txt)); 703 unit.appendChild(link); 704 } else { 705 unit.appendChild(document.createTextNode(resp.name)); 706 } 732 var link = (function(r) { 733 if (r.owned) { 734 var txt = r.name; 735 if (r.price) 736 txt += '(' + r.price + ')'; 737 if (typeof r.detail == 'string') { 738 var link = document.createElement('a'); 739 link.className = r.enabled ? 'cbs_enabled' : 'cbs_notenabled'; 740 link.href = r.detail; 741 link.appendChild(document.createTextNode(txt)); 742 return link; 743 } else { 744 var link = document.createElement('div'); 745 link.className = r.enabled ? 'cbs_link_enabled' : 'cbs_link_notenabled'; 746 link.id = resp.key; 747 link.appendChild(document.createTextNode(txt)); 748 link.addEventListener('click', function(e) { 749 request(resps[e.currentTarget.id].detail); 750 }, false); 751 return link; 752 } 753 } else { 754 return document.createTextNode(r.name); 755 } 756 })(resp); 757 758 unit.appendChild(link); 707 759 bar.lastChild.appendChild(unit); 760 761 resps[resp.key] = resp; 708 762 next(); 709 763 } … … 721 775 var cs = name.split('.'); 722 776 var target = LIBINFO[cs[0]][cs[1]].targets[cs[2]]; 723 GM_log(target.name);777 target.key = name; 724 778 725 779 target.func(book, target, response); … … 731 785 var ks = []; 732 786 for (var key in obj) { 733 GM_log('key: ' + key);734 787 ks.push(key); 735 } 736 GM_log('ks.length: ' + ks.length); 788 } 737 789 return ks; 738 790 } … … 771 823 } 772 824 825 function request(req) { 826 var form = document.createElement('form'); 827 form.id = 'cbs_form'; 828 form.method = req.method || 'get'; 829 form.action = req.url; 830 form.target = '_blank'; 831 832 if (req.params) { 833 for (var pairs = req.params.split('&'), i = 0, m = pairs.length; i < m; ++i) { 834 var pair = pairs[i].split('='); 835 var input = document.createElement('input'); 836 input.type = 'hidden'; 837 input.name = pair[0]; 838 input.value = pair.length > 1 ? pair[1] : ''; 839 form.appendChild(input); 840 } 841 } 842 843 document.body.appendChild(form); 844 form.submit(); 845 document.body.removeChild(form); 846 } 847 773 848 // patternA 774 849 // chuo, nerima, arakawa, setagaya, toshima … … 777 852 GM_log(lib.name); 778 853 779 var result = { name: lib.name };854 var result = { key: lib.key, name: lib.name }; 780 855 var isbn = getIsbn(lib.keys, book); 781 856 if (!isbn) { … … 833 908 GM_log(lib.name); 834 909 835 var result = { name: lib.name };910 var result = { key: lib.key, name: lib.name }; 836 911 var isbn = getIsbn(lib.keys, book); 837 912 if (!isbn) { … … 880 955 GM_log(lib.name); 881 956 882 var result = { name: lib.name };957 var result = { key: lib.key, name: lib.name }; 883 958 var isbn = getIsbn(lib.keys, book); 884 959 if (!isbn) {
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)