Greasy Fork is available in English.
查询全国图书馆参考咨询联盟中图书的SS
当前为
// ==UserScript==
// @name 图书馆SS显示
// @namespace book.ucdrs
// @version 0.1.0
// @author wenmin92
// @match *://book.ucdrs.superlib.net/search*
// @match *://book.ucdrs.superlib.net/views/specific/*
// @description 查询全国图书馆参考咨询联盟中图书的SS
// @license MIT
// ==/UserScript==
function doSpecific() {
const el = document.querySelector('script[language]:not([src])');
const imgBox = document.querySelector('.tubookimg');
if (el) {
const ss = el.innerText.match(/ssn=(\d{3,})/)?.[1];
let dx = ''
if (ss) {
imgBox.append('SS:' + ss);
} else if(dx = location.href.match(/dxNumber=(\d+)/)?.[1]) {
imgBox.append('DX:' + dx);
}
}
}
function doSearch() {
document.querySelectorAll('td[id="b_img"]').forEach(item => {
const ss = item.parentElement.querySelector('input[name*="ssid"]').value;
if (ss) {
item.nextElementSibling.append('SS:' + ss);
} else {
const dxNumber = item
.querySelector('a[href*="dxNumber"]')
.getAttribute('href')
.match(/dxNumber=(\d+)/)?.[1];
dxNumber && item.nextElementSibling.append('DX:' + dxNumber);
}
});
}
if (location.href.includes('/views/specific/')) {
doSpecific();
} else if (location.href.includes('/search')) {
doSearch();
}