LibraryThing WorldCat direct link

Makes a "direct" link to the work on WorldCat, similar to how the Amazon.com direct links works

  1. // ==UserScript==
  2. // @name LibraryThing WorldCat direct link
  3. // @namespace https://gf.qytechs.cn/en/users/11592-max-starkenburg
  4. // @description Makes a "direct" link to the work on WorldCat, similar to how the Amazon.com direct links works
  5. // @include http*://*librarything.tld/work/*
  6. // @include http*://*librarything.com/work/*
  7. // @version 3
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. var metas = document.getElementsByTagName("meta");
  12. var ltworkisbn = document.getElementById("ltworkisbn");
  13. var isbn = "9781111111111"; // 9781111111111 is apparently what LT puts on ISBN-less works
  14. if (ltworkisbn) {
  15. isbn = ltworkisbn.textContent;
  16. }
  17. if (isbn == "9781111111111") {
  18. for (var i=0; i<metas.length; i++) {
  19. if (metas[i].getAttribute("property") == "books:isbn") {
  20. isbn = metas[i].content;
  21. break;
  22. }
  23. }
  24. }
  25. if (isbn != "9781111111111") {
  26. var wcLink = "";
  27. var qls = document.getElementsByClassName("ql_printdisplay_line");
  28. for (var i=0; i<qls.length; i++) {
  29. if (qls[i].getAttribute("bsm_code") == "700:1") {
  30. wcLink = qls[i].getElementsByTagName("a")[1]; // the first link is the icon
  31. break;
  32. }
  33. }
  34. if (wcLink != "") {
  35. var direct = document.createElement('span');
  36. direct.innerHTML = ' (<a href="http://worldcat.org/isbn/' + isbn + '">direct</a>)';
  37. wcLink.parentNode.insertBefore(direct, wcLink.nextSibling);
  38. }
  39. }

QingJ © 2025

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