标题: 80元求网页脚本 [打印本页]
作者: lxh623 时间: 2019-9-11 09:54 标题: 80元求网页脚本
本帖最后由 lxh623 于 2019-9-14 17:58 编辑
游览器有个插件tampermonkey,可以加载脚本。现有脚本“读秀超星电子书获取插件”等等。脚本网站是https://greasyfork.org/zh-CN/scripts?q=掌阅,可以搜索、安装。
我想有个脚本可以在读秀搜索结果页面加入添加书籍在豆瓣的评分,链接。每页结果那里可能十本或者五十本书。比如,豆瓣 9.0 。前面两个字“豆瓣”带有该图书的豆瓣链接。
对于电脑专业的也许不难吧。
谢谢!
作者: Batcher 时间: 2019-9-11 10:02
现有脚本是用什么语言写的?发出来看看
作者: lxh623 时间: 2019-9-11 10:42
深圳图书馆图书信息豆瓣脚本,这个失效了。- // ==UserScript==
- // @name douban_shenzhenLib
- // @name:zh-CN 深圳图书馆图书信息豆瓣脚本
- // @namespace http://www.douban.com/note/180166013/
- // @description Show book available info in douban book page, show book's douban score in Shenzhen Library book page
- // @description:zh-cn 为豆瓣书籍页面(book.douban.com)添加书籍在深圳图书馆的信息,预借链接,为深圳图书馆书籍信息页面添加书籍在豆瓣的评分,链接
- // @license MIT License
- // @supportURL http://www.douban.com/note/180166013/
- // @version 1.24.10
- // @require http://code.jquery.com/jquery-1.4.4.min.js
- // @include http://book.douban.com/*
- // @include https://book.douban.com/*
- // @include https://www.douban.com/doulist/*
- // @include https://www.szlib.org.cn/Search/searchdetail.jsp*
- // @include https://www.szlib.org.cn/Search/searchshow.jsp*
- // @include http://opac.nslib.cn/Search/searchdetail.jsp*
- // @include http://opac.nslib.cn/Search/searchshow.jsp*
- // @include https://www.szln.gov.cn/Search/searchdetail.jsp*
- // @include https://www.szln.gov.cn/Search/searchshow.jsp*
- // @include http://218.17.147.50/Search/searchdetail.jsp*
- // @include http://218.17.147.50/Search/searchshow.jsp*
- // @grant GM_addStyle
- // @grant GM_xmlhttpRequest
- // @grant GM_registerMenuCommand
- // @grant GM_getValue
- // @grant GM_setValue
- // @author morningSky
- // @refer books_recommend_THU, bean vine (49911) and others...
- // @updateDate 2019-03-25
- /* @reason
- 1. 深圳图书馆查询url变更, sortfield=ptitle
- 2. 减少加载时间:缓存图书的索书号,是否有多本,可预借,可快递。在馆信息还是需要查询图书馆网站
- 3. 豆瓣api只对企业开放,个人用户不提供key,修改为在html中解析isbn10
-
- Firefox Greasemonkey v4.0及之后版本修改了API,这个脚本失效了;请用tampermonkey插件,需要再次安装这个脚本。
- 争取找时间修改脚本,使其适用于新版的Greasemonkey插件————可能tampermonkey插件后续也会修改API,导致脚本失效。
- @end*/
- //
- // ==/UserScript==
-
- /*
- * opac.nslib.cn 南山,szln.gov.cn 盐田,218.17.147.50 龙岗
- */
-
- var fDebug = false;
- var title, isbn, isbn10;
-
- var SZLIB_HOST = 'https://www.szlib.org.cn/';
- var LIBOPAC_URL = SZLIB_HOST + 'Search/searchshow.jsp?v_tablearray=bibliosm,serbibm,apabibibm,mmbibm,&v_book=on&sortfield=ptitle&sorttype=desc&pageNum=10';
-
- // 查询索书号
- var LIBOPAC_URL_CALLNO = SZLIB_HOST + 'Search/getpreholding.jsp?v_curtable=bibliosm&v_recno=';
- var LIBBOOK_URL = SZLIB_HOST + 'Search/searchdetail.jsp?v_tablearray=bibliosm&v_curtable=bibliosm&site=null&v_recno=';
- var LIBQRYRESERVABLE_URL = SZLIB_HOST + 'Search/getpreLoan.jsp?';
- var LIBRESERVE_URL = SZLIB_HOST + 'MyLibrary/Reader-Access.jsp?destPage=ReserveSubmit.jsp&v_tablearray=bibliosm&v_TableName=80000002&v_recno=';
- var LIB_EXPRESS_URL = SZLIB_HOST + 'MyLibrary/Reader-Access.jsp?destPage=/Search/searchshow.jsp?v_index=isbn&v_tablearray=bibliosm,&sorttype=desc&sortfield=ptitle&v_value=';
-
- var HTML_LOADING = '<font color="grey">正在查询图书馆馆藏情况 · · · · · · </font>';
- var LIBSEARCH_LINK_PRE = '<a title="点击前往图书馆搜索" target="_blank" ';
- var LIBSEARCH_LINK_SUF = '在深圳图书馆搜索</a>';
-
-
- //if(typeof isChromeExtension == 'undefined'){
- // init();
- //}else{
- // function onReadyGM(){
- // init();
- // };
- //};
-
-
-
- // main body of the script
-
- function isEmptyStr(vStr) {
- return vStr == null || vStr.length == 0 || /^\s*$/.test(vStr);
- }
-
- function getLibIsbnUrl(vIsbn) {
- return LIBOPAC_URL + '&v_index=isbn&v_value=' + vIsbn;
- }
-
- function getLibTitleUrl(vTitle) {
- return LIBOPAC_URL + '&v_index=title&v_value=' + encodeURIComponent(vTitle);
- }
-
- function getDoubanSearchUrl(keyword) {
- return 'http://book.douban.com/subject_search?cat=1001&cat=&search_text=' + encodeURIComponent(keyword);
- }
-
- function getDoubanSearchLink(keyword) {
- return '<a target="_blank" href="' + getDoubanSearchUrl(keyword) + '" title="点击前往豆瓣查询这本书">在豆瓣搜索</a>';
- }
-
- function getLibHeadHtml() {
- var htmlStr = '<ul>';
- // http://www.szln.gov.cn/lib/library.do
- /*htmlStr += '<li><a style="float:right" target="_blank" href="http://www.szlib.gov.cn">深圳图书馆</a></li>';*/
- //<span class="membArrow"> </span>
- htmlStr += '<li><div class="libMem">';
- htmlStr += '<a class="libMemLink" href="#more" >成员馆</a>';
- htmlStr += '<ul class="libMemMenu">';
- htmlStr += '<li><a href="http://www.szlib.org.cn" target="_blank" title="深圳图书馆">深圳图书馆</a></li>';
- htmlStr += '<li><a href="http://www.szclib.org.cn/" target="_blank" title="深圳少年儿童图书馆">少年儿童图书馆</a></li>';
- htmlStr += '<li><a href="http://lib.utsz.edu.cn/" target="_blank" title="深圳市科技图书馆">科技图书馆</a></li>';
- htmlStr += '<li><a href="http://www.szlhlib.com.cn/" target="_blank" title="深圳市罗湖区图书馆">罗湖区图书馆</a></li>';
- htmlStr += '<li><a href="http://www.szftlib.com.cn/" target="_blank" title="深圳市福田区图书馆">福田区图书馆</a></li>';
- htmlStr += '<li><a href="http://www.sznslib.com.cn" target="_blank" title="深圳市南山区图书馆">南山区图书馆</a></li>';
- htmlStr += '<li><a href="http://www.szytlib.cn/" target="_blank" title="深圳市盐田区图书馆">盐田区图书馆</a></li>';
- htmlStr += '<li><a href="http://www.balib.com.cn" target="_blank" title="深圳市宝安区图书馆">宝安区图书馆</a></li>';
- htmlStr += '<li><a href="http://www.szlglib.com.cn/" target="_blank" title="深圳市龙岗图书馆">龙岗图书馆</a></li>';
- htmlStr += '</ul></div></li>';
- htmlStr += '<li><h2>在深圳图书馆借阅 · · · · · · </h2></li>';
- htmlStr += '</ul>';
-
- return htmlStr;
- }
-
- function setLibMemberStyle() {
- GM_addStyle('\
- #libInfo {\
- overflow: visible;\
- }\
- .libMem {\
- z-index: 97;\
- position: relative;\
- float: right;\
- }\
- .libMemMenu {\
- position: absolute;\
- top: -5px;\
- left: 0px;\
- visibility: hidden;\
- }\
- .libMem a {\
- -moz-border-radius: 7px;\
- -webkit-border-radius: 7px;\
- border-radius: 7px;\
- display: block;\
- background: #f6f6f1;\
- padding: 5px;\
- width: 90px;\
- line-height: 160%;\
- border: 1px solid #fff;\
- }\
- .libMem a:hover {\
- background: #FFF;\
- border: 1px solid #aaa;\
- color: #000;\
- }\
- .libMem:hover .libMemMenu {\
- visibility: visible;\
- }\
- .libMem .libMemLink {\
- border: 1px solid #aaa;\
- line-height: 100%;\
- width: 90px;\
- }\
- ');
- }
-
- // getpreLoan.jsp?tableList=bibliosm,bibliosm,bibliosm,&metaidList=934991,1209378,698561,
- function getReservableQryUrl(bookRecNos) {
- var qryParam = 'tableList=';
- for (var i = 0; i < bookRecNos.length; i++) {
- qryParam += 'bibliosm,';
- }
- // array.toString: arr[0],arr[1],...
- qryParam += '&metaidList=' + bookRecNos + ',';
- if (fDebug) console.log('Reservable qryUrl: ' + LIBQRYRESERVABLE_URL + qryParam);
- return LIBQRYRESERVABLE_URL + qryParam;
- }
-
- /*
- * Append the book link, search link, preserve link, call no with location info
- *
- * @param bookRecNos is an Array
- * The reservable query return a xml:
- * <root><preloan no='0'>true</preloan><preloan no='1'>false</preloan></root>
- */
- function appendLibBookInfo(bookRecNos) {
- if (bookRecNos == null || bookRecNos.length == 0)
- return ;
-
- var fMore = (bookRecNos.length > 1);
- var bookRecNo = bookRecNos[0];// set the first book as default
- var reservableQry_url = getReservableQryUrl(bookRecNos);
-
- GM_xmlhttpRequest({
- method: 'GET',
- url: reservableQry_url,
- headers: {
- 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
- "Accept": "text/xml"
- },
- onload: function(res) {
- // the reservable query return is a xml document
- var fHasReservable = false;
-
- if (fDebug) console.log('preloan xml: ' + res.responseText);
- var xmldata = new DOMParser().parseFromString(res.responseText, "text/xml");
-
- if (fDebug) console.log('preloan xml: ' + xmldata);
- var preloans = xmldata.getElementsByTagName('preloan');
- for (var i = 0; i < preloans.length;i++) {
- if (fDebug) console.log('preloan : ' + i + ', ' + preloans[i].childNodes[0].nodeValue);
- if (preloans[i].childNodes[0].nodeValue == 'true') {
- bookRecNo = bookRecNos[i];
- fHasReservable = true;
- break;
- }
- }
-
- var fHasExpress = false;
- var exps = xmldata.getElementsByTagName('express');
- for (var j = 0; j < exps.length; j++) {
- if (exps[j].childNodes[0].nodeValue == 'true') {
- fHasExpress = true;
- break;
- }
- }
-
- var cacheInfo = '{"bookRecNo":"' + bookRecNo + '", "hasMore":"'+ fMore + '", "reservable":"' + fHasReservable + '", "expressable":"' + fHasExpress + '"}';
- GM_setValue(isbn, cacheInfo);
- appendLibBookHtml(bookRecNo, fMore, fHasReservable, fHasExpress);
-
- } // end function(res)
- }
- );
-
- } // end appendLibBookInfo
-
- function appendLibBookHtml(bookRecNo, fMore, fHasReservable, fHasExpress) {
- if (fDebug) console.log('book recNo: ' + bookRecNo + ', fHasReservable: ' + fHasReservable + ', fHasExpress:' + fHasExpress);
-
- var book_url = LIBBOOK_URL + bookRecNo;
- var htmlStr = '';
- htmlStr += '<ul id="libLinks" class="bs" >';//<div class="indent">
- htmlStr += '<li style="border:none"><a id=libBookLink href="' + book_url;
- //title="点击前往图书馆查看"
- htmlStr += '" target="_blank" >到深圳图书馆查看本书</a>';
- if (fMore) {
- htmlStr += '<a class="rr" href="' + getLibIsbnUrl(isbn);
- htmlStr += '" target="_blank" title="查看所有搜索结果">更多. . .</a>';
- }
- htmlStr += '</li>';
- if (fHasReservable || fHasExpress) {
- htmlStr += '<li style="border:none">';
- if (fHasReservable) {
- htmlStr += '<a class="collect_btn colbutt ll" href="';
- htmlStr += LIBRESERVE_URL + bookRecNo;
- htmlStr += '" target="_blank" title="登陆我的图书馆办理预借登记"><span >预借登记</span></a>';
- }
- if (fHasExpress) {
- htmlStr += (fHasReservable ? ' ' : '');
- htmlStr += '<a class="collect_btn colbutt ll" href="';
- htmlStr += LIB_EXPRESS_URL + isbn;
- htmlStr += '" target="_blank" title="登陆我的图书馆办理快递到家"><span >快递到家</span></a>';
- }
- htmlStr += '</li>';
- }
-
- htmlStr += '</ul>'; //</div></div>
- $("#libInfo").html(htmlStr);
-
- appendBookCallNumbers(bookRecNo);
- }
-
-
- /**
- * 解析索书号没有使用xml解析,使用正则表达式解析
- *
- * 添加索书号,位置信息,查询url返回html字符串,每个馆藏一个div,结构如下
- * <div class='tab_2_title'><a title='深圳图书馆 (1)'>深圳图书馆 (1)</a>...</div>
- * <div class="tab_2_show">
- * <div class="tab_2_text">
- * <h3 class='title'>可外借馆藏</h3>
- * <table >
- * <thead><tr><td>条码号</td><td>索书号</td><td>所在地点</td></tr></thead>
- * <tbody>
- * <tr><td>04400511016054</td><td>K825.4/1023</td><td>深图中文图书借阅区(3楼)</td></tr>
- * ...
- * </tbody>
- * </table>
- * <h3 class='title'>可阅览馆藏</h3>
- * <table >...</table>
- * </div>
- * ...
- * </div>
- *
- * 条码号可能是字母开头
- * <tr><td>F4401001057643</td><td>K825.1=72/6</td><td>大学城中文图书</td></tr>
- */
- function appendBookCallNumbers(bookRecNo) {
- if (bookRecNo == -1)
- return ;
-
- var qryCallNoUrl = LIBOPAC_URL_CALLNO + bookRecNo;
- if (fDebug) console.log('qryCallNoUrl: ' + qryCallNoUrl);
-
- GM_xmlhttpRequest({
- method: 'GET',
- url: qryCallNoUrl,
- headers: {
- 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey'
- },
- onload: function(res) {
- if (fDebug) console.log('res: ' + res.responseText);
- var respTxt = res.responseText;
- // extract the 图书馆分馆名称
- var locs = null;
- var libLocs = null;
- try
- {
- locs = respTxt.match(/\s+title=["']?.*?["']/igm);
- if (fDebug) console.log('locs: ' + locs + ', len: ' + locs.length);
- libLocs = respTxt.match(/<div\sclass=["']?tab_2_text["']?.*?<\/div>/igm);
- if (fDebug) console.log('libLocs: ' + libLocs + ', len: ' + libLocs.length);
- } catch (ex) {
- console.log('book callNo parse has exception, ' + ex.message);
- }
-
- var htmlStr = getBookCallNumberHtml(locs, libLocs);
- if (fDebug) console.log('call No html: ' + htmlStr);
-
- if (!isEmptyStr(htmlStr))
- $("#libInfo").append(htmlStr);
- } // end function(res)
- });
-
- } // end appendBookCallNumber
-
- function getBookCallNumberHtml(locs, libLocs) {
- if (locs == null || libLocs == null)
- return '<div class="indent"></div>';
-
- var htmlStr = '';
- htmlStr += '<div class="indent"><table width="100%" title="部分在馆书籍">';
- htmlStr += '<thead><tr style="border-bottom:1px solid #CCC;">'
- + '<td width=30%> 索 书 号</td><td width=70%>馆藏地点</td>'
- + '</tr></thead><tbody>';
- for (var i = 0; i < libLocs.length; i++) {
- // extract Name, remove the first '
- var subLibName = locs[i].match(/["'].*?\s/ig)[0].substr(1).trim();
- if (fDebug) console.log('subLib: ' + subLibName);
- // extract the 索书号信息行
- var shelfLocs = libLocs[i].match(/<tr><td>.*?<\/td><\/tr>/igm);
- //libLocs[i].match(/<tr><td>[0-9]+.*?<\/td><\/tr>/igm);
-
- if (fDebug) console.log('shelfLocs: ' + shelfLocs + ', len: ' + shelfLocs.length);
- var callNoArr = new Array();
- for (var j = 0; j < shelfLocs.length; j++) {
- // extract the 索书号, 馆内位置
- try{
- var shelfLocArr = shelfLocs[j].match(/<td>.*?<\/td>/igm);
- var callNoStr = shelfLocArr[1];
- var shelfLocStr = shelfLocArr[2];
- // 4 = "<td>".length, 5 = "</td>".length
- callNoStr = callNoStr.substring(4, callNoStr.length-5);
- shelfLocStr = shelfLocStr.substring(4, shelfLocStr.length-5).trim();
- if (fDebug) console.log('callNo : ' + callNoStr + ', loc: ' + shelfLocStr);
-
- // 索 书 号+馆藏地点 相同的不重复显示
- if (callNoArr.indexOf(callNoStr + shelfLocStr) == -1) {
- callNoArr.push(callNoStr + shelfLocStr);
-
- htmlStr += '<tr style="border-bottom:1px dashed #DDDDDD;"><td>' + callNoStr + '</td><td>';
- htmlStr += shelfLocStr + '</td></tr>';
- }
- } catch(ex) {
- console.log('failed to parse callNo, shelfLoc, subLibName, ' + ex.message);
- }
- }
- } // end libLocs
-
- htmlStr += '</tbody></table></div>';
-
- return htmlStr;
- }
-
- function getDoubanBookTitle() {
- // get book title
- title = $('h1 span').text();
- }
-
- function getDoubanBookIsbn() {
- // get book isbn
- try
- {
- var liTxt = null;
- $("#info span.pl").each(function(){
- liTxt = $(this).text();
- if (fDebug) console.log('lib book attr txt:' + liTxt);
- if (liTxt == 'ISBN:' && $(this)[0].nextSibling != null){
- isbn = $(this)[0].nextSibling.nodeValue.trim();
- if (fDebug) console.log('book isbn txt: [' + isbn + ']');
- }
- });
- } catch(ex) {
- console.log('In getDoubanBookIsbn, exception: ' + ex.message);
- }
- isbn10 = getIsbn10();
- if (fDebug) console.log("book isbn10: \'" + isbn10 + "\'");
- }
-
- function appendTitleLink_Loading(){
- var htmlStr = '';
- htmlStr += '<div id="libArea">' + getLibHeadHtml();
- htmlStr += '<div id="libInfo"><div class="indent">'
- + LIBSEARCH_LINK_PRE + ' href="' + getLibTitleUrl(title)
- + '" >' + LIBSEARCH_LINK_SUF;
-
- if (!isEmptyStr(isbn)) {
- htmlStr += '<ul id="libLoading">' + HTML_LOADING + '</ul>';
- }
- htmlStr += '</div></div></div>';
- $('.aside').prepend(htmlStr);
- setLibMemberStyle();
- }
-
- function queryLibByIsbn(vIsbn){
- if (fDebug) console.log("url : " + getLibIsbnUrl(vIsbn));
-
- var cacheInfo = GM_getValue(vIsbn);
- if (!cacheInfo && isbn10) {
- if (fDebug) console.log("check cache for isbn10 also ");
- cacheInfo = GM_getValue(isbn10);
- }
- if (cacheInfo) {
- var bookInfo = JSON.parse(cacheInfo);
- // '{"bookRecNo":' + bookRecNo + ', "hasMore":'+ fMore + ', "reservable":' + fHasReservable + ', "expressable":' + fHasExpress + '}';
- var bookRecNo = bookInfo['bookRecNo'];
- var fMore = bookInfo['hasMore'];
- var fReservable = bookInfo['reservable'];
- var fHasExpress = bookInfo['expressable'];
- if (fDebug) console.log(vIsbn + " cached, bookRecNo:" + bookRecNo + ", hasMore:" + fMore + ", reservable:" + fReservable + ", expressable:" + fHasExpress);
- appendLibBookHtml(bookRecNo, fMore, fReservable, fHasExpress);
- return ;
- }
-
- GM_xmlhttpRequest({
- method: 'GET',
- url: getLibIsbnUrl(vIsbn),
- headers: {
- 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
- },
- //onload: loadLibInfo
- onload: function(res) {
- var respTxt = res.responseText;
- if (fDebug) console.log("respTxt : " + respTxt);
-
- // shenzhenLib search result page will contains below string
- // if the isbn search find any books
- // parse string: &metaidList=1086672,962940,400742,70483,1184921,'
- var idstr = respTxt.match(/\&metaidList=.*?,\'/igm);
- if (fDebug) console.log("found metaids : " + idstr);
- var found = (idstr != null );
- if (found ) {
- // parse bookRecNos
- var bookRecNos = idstr[0].match(/\d+/g);
- isbn = vIsbn; // the value might be isbn10
- appendLibBookInfo(bookRecNos);
- } else {
- if (vIsbn.length == 13) {
- if (fDebug) console.log('try another value again');
- //setTimeout(function(){
- // appendLibInfoByIsbn10(vIsbn);
- //}, 20);
- if (isbn10) {
- queryLibByIsbn(isbn10);
- } else {
- $('#libLoading').remove();
- }
- } else {
- $('#libLoading').remove();
- }
- }
- }
- });
- }
-
- function appendLibInfoByIsbn10(isbn13){
- GM_xmlhttpRequest({
- method: 'GET',
- url: 'http://api.douban.com/book/subject/isbn/' + isbn13 + '?alt=json',
- headers: {
- 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
- },
- onload: function(res) {
- var isbn10 = null;
- var jsonObj = JSON.parse(res.responseText);
-
- var propArr = jsonObj['db:attribute'];
- for (var i = 0; i < propArr.length; i++) {
- if (fDebug) console.log("name: " + propArr[i]['@name']);
- if (fDebug) console.log("val : " + propArr[i]['$t']);
- if (propArr[i]['@name'] == 'isbn10') {
- isbn10 = propArr[i]['$t'];
- break;
- }
- }
-
- if (isbn10 != null && isbn10.length == 10) {
- queryLibByIsbn(isbn10);
- } else {
- $('#libLoading').remove();
- }
- }
- });
- }
-
- function getIsbn10() {
- var isbn10 = null;
- var borrowDiv = document.getElementById("borrowinfo");
- // div -> ul -> li -> a
- if (borrowDiv ) {
- if (borrowDiv.children[1] && borrowDiv.children[1].children[0]
- && borrowDiv.children[1].children[0].children[0]) {
- var libLink = borrowDiv.children[1].children[0].children[0].href;
- if (fDebug) console.log('libLink: ' + libLink);
- var m = libLink.match(/&subject=.*&type=/igm);
- if (m) {
- isbn10 = m[0];
- isbn10 = isbn10.substring("&subject=".length, isbn10.length - "&type=".length);
- if (fDebug) console.log('isbn10: ' + isbn10);
- return isbn10;
- }
- }
- }
- }
-
- /**
- * append the library link to douban book page
- * a) if the lib isbn query return books, the link is the first book page;
- * b) if the query results has more than one book, add query result link
- * c) if the first ten books has preservable book, set it as the book link
- * d) otherwise append title query link of Shenzhen Library
- */
- function appendLibraryLink() {
-
- title = null;
- isbn = null;
-
- getDoubanBookTitle();
- if (fDebug) console.log("book title: \'" + title + "\'");
- getDoubanBookIsbn();
- if (fDebug) console.log("book isbn: \'" + isbn + "\'");
- // it might not be book page, or douban changed the page structure
- if (isEmptyStr(title) && isEmptyStr(isbn) )
- return ;
-
- appendTitleLink_Loading();
-
- if (!isEmptyStr(isbn)) {
- // query library, append link to library
- setTimeout(function(){
- queryLibByIsbn(isbn);
- }, 200); // end of setTimeout
- }
- } // end of appendLibraryLink()
-
-
- function getLibBookTitle() {
- title = $('h3 a').text();
- }
-
- function getLibBookIsbn() {
- // get book isbn
- try
- {
- var liTxt = null;
- $("div.righttop ul li").each(function(){
- liTxt = $(this).text();
- if (fDebug) console.log('lib book attr txt:' + liTxt);
- //if ($(this).text() == 'ISBN' && $(this)[0].nextSibling != null)
- if (liTxt.indexOf('ISBN') == 0 && liTxt.length > 5) { // 5='ISBN:'.length
- //isbn = $(this)[0].nextSibling.nodeValue.trim();
- isbn = liTxt.substring(5).trim();
- if (fDebug) console.log('lib book isbn txt:' + isbn);
- isbn = isbn.replace(/-/g, '').substr(0,13);
- if (fDebug) console.log('lib book isbn:' + isbn);
- }
- });
- } catch(ex) {
- console.log('In getLibBookIsbn, exception: ' + ex.message);
- }
- }
-
- function appendDoubanTitleSearchLink() {
- if (isEmptyStr(title))
- return ;
-
- var htmlStr = '<li>在豆瓣:';
- htmlStr += getDoubanSearchLink(title) + '</li>';
- if (fDebug) console.log("book query url: " + htmlStr);
- $("div.righttop ul").append(htmlStr);
- }
-
- function appendDoubanBookLink(score, bookLink, pageCt) {
- var htmlStr = '<li>在豆瓣:';
- htmlStr += '<a href="' + bookLink + '" target="_blank" title="点击前往豆瓣查看评论">到豆瓣查看评论';
- if (score != null && !isNaN(score) && score > 0) {
- htmlStr += ' (评分: ' + score + ')';
- }
- htmlStr += '</a></li>';
- if (pageCt != null && !isNaN(pageCt) && pageCt > 0) {
- htmlStr += '<li>页数:'+ pageCt + '</li>';
- }
-
- if (fDebug) console.log("book query url: " + htmlStr);
-
- $("div.righttop ul").append(htmlStr);
- }
-
- // append link to douban book
- function appendDoubanLink() {
-
- title = null;
- isbn = null;
-
- if (fDebug) console.log('lib bookpage append link to douban book: ');
- getLibBookTitle();
- if (fDebug) console.log("book title: \'" + title + "\'");
- getLibBookIsbn();
- if (fDebug) console.log("book isbn: \'" + isbn + "\'");
- // it might not be lib book page, or shenzhen Lib changed the page structure
- if (isEmptyStr(title) && isEmptyStr(isbn) )
- return ;
-
- if (!isEmptyStr(isbn)) {
- //var doubanUrl = 'http://book.douban.com/isbn/' + isbn + '/';
- var doubanUrl = 'http://api.douban.com/book/subject/isbn/' + isbn + '?alt=json';
- setTimeout(function(){GM_xmlhttpRequest({
- method: 'GET',
- url: doubanUrl ,
- headers: {
- 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
- },
- onload: function(res) {
- try {
- var jsonObj = JSON.parse(res.responseText);
-
- var score = jsonObj['gd:rating']['@average'];
- var bookLink = jsonObj['link'][1]['@href'];
- var dbAttrs = jsonObj['db:attribute'];
- var pageCt = 0;
- for (var i = 0; i < dbAttrs.length; i++)
- {
- if (fDebug) console.log("attr: " + dbAttrs[i]['$t']);
- if (dbAttrs[i]['@name'] == 'pages') {
- pageCt = dbAttrs[i]['$t'];
- if (fDebug) console.log("pages: " + pageCt);
- }
- }
- if (fDebug) console.log("score: " + score);
-
- appendDoubanBookLink(score, bookLink, pageCt);
- } catch(ex) {//SyntaxError
- if (fDebug) console.log("respTxt: " + res.responseText);
- // no such book, responseText is not a valid json str
- appendDoubanTitleSearchLink();
- }
- }
- })}, 20); // end of setTimeout
- } else {
- appendDoubanTitleSearchLink();
- }
-
- } // end of appendDoubanLink()
-
-
- function appendLibraryInSearchPage() {
- var keyword = $(":text").val();
- keyword = keyword.replace(/-/g, '');
- if (fDebug) console.log('keyword: [' + keyword + ']');
- if (isEmptyStr(keyword))
- return ;
-
- var htmlStr =
- '<h2><span class="">图书馆搜索</span> · · · · · · </h2>'
- + '<p class="p1">' + LIBSEARCH_LINK_PRE
- + ' href="' + getLibTitleUrl(keyword)
- + '" >> '+ LIBSEARCH_LINK_SUF + '</p>';
-
- $(".aside h2:last").before(htmlStr);
- }
-
- function appendDoubanInSearchPage() {
-
- try
- {
- var keyword = $("span.fbold").text();
- if (isEmptyStr(keyword))
- return ;
- if (fDebug) console.log('keyword: [' + keyword + ']');
-
- var rsltSearchBtn = $("div.books_sel input:last");
- if (fDebug) console.log('find search in result button');
- var dbSearchBtn = rsltSearchBtn.clone();
- var dbSearchUrl = getDoubanSearchUrl(keyword);
- if (fDebug) console.log('copy it, new dbSearchBtn, dbSearchUrl: ' + dbSearchUrl);
- dbSearchBtn.attr('value','在豆瓣搜索');
- dbSearchBtn.attr('onclick', null);
- dbSearchBtn.click(function() {window.open(dbSearchUrl);});
-
- if (fDebug) console.log('created douban search button');
- $("div.books_sel").append(dbSearchBtn);
- } catch(ex) {
- console.log('In Library search page, exception: ' + ex.message);
- console.log('In Library search page, cannot find keyword, page struct may changed');
- }
- }
-
- function appendListBooksLibLink() {
- // eg, book.douban.com/doulist/232705/ (div.pl2 a),
- // book.douban.com/doulist/531890/ (div.title a),
-
- var fChecked = false;
- $('div.article table').each(function(){
- var keyword = '';
- if (!fChecked) {
- fChecked = true;
- GM_addStyle(".libSearch{\
- float:left;display: inline-block;\
- background: #eef9eb;border: 1px solid #2F7B4B;\
- padding: 1px 10px;border-radius:3px;margin-right: 8px;}\
- ");
- if (fDebug) console.log(' tag/doulist 1: fChecked[' + fChecked + '] ');
- }
-
- keyword = $('div.pl2 a', this).text();
- if (isEmptyStr(keyword))
- return ;
- keyword = keyword.trim();
- if (fDebug) console.log(' tag/doulist page: [' + keyword + ']');
-
- var htmlStr = LIBSEARCH_LINK_PRE +
- ' class="libSearch" href="' + getLibTitleUrl(keyword)
- + '" >' + LIBSEARCH_LINK_SUF;
- $('td > span.rr', this).append(htmlStr);
- });
- }
-
- function appendTagBooksLibLink() {
- // eg, book.douban.com/tag/web , book.douban.com/people/qibadao/collect
- // book.douban.com/chart
-
- $('div.article ul li').each(function(){
- var keyword = '';
- keyword = $('h2 a', this).text();
-
- if (isEmptyStr(keyword))
- return ;
- keyword = keyword.trim();
- if (fDebug) console.log(' tag page: [' + keyword + ']');
-
- var htmlStr = LIBSEARCH_LINK_PRE
- + ' class="j a_add2cart add2cart" href="'
- + getLibTitleUrl(keyword) + '">' + LIBSEARCH_LINK_SUF;
- $('span.cart-info span', this).first().append(htmlStr);
- });
- }
-
-
- (function() {
-
- var thisScript = {
- name: "douban_shenzhenLib",
- id: "116332",
- version:"1.24.10"
- };
-
- if (typeof(Updater)!='undefined') {
- var updater = new Updater(thisScript);
- updater.check(24);
- }
-
- if (fDebug) console.log('url host:' + document.URL);
-
- var vUrl = document.URL;
- if (vUrl.indexOf("douban.com/subject/") > 0) {
- if (fDebug) console.log('in douban page');
- appendLibraryLink();
- } else if (vUrl.indexOf("douban.com/subject_search") > 0) {
- appendLibraryInSearchPage();
- } else if (vUrl.indexOf("/Search/searchdetail.jsp") > 0) {
- if (fDebug) console.log('in shenzhen library page');
- appendDoubanLink();
- } else if (vUrl.indexOf("/Search/searchshow.jsp") > 0) {
- appendDoubanInSearchPage();
- } else if(vUrl.indexOf('/top250') > 0
- || vUrl.indexOf('/doulist/') > 0) {
- appendListBooksLibLink();
- } else if (vUrl.indexOf('/tag/') > 0
- || /\/people\/.+\/collect/.test(vUrl) || /\/chart(.*)$/.test(vUrl)) {
- appendTagBooksLibLink();
- }
- })();
复制代码
作者: lxh623 时间: 2019-9-11 10:45
读秀超星电子书获取插件。- // ==UserScript==
- // @name 读秀超星电子书获取插件,适用于龙岩网络图书馆,全国图书参考联盟等网站 by平底锅 (感谢maer)
- // @namespace duxiu.ssno.search
- // @version 1.0.1
- // @include *search*
- // @include *bookDetail.jsp?*
- // @include *advsearch*
- // @include *book.do?go=guide*
- // @include *book.do?go=showmorelib*
- // @include *searchEBook*
- // @include *www.duxiu.com*
- // @include *n/jpgfs/book/base*
- // @include *n/slib/book/slib*
- // @description 直接显示图书唯一编码ss号,增加存货查询按钮,一键获取图书方便快捷。
- // @copyright maer
- // @grant none
- // ==/UserScript==
-
- //获取当前网页地址
- var myurl = window.location.href;
- //定义统一的样式
- var mystyle = "font-family:Verdana;color:red;font-size:15px;font-weight:bold;";
- mystyle+="text-align:center;margin-top:5px;margin-bottom:5px;";
-
- app = {
- run: function(){
- //封面页展示图书显示ssid
- var isDuxiuIndex=myurl.indexOf("www.duxiu.com")!=-1;
- if(isDuxiuIndex)
- {
- var myul=document.querySelector("ul.zpicImg");
- var mybooks=myul.querySelectorAll("li");
- for(var i=0;i<mybooks.length;i++)
- {
- var myCov=mybooks[i].querySelector("img").src.toString();
- var ssid=GetSSID(myCov);
- var ssNode=CreateSSIDNode2(ssid,"myssid"+i);
- mybooks[i].appendChild(ssNode);
- }
- }
-
- //搜索页显示ssid
- var isSearch=myurl.indexOf("search?") != -1;
- var notBaoku=myurl.indexOf("book/search?")==-1;
- var notAdvsearch=myurl.indexOf("advsearch") == -1;
- if (isSearch&¬Advsearch&¬Baoku) {
- var subdomain = document.getElementsByName("sp.subdomain")[0];
- //读秀和长春图书馆的情况
- var isDuxiu=subdomain.value == "book.duxiu.com";
- var isCcelib=subdomain.value == "book.ccelib.com";
- if ( isDuxiu||isCcelib) {
- //获取书本列表节点
- var mybooks = document.getElementsByClassName("books");
- for (var i = 0; i < mybooks.length; i++) {
- //调整最小显示高度
- var listDL=mybooks[i].querySelector("dl");
- listDL.style.minHeight="210px";
-
- //获取ssid
- var ssid=GetSSIDDXID("ssid" + i,"dxid" + i);
- //创建插入节点
- var ssNode=CreateSSIDNode2(ssid,"myssid"+i);
- //插入节点
- var divImg=mybooks[i].querySelector(".divImg");
-
- //存货查询
- var infoAnchor=divImg.querySelector("a").href;
- var oldstr="bookDetail.jsp?dxNumber=";
- var newstr="book.do?go=showmorelib&type=1&dxid=";
- var scgAnchor="http://180.76.236.241:8089/sscx="+ssid;
- var csgbutton=document.createElement("a");
- csgbutton.href=scgAnchor;
- csgbutton.target="_blank";
- csgbutton.style="color:green;font-size:15px;font-weight:bold;text-decoration:none;";
- csgbutton.innerHTML="存货查询";
- var csgP=document.createElement("p");
- csgP.style="text-align:center;";
- csgP.appendChild(csgbutton);
-
- divImg.appendChild(ssNode);
- divImg.appendChild(csgP);
- };
- }
- //深圳文献港,全国图书馆联盟搜索页
- else {
- var mybooks = document.getElementsByClassName("book1");
- for (var i = 0; i < mybooks.length; i++) {
- //获取ssid
- var ssid=GetSSIDDXID("ssid" + i,"dxid" + i);
- //创建插入节点
- var ssNode=CreateSSIDNode2(ssid,"myssid"+i);
-
- //获取信息页地址
- var infoUrl=document.getElementById("url"+i).value;
- var dxid=getValueFromUrl2(infoUrl,"dxNumber");
- var dValue=getValueFromUrl2(infoUrl,"&d");
- var myhref="http://180.76.236.241:8089/sscx=";
- myhref+=ssid;
-
- var csgbutton=document.createElement("a");
- csgbutton.href=myhref;
- csgbutton.target="_blank";
- csgbutton.style="color:green;font-size:15px;font-weight:bold;text-decoration:none;";
- csgbutton.innerHTML="存货查询";
- var csgP=document.createElement("p");
- csgP.style="text-align:center;";
- csgP.appendChild(csgbutton);
-
- //插入节点
- var tdelems = mybooks[i].getElementsByTagName("td");
- for (var j = 0; j < tdelems.length; j++) {
- if (tdelems[j].id == "b_img") {
- var imgNode = tdelems[j];
- var insertPoint = imgNode.nextSibling;
- var myParentNode=insertPoint.parentNode;
- myParentNode.insertBefore(ssNode, insertPoint);
- myParentNode.insertBefore(csgP,insertPoint);
- }
- }
- }
- }
- }
-
- //信息页面显示ssid
- if (myurl.indexOf("bookDetail.jsp?") != -1) {
- //读秀信息页面
- if (myurl.indexOf("/views/specific/") == -1) {
- //获取ssid
- var bookphoto=document.getElementById("bookphoto");
- var imgsrc=bookphoto.querySelector("img").src;
- var ssid=GetSSID(imgsrc);
- //创建插入节点
- var ssNode=CreateSSIDNode(ssid);
- var grade1=document.getElementById("grade1");
- bookphoto.insertBefore(ssNode,grade1);
-
- //获取三个按钮的根节点,如果没有,则创建一个
- var bnt_content=document.querySelector(".bnt_content");
- if(bnt_content==null)
- {
- bnt_content=document.createElement("dd");
- bnt_content.className="bnt_content";
- var card_text=document.querySelector(".card_text");
- var card_dl=card_text.querySelector("dl");
- card_dl.appendChild(bnt_content);
- }
- var bnt_innerHtml=bnt_content.innerHTML;
- var d=getValueFromUrl("&d");
- var dxid=getValueFromUrl("dxNumber");
- /*有待解决d值的问题
- if(bnt_innerHtml.indexOf("图书馆文献传递")==-1)
- {
- var wxcd=document.createElement("a");
- wxcd.title="功能将您需要的全文发送到您的邮箱!";
- wxcd.className="bnt_book leftF";
- var wxcdUrl="javaScript:subtoRefer(true,'/gofirstdrs.jsp?dxNumber=";
- wxcdUrl+=dxid+"&d="+d+"')";
- wxcd.href=wxcdUrl;
- wxcd.innerHTML="图书馆文献传递";
- if(bnt_innerHtml.indexOf("部分阅读")==-1)
- {
- bnt_content.appendChild(wxcd);
- }
- else
- {
- bnt_content.insertBefore(wxcd,wxcd.firstElementChild);
- }
- }
- */
- //部分阅读按钮
- if(bnt_innerHtml.indexOf("部分阅读")==-1)
- {
- var bfydurl="http://book.duxiu.com/readDetail.jsp?dxNumber=";
- bfydurl+=dxid;
- bfydurl+="&";
- bfydurl+="d="+d;
-
- var bfyd=document.createElement("a");
- bfyd.href=bfydurl;
- bfyd.className="bnt_book leftF";
- bfyd.innerHTML="部分阅读";
- bnt_content.appendChild(bfyd);
- }
-
- //显示查询藏馆按钮
- var csgbutton=document.createElement("a");
- var oldstr="bookDetail.jsp?dxNumber=";
- var newstr="book.do?go=showmorelib&type=1&dxid=";
- var newAnchor="http://180.76.236.241:8089/sscx="+ssid;
- csgbutton.href=newAnchor;
- csgbutton.className="bnt_book leftF";
- csgbutton.innerHTML="存货查询";
- bnt_content.appendChild(csgbutton);
- }
- //深圳文献港,图书馆参考联盟图书信息页
- else {
- //获取ssid
- var tubookimg=document.querySelector(".tubookimg");
- var imgsrc=tubookimg.querySelector("img").src;
- var ssid=GetSSID(imgsrc);
- //创建插入节点
- var ssNode=CreateSSIDNode(ssid);
- tubookimg.appendChild(ssNode);
-
- //显示查询藏馆按钮
- var csgbutton=document.createElement("a");
- var dxid=getValueFromUrl("dxNumber");
- var dvalue=getValueFromUrl("&d");
- var myhref="http://180.76.236.241:8089/sscx=";
- myhref+=ssid;
-
- csgbutton.href=myhref;
- csgbutton.target="_blank";
- csgbutton.style="color:green;font-size:15px;font-weight:bold;text-decoration:none;";
- csgbutton.innerHTML="存货查询";
- var pTemp=document.createElement("p");
- pTemp.style="text-align:center;";
- pTemp.appendChild(csgbutton);
- tubookimg.appendChild(pTemp);
- }
- }
-
- //高级搜索页面显示ssid
- if (myurl.indexOf("advsearch") != -1) {
- //定义按钮
- var btnSSID = document.createElement("input");
- btnSSID.id = "btnshowSSID";
- btnSSID.class = "btnInput";
- btnSSID.type = "button";
- btnSSID.onclick = showAdvSS;
- btnSSID.value = "显示SS";
- btnSSID.style = "width:85px;height:27px;";
-
- //获取插入点,并插入
- var searchinfoDiv = document.getElementById("searchinfo");
- searchinfoDiv.appendChild(btnSSID);
- }
-
- //电子书导航页
- if(myurl.indexOf("book.do?go=guide")!=-1)
- {
- var ulLists=document.getElementsByTagName("ul");
- var ulBooks=null;
- for(var i=0;i<ulLists.length;i++)
- {
- if(ulLists[i].className=="clearfix")
- {
- ulBooks=ulLists[i];
- }
- }
- if(ulBooks!=null)
- {
- var bookLists=ulBooks.querySelectorAll("li");
- for(var j=0;j<bookLists.length;j++)
- {
- var ImgDiv=bookLists[j].getElementsByClassName("divImg");
- if(ImgDiv.length!=0)
- {
- var imgNode=ImgDiv[0];
- var covimgs=imgNode.getElementsByTagName("img");
- if(covimgs.length!=0)
- {
- var covimg=covimgs[0];
- var imghref=covimg.src;
- var ssid = GetSSID(imghref);
- var ssidNode=CreateSSIDNode(ssid);
- imgNode.appendChild(ssidNode);
- }
- }
-
- }
- }
- }
-
- //电子书检索页
- if(myurl.indexOf("searchEBook?")!=-1)
- {
- var mybooks=document.querySelector(".books");
- var myBookLists=mybooks.querySelectorAll("li");
- for(var i=0;i<myBookLists.length;i++)
- {
- //调整列表最小高度
- var listDL=myBookLists[i].querySelector("dl");
- listDL.style.minHeight="190px";
-
- //获取ssid
- var ssid=GetSSIDDXID("ssid" + i,"dxid_" + i);
-
- //创建插入节点
- var ssNode=CreateSSIDNode2(ssid,"myssid"+i);
-
- var divImg=myBookLists[i].querySelector(".divImg");
- divImg.appendChild(ssNode);
- }
- }
- //藏馆页面
- if(myurl.indexOf("book.do?go=showmorelib")!=-1)
- {
- //显示ssid部分
- var headDiv=document.querySelector(".header");
- var flDiv=headDiv.querySelector("img");
- var imgSrc=flDiv.src;
- var ssid=GetSSID(imgSrc);
- var ssidLi=document.createElement("li");
- ssidLi.style="color:red;font-weight:bold;";
- console.log(ssid);
- console.log(ssid.length);
- if(ssid.length==8)
- {
- ssidLi.innerHTML="【SS号】"+ssid;
- }
- else
- {
- ssidLi.innerHTML="【DX号】"+ssid;
- }
- var infoUL=headDiv.querySelector("ul");
- var insertPoint=infoUL.firstElementChild.nextElementSibling;
- infoUL.insertBefore(ssidLi,insertPoint);
-
- //统一按钮风格
- var btnStyle= "min-width:90px;height:28px;margin-left:10px;font-weight:bold;color:red;";
- //显示切换按钮
- var switchButton=document.createElement("input");
- switchButton.id = "switchSCG";
- switchButton.type = "button";
- switchButton.onclick = switchSCG;
- if(myurl.indexOf("&type=1")!=-1)
- {
- switchButton.value = "纸质藏馆";
- }
- else
- {
- switchButton.value = "存货查询";
- }
- switchButton.style = btnStyle;
- var tabDiv=document.querySelector(".tab");
- tabDiv.appendChild(switchButton);
-
- //返回按钮
- var returnButton=document.createElement("input");
- returnButton.id="returnBtn";
- returnButton.type="button";
- returnButton.style =btnStyle;
- returnButton.onclick=returnBookDetail;
- returnButton.value="返回BookDetail";
- tabDiv.appendChild(returnButton);
-
- //试读按钮
- var sd=document.createElement("input");
- sd.id="sd";
- sd.type="button";
- sd.style= btnStyle;
- sd.value="试读";
- sd.onclick=sdtz;
- tabDiv.appendChild(sd);
- }
-
- //包库搜索页面显示ssid
- if(myurl.indexOf("book/search")!=-1)
- {
- var ztbg=document.querySelector("div[class='ztbg']");
- var h2Status=ztbg.querySelector("h2[class='fl zli_t']");
- var insertPoint=h2Status.nextElementSibling;
- //定义按钮
- var btnSSID = document.createElement("input");
- btnSSID.id = "btnshowSSID";
- btnSSID.class = "btnInput";
- btnSSID.type = "button";
- btnSSID.onclick = GetBaoKuSSID;
- btnSSID.value = "显示SSID";
- btnSSID.style = "width:85px;height:30px;color:red;margin-left:15px;";
- ztbg.insertBefore(btnSSID,insertPoint);
- }
-
- //试读页显示封面、书名、版权、封底四个按钮
- if(myurl.indexOf("/n/jpgfs/book/base/")!=-1)
- {
- var jpath="";
- var mySource=document.querySelector("html").outerHTML;
- var istart=0;
- var iend=0;
- var myIndexStr1="jpgPath:\"";
- var myIndexStr2="\"";
- istart=mySource.indexOf(myIndexStr1);
- istart+=myIndexStr1.length;
- iend=mySource.indexOf(myIndexStr2,istart);
- jpath=mySource.substring(istart,iend);
-
- var baseUrl="http://img.duxiu.com";
- var myCovUrl=baseUrl+jpath+"cov001?zoom=2";
- var myBokUrl=baseUrl+jpath+"bok001?zoom=2";
- var myLegUrl=baseUrl+jpath+"leg001?zoom=2";
- var myBacUrl=baseUrl+jpath+"cov002?zoom=2";
-
- console.log("封面页:"+myCovUrl);
- console.log("书名页:"+myBokUrl);
- console.log("版权页:"+myLegUrl);
- console.log("封底页:"+myBacUrl);
-
- var t_content=document.querySelector("#t_content");
- t_content.style="width:815px;";
- var tc_right=document.querySelector("#tc_right");
- tc_right.style="width:240px;";
- var myul=tc_right.querySelector("ul");
-
- var cov001li=addALink(myCovUrl,"cov001","封面","cov001.pdg");
- cov001li.style.marginTop="7px";
- myul.appendChild(cov001li);
-
- var bok001li=addALink(myBokUrl,"bok001","书名","bok001.pdg");
- bok001li.style.marginTop="7px";
- myul.appendChild(bok001li);
-
- var leg001li=addALink(myLegUrl,"leg001","版权","leg001.pdg");
- leg001li.style.marginTop="7px";
- myul.appendChild(leg001li);
-
- var cov002li=addALink(myBacUrl,"cov002","封底","cov002.pdg");
- cov002li.style.marginTop="7px";
- myul.appendChild(cov002li);
-
- var oneKeyDown=document.createElement("li");
- oneKeyDown.style="margin-top: 7px;margin-left:6px;";
- var oneKeyDownlink=document.createElement("a");
- oneKeyDownlink.id="oneKeyDown";
- oneKeyDownlink.style="color: red;font-weight:bold;cursor: pointer;";
- oneKeyDownlink.innerHTML="一键下载";
- oneKeyDownlink.href="#";
- oneKeyDownlink.onclick=OneKeyDownAll;
- oneKeyDown.appendChild(oneKeyDownlink);
- myul.appendChild(oneKeyDown);
- }
-
- //包库在线阅读页显示封面、书名、版权、封底四个按钮
- if(myurl.indexOf("/n/slib/book/slib/")!=-1)
- {
- var jpath="";
- var mySource=document.querySelector("html").outerHTML;
- var istart=0;
- var iend=0;
- var myIndexStr1="jpgPath: \"";
- var myIndexStr2="\"";
- istart=mySource.indexOf(myIndexStr1);
- istart+=myIndexStr1.length;
- iend=mySource.indexOf(myIndexStr2,istart);
- jpath=mySource.substring(istart,iend);
- console.log(jpath);
- var baseUrl="http://img.sslibrary.com";
- var myCovUrl=baseUrl+jpath+"cov001?zoom=2";
- var myBokUrl=baseUrl+jpath+"bok001?zoom=2";
- var myLegUrl=baseUrl+jpath+"leg001?zoom=2";
- var myBacUrl=baseUrl+jpath+"cov002?zoom=2";
-
- console.log("封面页:"+myCovUrl);
- console.log("书名页:"+myBokUrl);
- console.log("版权页:"+myLegUrl);
- console.log("封底页:"+myBacUrl);
-
- var ToolsBar=document.querySelector(".ToolsBar");
- var myul=ToolsBar.querySelector("ul");
- myul.style.width="1366px";
-
-
- var cov001li=addALink(myCovUrl,"cov001","封面","cov001.pdg");
- myul.appendChild(cov001li);
-
- var bok001li=addALink(myBokUrl,"bok001","书名","bok001.pdg");
- myul.appendChild(bok001li);
-
- var leg001li=addALink(myLegUrl,"leg001","版权","leg001.pdg");
- myul.appendChild(leg001li);
-
- var cov002li=addALink(myBacUrl,"cov002","封底","cov002.pdg");
- myul.appendChild(cov002li);
-
- var oneKeyDown=document.createElement("li");
- oneKeyDown.style="margin-left:6px;";
- var oneKeyDownlink=document.createElement("a");
- oneKeyDownlink.id="oneKeyDown";
- oneKeyDownlink.style="color: red;font-weight:bold;cursor: pointer;";
- oneKeyDownlink.innerHTML="一键下载";
- oneKeyDownlink.href="#";
- oneKeyDownlink.onclick=OneKeyDownAll;
- oneKeyDown.appendChild(oneKeyDownlink);
- myul.appendChild(oneKeyDown);
- }
- }};
-
-
- function GetBaoKuSSID()
- {
- var myssids=document.querySelectorAll("#myssid");
- if(myssids.length!=0)
- {
- return;
- }
- else
- {
- var mybooklist=document.querySelectorAll("ul[class='clearfix zli_item']");
- for(var i=0;i<mybooklist.length;i++)
- {
- var mybook=mybooklist[i].querySelector("li[class='fl zli_img']");
- var bookimg=mybook.querySelector("img");
- var myimgSrc=bookimg.src;
- console.log(myimgSrc);
- var myssid=GetSSID(myimgSrc);
- console.log(myssid);
- var ssidNode=CreateSSIDNode(myssid);
- mybook.appendChild(ssidNode);
- }
- }
- }
-
- function OneKeyDownAll()
- {
- var mylinksId=new Array("cov001","bok001","leg001","cov002");
- for(var i=0;i<mylinksId.length;i++)
- {
- var mylink=document.getElementById(mylinksId[i]);
- mylink.click();
- }
- }
-
- function addALink(urlStr,myIdStr,innerHTMLStr,downloadName)
- {
- var myli=document.createElement("li");
- myli.style="margin-left:6px;";
- var alink=document.createElement("a");
- alink.id=myIdStr;
- alink.innerHTML=innerHTMLStr;
- alink.href=urlStr;
- alink.style="color: green;font-weight:bold;cursor: pointer;";
- alink.download=downloadName;
- myli.appendChild(alink);
- return myli;
- }
-
- //切换藏书查询
- function switchSCG()
- {
- var newurl="";
- if(myurl.indexOf("&type=1")!=-1)
- {
- newurl=myurl.replace("&type=1","");
- }
- else
- {
- newurl=myurl+"&type=1";
- }
- window.location.href=newurl;
- }
-
-
- //跳转试读页
- function sdtz()
- {
- var d=getValueFromUrl("&d");
- var dxid=getValueFromUrl("&dxid");
- newurl="http://book.duxiu.com/readDetail.jsp?dxNumber=";
- newurl+=dxid;
- newurl+="&";
- newurl+="d="+d;
- window.open(newurl,"_blank");
- }
-
- //返回bookdetail
- function returnBookDetail()
- {
- var d=getValueFromUrl("&d");
- var dxid=getValueFromUrl("&dxid");
- newurl="http://book.duxiu.com/bookDetail.jsp?dxNumber=";
- newurl+=dxid;
- newurl+="&";
- newurl+="d="+d;
- window.location.href=newurl;
- }
- //从当前网址中提取某个字段,输入字段名称
- function getValueFromUrl(myfield)
- {
- var str=myfield+"=";
- if(myurl.indexOf(str)!=-1)
- {
- var reg =new RegExp(myfield+"\\=\\w+");
-
- var fieldStr = myurl.match(reg)[0];
- console.log(myfield.toString());
- var fieldValue = fieldStr.replace(myfield+"=", "");
- return fieldValue;
- }
- }
-
- //从当前网址中提取某个字段,输入字段名称
- function getValueFromUrl2(URL,myfield)
- {
- var str=myfield+"=";
- if(URL.indexOf(str)!=-1)
- {
- var reg =new RegExp(myfield+"\\=\\w+");
-
- var fieldStr = URL.match(reg)[0];
- var fieldValue = fieldStr.replace(myfield+"=", "");
- return fieldValue;
- }
- }
-
- //获取ssid或者dxid,当ssid不存在的时候,返回dxid
- //输入ssid的元素id以及读秀dxid的元素id
- function GetSSIDDXID(ssidNodeID,dxidNodeID)
- {
- //获取ssid
- var ssid=GetSSIDByID(ssidNodeID,"value");
-
- //获取dxid
- var dxid=GetSSIDByID(dxidNodeID,"value");
-
- //如果ssid不存在,则用dxid替代
- if (ssid == "") {
- ssid = dxid;
- }
- return ssid;
- }
- //获取ssid,输入元素的id、属性名称(一般为value)
- function GetSSIDByID(elementID,strAttribute)
- {
- var ssidNode=document.getElementById(elementID);
- var ssid=ssidNode.getAttribute(strAttribute);
- return ssid;
- }
- //创建默认的ssid节点,节点id为myssid
- function CreateSSIDNode(ssid)
- {
- var myid='myssid';
- return CreateSSIDNode2(ssid,myid);
- }
- //创建ssid节点,输入ssid和节点id
- function CreateSSIDNode2(ssid,strID)
- {
- var ssNode = document.createElement("p");
- ssNode.id=strID;
- ssNode.style=mystyle;
- ssNode.innerHTML=ssid;
- return ssNode;
- }
-
- //高级搜索页面显示ssid
- function showAdvSS() {
- //获取图书节点
- var mybooks = document.getElementsByClassName("books")[0];
- var booklists=mybooks.getElementsByTagName("li");
- for (var i = 0; i < booklists.length; i++) {
- //判断是否存在,如果存在,则跳过
- var myssid = document.getElementById("myssid" + i);
- if (myssid != null) {
- continue;
- }
- //获取ssid
- var ssid=GetSSIDDXID("ssid" + i,"dxid" + i);
-
- //创建插入节点
- var ssNode=CreateSSIDNode2(ssid,"myssid"+i);
-
- //修改dl最低高度
- var listDL=booklists[i].querySelector("dl");
- listDL.style.minHeight="210px";
-
- //插入数据
- var divImg=booklists[i].getElementsByClassName("divImg")[0];
-
- var infoAnchor=divImg.querySelector("a").href;
- var oldstr="bookDetail.jsp?dxNumber=";
- var newstr="book.do?go=showmorelib&type=1&dxid=";
- var scgAnchor="http://180.76.236.241:8089/sscx="+ssid;
- //存货查询
- var csgbutton=document.createElement("a");
- csgbutton.href=scgAnchor;
- csgbutton.target="_blank";
- csgbutton.style="color:green;font-size:15px;font-weight:bold;text-decoration:none;";
- csgbutton.innerHTML="存货查询";
- var csgP=document.createElement("p");
- csgP.style="text-align:center;";
- csgP.appendChild(csgbutton);
-
- divImg.appendChild(ssNode);
- divImg.appendChild(csgP);
- }
- }
-
- function GetSSID(strImgSrc) {
- var ssid = "";
- var iidStr=GetEncode(strImgSrc);
- var ssidStr = DeCode(iidStr);
- ssid = TrimString(ssidStr);
- return ssid;
- }
-
- function GetEncode(strImgSrc) {
- var reg = /iid\=\w+/;
- var iidStr = strImgSrc.match(reg)[0];
- iidStr = iidStr.replace("iid=", "");
- return iidStr;
- }
-
- function TrimString(inputStr) {
- var outPutStr = "";
- inputStr = inputStr.replace(/\//g, "");
- var reg = /\d{8,}/;
- outPutStr = inputStr.match(reg);
- outPutStr=outPutStr.toString();
- return outPutStr;
- }
-
- function DeCode(EnCodeStr) {
- var decodeStr = "";
- var baseNumStr = EnCodeStr.substring(EnCodeStr.length - 2);
- var baseNum = parseInt(baseNumStr, 16);
- var myCodeStr = EnCodeStr.substring(0, EnCodeStr.length - 16);
- for (var i = 0; i < myCodeStr.length; i = i + 2) {
- decodeStr += GetSubString(myCodeStr, baseNum, i);
- }
- return decodeStr;
- }
-
- function GetSubString(EnCodeStr, BaseNum, startIndex) {
- var s = "";
- s = EnCodeStr.substring(startIndex, startIndex + 2);
- //转换进制
- var i = parseInt(s, 16) - BaseNum;
- s = String.fromCharCode(i);
- return s;
- }
-
- try {
- app.run();
- } catch (e) {
- console.log(e);
- }
复制代码
作者: codegay 时间: 2019-9-13 01:54
回复 2# Batcher
浏览器脚本都是JS,chrome还有暴力猴Violentmonkey可以用,装了之后支持浏览器脚本。
作者: xp3000 时间: 2019-9-29 17:44
油猴还是很好用的
欢迎光临 批处理之家 (http://bathome.net./) |
Powered by Discuz! 7.2 |