forked from tastytea/userscripts
goodreads: Add support for descriptions on hover.
This commit is contained in:
parent
30ae58f42f
commit
706a49885f
|
@ -2,7 +2,7 @@
|
|||
// @name Goodreads expand
|
||||
// @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.
|
||||
// @version 2021.04.24.1
|
||||
// @version 2021.07.20.1
|
||||
// @author tastytea
|
||||
// @copyright 2020, 2021, tastytea (https://tastytea.de/)
|
||||
// @license GPL-3.0-only
|
||||
|
@ -11,8 +11,7 @@
|
|||
// @supportURL https://schlomp.space/tastytea/userscripts/issues
|
||||
// @downloadURL https://schlomp.space/tastytea/userscripts/raw/branch/main/catalogues/goodreads_expand.user.js
|
||||
// @grant none
|
||||
// @match https://www.goodreads.com/book/*
|
||||
// @match https://www.goodreads.com/author/*
|
||||
// @match https://www.goodreads.com/*
|
||||
// @run-at document-end
|
||||
// @inject-into content
|
||||
// ==/UserScript==
|
||||
|
@ -55,3 +54,29 @@
|
|||
document.getElementById("bookDataBoxShow").setAttribute("style", "display: none;");
|
||||
}
|
||||
})();
|
||||
|
||||
// On-hover book descriptions are getting loaded dynamically, so we have to look
|
||||
// for them periodically.
|
||||
function userscript_expand_hover_description()
|
||||
{
|
||||
const descriptions = document.getElementsByClassName("addBookTipDescription");
|
||||
for (const element of descriptions)
|
||||
{
|
||||
if (element == null) // null or undefined.
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
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)";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
setInterval(userscript_expand_hover_description, 1000);
|
||||
|
|
Loading…
Reference in New Issue
Block a user