Skip to content

Instantly share code, notes, and snippets.

View BrittanyBunk's full-sized avatar

Brittany Bunk BrittanyBunk

View GitHub Profile
@MignonBelongie
MignonBelongie / anglify
Created January 4, 2022 03:56
Bookmarklet for Open Library that shows English titles and covers, when available, in an author's list of works
javascript: (() => { document.querySelectorAll('#searchResults li.searchResultItem').forEach(el => { a = el.querySelector('.resultTitle a'); u = a.getAttribute('href').split('?')[0]; fetch(u + '/editions.json/').then(r => r.json()).then((j) => { ees = j.entries.filter(e => e.languages && e.languages[0].key == '/languages/eng'); ees2 = ees.filter(e => e.covers); ee = ees2.length? ees2[0] : ees.length? ees[0] : 0; if (ee) { el.querySelector('.resultTitle a').innerHTML = ee.title; if (ee.covers && ee.covers.length) { i = `//covers.openlibrary.org/b/id/${ee.covers[0]}-M.jpg`; el.querySelector('img').setAttribute('src', i) } } }) }) })();