LibraryThing blurber author pages

For each of the blurbers listed on a work, this script creates a link to their author page (assumes it exists)

  1. // ==UserScript==
  2. // @name LibraryThing blurber author pages
  3. // @namespace https://gf.qytechs.cn/en/users/11592-max-starkenburg
  4. // @description For each of the blurbers listed on a work, this script creates a link to their author page (assumes it exists)
  5. // @include http*://*.librarything.tld/work/*
  6. // @include http*://*.librarything.com/work/*
  7. // @version 2
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. var blurbers = document.querySelector("[fieldname=blurbers]").getElementsByClassName("fwikiItemText");
  12.  
  13. if (blurbers.length) {
  14. for (var i=0; i<blurbers.length; i++) {
  15. var blurber = blurbers[i];
  16. var string = blurber.textContent.trim();
  17. if (string != "") {
  18. var parens = new RegExp("\\(.*\\)","g");
  19. if (string.replace(parens,"") != "") { // Remove any parenthetical text, unless the string is entirely parenthetical (probably unnecessary for blurbers, but who knows)
  20. string = string.replace(parens,"");
  21. }
  22. if (string.indexOf(",") == -1) { // Since sometimes people have written them as "First Last" instead of "Last, First" (though these should really just be fixed)
  23. var lastspace = string.lastIndexOf(" ");
  24. string = string.substring(lastspace) + string.substring(0,lastspace);
  25. }
  26. string = string.toLowerCase().replace(/[^a-z]/g,"").substring(0,20); // Remove non-alpha character, lower-case it, and limit it to 20 characters
  27. if (string.length) { // Just in case it was all non-Latin characters, whose number generation is a mystery to me
  28. var aLink = document.createElement("span");
  29. aLink.style.cssFloat = "right";
  30. aLink.style.fontSize = ".9em";
  31. aLink.innerHTML = '(<a href="/author/' + string + '">author page</a>)';
  32. blurber.insertBefore(aLink, blurber.firstChild); // Attach it somewhere that won't get in the way while editing
  33. }
  34. }
  35. }
  36. }

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址