Anilist more links (MAL/AniDB)

adds links to anilist/mal site to anilist (uses just the duckduckgo I'm feeling ducky feature with the anime name)

  1. // ==UserScript==
  2. // @name Anilist more links (MAL/AniDB)
  3. // @namespace https://github.com/Alistair1231/my-userscripts/
  4. // @version 0.5.1
  5. // @description adds links to anilist/mal site to anilist (uses just the duckduckgo I'm feeling ducky feature with the anime name)
  6. // @author Alistair1231
  7. // @match https://anilist.co/*
  8. // @icon https://icons.duckduckgo.com/ip2/anilist.co.ico
  9. // @license MIT
  10. // ==/UserScript==
  11.  
  12. function createButton(linkcolor="#5B0BB5e0", link, text, iconDomain) {
  13. const anchorTag = document.createElement('a');
  14. anchorTag.setAttribute('data-v-c1b7ee7c', '');
  15. anchorTag.setAttribute('href', link);
  16. anchorTag.setAttribute('target', '_blank');
  17. anchorTag.setAttribute('class', 'external-link');
  18. anchorTag.setAttribute('style', `--link-color:${linkcolor};`);
  19. const divTag = document.createElement('div');
  20. divTag.setAttribute('data-v-c1b7ee7c', '');
  21. divTag.setAttribute('class', 'icon-wrap');
  22. divTag.setAttribute('style', `background:black;`);
  23.  
  24. const imgTag = document.createElement('img');
  25. imgTag.setAttribute('data-v-c1b7ee7c', '');
  26. imgTag.setAttribute('src', 'https://icons.duckduckgo.com/ip2/' + iconDomain + '.ico');
  27. imgTag.setAttribute('class', 'icon');
  28. // min-width: 25px;
  29. imgTag.style.minWidth = "25px";
  30. const spanTag = document.createElement('span');
  31. spanTag.setAttribute('data-v-c1b7ee7c', '');
  32. spanTag.setAttribute('class', 'name');
  33. spanTag.textContent = text;
  34. divTag.appendChild(imgTag);
  35. anchorTag.appendChild(divTag);
  36. anchorTag.appendChild(spanTag);
  37. return anchorTag;
  38. }
  39.  
  40. function run() {
  41. // if no external links there, add the div to the sidebar
  42. if (document.querySelectorAll("div.external-links h2~div").length === 0) {
  43. var myDiv = document.createElement("div");
  44. myDiv.setAttribute("data-v-7a1f9df8", "");
  45. myDiv.setAttribute("data-v-1c97ba07", "");
  46. myDiv.setAttribute("class", "external-links");
  47. myDiv.innerHTML = "<h2 data-v-7a1f9df8=\"\">External &amp; Streaming links<\/h2><div data-v-7a1f9df8=\"\" class=\"external-links-wrap\"><\/div>";
  48. document.querySelector("div.sidebar").appendChild(myDiv);
  49. }
  50. var linkBar = document.querySelectorAll("div.external-links h2~div");
  51.  
  52. var name = document.querySelector(".content h1").innerText.replace(':','');
  53. var mal = "https://duckduckgo.com/?q=!myanimelist+" + name;
  54. var malButton = createButton(linkcolor="#5B0BB5e0", link=mal, text="MAL",iconDomain="myanimelist.net");
  55. var anidb = "https://duckduckgo.com/?q=!anidb+" + name;
  56. var anidbButton = createButton(linkcolor="#5B0BB5e0", link=anidb, text="AniDB",iconDomain="anidb.net");
  57. if (document.querySelectorAll("a.external-link[href*='https://duckduckgo.']").length === 0) {
  58. linkBar[0].prepend(malButton);
  59. linkBar[0].prepend(anidbButton);
  60. }
  61. }
  62.  
  63.  
  64. function checkReady() {
  65. var contentH1 = document.querySelector(".content h1");
  66. if (contentH1) {
  67. run();
  68. }
  69. else{
  70. console.log("title not loaded, trying again in 200ms");
  71. setTimeout(checkReady, 200);
  72. }
  73. }
  74.  
  75. (function() {
  76. let url;
  77. let lastUrl = location.href;
  78.  
  79. let mutationObserver = new MutationObserver(() => {
  80. url = location.href;
  81. if (url !== lastUrl) {
  82. lastUrl = url;
  83. checkReady();
  84. }
  85. })
  86.  
  87. mutationObserver.observe(document, { subtree: true, childList: true });
  88. checkReady();
  89. })();

QingJ © 2025

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