カーリル
ゴリゴリのIT企業の雰囲気がなくていい
https://calil.jp/company/#:~:text=近くの温泉
が書いてあって遊び心がある
https://upload.wikimedia.org/wikipedia/commons/thumb/1/1c/Calil_Nakatsugawa_office.jpg/500px-Calil_Nakatsugawa_office.jpg↗️
オフィスがめちゃくちゃローカルな感じがいい
URLもISBNでシンプル
https://calil.jp/book/4098254840
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に備えて
fetchなしでリンク先が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);
電子化されていない書籍#698d37730000000000a6b3a3の価格の横断検索のために
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 {
year = document.querySelector('itemprop="datePublished"')?.textContent?.match(/\d{4}/)?.0 || '';
}
window.open(
'https://qszyn.github.io/MyToolBox/図書館取り寄せフォーム.html?' +
new URLSearchParams({
title: document.querySelector('itemprop="name"')?.textContent?.trim() || '',
author: document.querySelector('itemprop="author" > a')?.textContent?.trim() || '',
publisher: document.querySelector('itemprop="publisher"')?.textContent?.trim() || '',
year: year,
isbn: document.querySelector('itemprop="isbn":last-of-type')?.nextSibling.textContent.trim() || ''
}).toString(),
'_blank'
)
})()
月抽出未対応