Add books.google.fr support

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X4uRGZZ4EpYHA4PNK3x5JY
This commit is contained in:
alexture 2026-09-20 16:47:54 +02:00
parent ac9c35b06d
commit 5d822caf97
2 changed files with 6 additions and 4 deletions

View file

@ -24,7 +24,7 @@ On a book page on Bookshop.org, Amazon (`.fr`/`.com`), Waterstones, or Google Bo
- `bookshop.org/p/books/*` - `bookshop.org/p/books/*`
- `waterstones.com/book/*` - `waterstones.com/book/*`
- `amazon.fr` and `amazon.com` product pages (`/dp/*`) - `amazon.fr` and `amazon.com` product pages (`/dp/*`)
- Google Books (`books.google.com/books?id=…`, `google.com/books/edition/…`) - Google Books (`books.google.com/books?id=…`, `google.com/books/edition/…`, and the `.fr` equivalents)
## Notes ## Notes

View file

@ -1,7 +1,7 @@
// ==UserScript== // ==UserScript==
// @name Book Links // @name Book Links
// @namespace http://tampermonkey.net/ // @namespace http://tampermonkey.net/
// @version 1.2 // @version 1.3
// @description Show Anna's Archive and Waterstones links when browsing books // @description Show Anna's Archive and Waterstones links when browsing books
// @license MIT // @license MIT
// @match https://bookshop.org/p/books/* // @match https://bookshop.org/p/books/*
@ -12,6 +12,8 @@
// @match https://www.amazon.com/*/dp/* // @match https://www.amazon.com/*/dp/*
// @match https://books.google.com/books?* // @match https://books.google.com/books?*
// @match https://www.google.com/books/edition/* // @match https://www.google.com/books/edition/*
// @match https://books.google.fr/books?*
// @match https://www.google.fr/books/edition/*
// @connect annas-archive.gl // @connect annas-archive.gl
// @connect www.waterstones.com // @connect www.waterstones.com
// @connect www.chez-mon-libraire.fr // @connect www.chez-mon-libraire.fr
@ -64,7 +66,7 @@
return null; return null;
} }
if (host.includes('google.com')) { if (host.includes('google.')) {
const text = document.body?.innerText || ''; const text = document.body?.innerText || '';
const m13 = text.match(/\b(97[89][-\d ]{9,14}\d)\b/); const m13 = text.match(/\b(97[89][-\d ]{9,14}\d)\b/);
if (m13) { if (m13) {
@ -119,7 +121,7 @@
return { title, author }; return { title, author };
} }
if (host.includes('google.com')) { if (host.includes('google.')) {
const title = document.querySelector('h1')?.textContent?.trim(); const title = document.querySelector('h1')?.textContent?.trim();
const author = document.querySelector('a[href*="inauthor"]')?.textContent?.trim(); const author = document.querySelector('a[href*="inauthor"]')?.textContent?.trim();
return { title, author }; return { title, author };