// ==UserScript== // @id xuqb@lib.pku.edu.cn // @name 豆瓣读书揭示北大馆藏 // @namespace lib.pku.edu.cn // @version 1.0 // @description 为豆瓣读书增加北京大学图书馆相关资源链接。图书页面右侧的“在哪儿借这本书”中将出现红色图标及“北京大学图书馆”链接,点击链接可以打开北大馆藏目录中该书的检索结果。如果该书有 ISBN(国际标准书号)但查无此书,或没有 ISBN,则改为提供一个按书名检索的链接。 // @author 馆君 // @match https://book.douban.com/subject/* // @connect 162.105.138.200 // @grant GM_xmlhttpRequest // @grant GM_setClipboard // @grant GM_addStyle // @grant GM_setValue // @grant GM_getValue // @downloadURL none // ==/UserScript== GM_addStyle("@charset utf-8; #borrowinfo ul img {height: 16px; vertical-align: text-bottom; padding-right: 2px;}"); function getDoc(url, meta, callback) { // XHR 回调函数模板 GM_xmlhttpRequest({ method: 'GET', url: url, headers: { 'User-agent': window.navigator.userAgent, 'Content-type': null }, onload: function(responseDetail) { var doc = ''; if (responseDetail.status == 200) { doc = new DOMParser().parseFromString(responseDetail.responseText, 'text/html'); if (doc === undefined) { doc = document.implementation.createHTMLDocument(""); doc.querySelector('html').innerHTML = responseText; } } callback(doc, responseDetail, meta); } }); } (function() { 'use strict'; if($("#borrowinfo").length <= 0) // 如果借阅信息面板不存在,模仿常例创建之 $("#buyinfo").after($("