カーリル
ゴリゴリのIT企業の雰囲気がなくていい
が書いてあって遊び心がある
https://upload.wikimedia.org/wikipedia/commons/thumb/1/1c/Calil_Nakatsugawa_office.jpg/500px-Calil_Nakatsugawa_office.jpg↗️ オフィスがめちゃくちゃローカルな感じがいい
URLもISBNでシンプル
https://gyazo.com/1f0ceeac01e06c76228460e14fe96d1e
図書館ごとのピックアップはどうやって作っているんだろう
今日返却された本とか
今までどれくらい借りられてきたのか知りたい
カーリルから,版元ドットコムの紹介と目次を直接見たいな
拡張機能か?
カーリルのページからリンクされている版元どっとこむのサイトに飛んで,紹介と目次のデータをとってくる拡張機能を作りたい
document.querySelector('a.linkbutton[href^="https://www.hanmoto.com"]')
でそのサイトに飛べて,document.querySelector('[data-book-contents-name="kaisetsu"] p')に概要がある.
htmlスクレイピングしたいのわかってる
<span itemprop="publisher">毎日コミュニケーションズ</span>
404に備えて
code:toSHINSHOmap.js
waitForElement('.other .bottom_line',() => {
code:toSHINSHOmap.js
const isbn = location.pathname.split('/').pop();
const a = Object.assign(document.createElement('a'), {
className: 'linkbutton',
target: '_blank',
href: https://shinshomap.info/book/${isbn},
textContent: '新書マップ',
style: 'display:none'
});
const img = Object.assign(document.createElement('img'), {
hidden: true,
onload() {
if (this.src.startsWith('data:image/gif;base64')) {
} else {
a.style.display = '';
}
},
src: https://api.shinshomap.info/cur/img/book/${isbn}.jpg
});
a.append(img);
document.querySelector('.other .bottom_line').append(a);
code:toSHINSHOmap.js
document.querySelector('.other .bottom_line').append(
Object.assign(document.createElement('a'), {
className: 'linkbutton',
target: '_blank',
href: http://book.tsuhankensaku.com/hon/index.php?t=booksearch&q=${isbn},
textContent: '在庫横断検索',
})
);
code:toSHINSHOmap.js
})
function waitForElement(selector, callback) {
const el = document.querySelector(selector);
if (el) {
callback(el);
return;
}
const observer = new MutationObserver(() => {
const el = document.querySelector(selector);
if (el) {
observer.disconnect(); //継続監視するか
callback(el);
}
});
observer.observe(document.documentElement, {
childList: true,
subtree: true
});
}
code:metadata.js
(function(){
var dateText = document.querySelector('itemprop="isbn":last-of-type')?.nextSibling?.textContent || ''; var dateMatch = dateText.match(/\((\d{4})-(\d{2})-\d{2}\)/);
var year = '';
if (dateMatch) {
year = dateMatch1 + '. ' + parseInt(dateMatch2, 10); } else {
}
window.open(
new URLSearchParams({
title: document.querySelector('itemprop="name"')?.textContent?.trim() || '', year: year,
isbn: document.querySelector('itemprop="isbn":last-of-type')?.nextSibling.textContent.trim() || '' }).toString(),
'_blank'
)
})()
月抽出未対応