Goodreads:显示图书 ID 和 ISBN
在书名下方附加图书标识符和 ISBN,处理数据时很方便。
可复制的代码
// Append the book ID and ISBN to the page title for developers
(function () {
var isbn = document.querySelector('[itemprop="isbn"]');
var m = location.pathname.match(/\/book\/show\/(\d+)/);
var bits = [];
if (m) { bits.push('id ' + m[1]); }
if (isbn && isbn.textContent.trim()) { bits.push('ISBN ' + isbn.textContent.trim()); }
var title = document.querySelector('.bookTitle, h1[data-testid="bookTitle"]');
if (title && bits.length) {
var tag = document.createElement('small');
tag.style.cssText = 'display:block;color:#888;font-weight:400;font-size:0.8rem';
tag.textContent = bits.join(' · ');
title.appendChild(tag);
}
})();
如何使用此示例
- 用上方按钮复制代码。
- 安装 JustZix(2 分钟),在目标页面打开扩展。
- 添加一条匹配该页面的新规则。
- 将代码粘贴到规则的 JavaScript 面板并保存 — 每次访问页面时都会运行。
为此示例评分
暂无评分 — 成为第一个。