Goodreads expand: Expand author info on book pages.

This commit is contained in:
tastytea 2021-04-24 22:08:21 +02:00
parent c555e69ad1
commit 29c5109c0a
Signed by untrusted user: tastytea
GPG Key ID: CFC39497F1B26E07
1 changed files with 25 additions and 17 deletions

View File

@ -2,7 +2,7 @@
// @name Goodreads expand // @name Goodreads expand
// @description Show the whole description / author information / book details on goodreads.com. // @description Show the whole description / author information / book details on goodreads.com.
// @description:de Zeige die ganze beschreibung / author·inneninformation / buchdetails auf goodreads.com an. // @description:de Zeige die ganze beschreibung / author·inneninformation / buchdetails auf goodreads.com an.
// @version 2021.04.20.1 // @version 2021.04.24.1
// @author tastytea // @author tastytea
// @copyright 2020, 2021, tastytea (https://tastytea.de/) // @copyright 2020, 2021, tastytea (https://tastytea.de/)
// @license GPL-3.0-only // @license GPL-3.0-only
@ -19,27 +19,35 @@
(function() (function()
{ {
let root = document.getElementById("description"); // Book description.
if (root === null) const description = document.getElementById("description");
// Author info on author page.
let author = document.getElementsByClassName("aboutAuthorInfo")[0];
if (author === undefined)
{ {
root = document.getElementsByClassName("aboutAuthorInfo")[0]; // Author info on book page.
if (root === null) author = document.getElementsByClassName("bookAuthorProfile")[0];
}
for (const element of [description, author])
{
if (element == null) // null or undefined.
{ {
console.warn("Could not find description / author info."); continue;
return; }
const spans = element.getElementsByTagName("span");
if (spans.length >= 2)
{
spans[1].setAttribute("style", "display: block;");
spans[0].setAttribute("style", "display: none;");
const links = element.getElementsByTagName("a");
links[links.length - 1].text = "(less)";
} }
} }
const spans = root.getElementsByTagName("span"); // Data below books.
if (spans.length >= 2)
{
spans[1].setAttribute("style", "display: block;");
spans[0].setAttribute("style", "display: none;");
const links = root.getElementsByTagName("a");
links[links.length - 1].text = "(less)";
}
const bookdata = document.getElementById("bookDataBox"); const bookdata = document.getElementById("bookDataBox");
if (bookdata !== null) if (bookdata !== null)
{ {