[MAL] Additional features

Adds image and torrent search to anime / manga entries.

  1. // ==UserScript==
  2. // @name [MAL] Additional features
  3. // @description Adds image and torrent search to anime / manga entries.
  4. // @version 1.2.0
  5. // @author MetalTxus
  6.  
  7. // @match https://myanimelist.net/anime*
  8. // @match https://myanimelist.net/manga*
  9.  
  10. // @icon https://cdn.myanimelist.net/images/favicon.ico
  11. // @namespace https://gf.qytechs.cn/users/8682
  12. // ==/UserScript==
  13.  
  14. /* globals jQuery */
  15.  
  16. (() => {
  17. 'use strict';
  18.  
  19. const MediaType = {
  20. Anime: { id: '1_2', label: 'anime' },
  21. Manga: { id: '3_1', label: 'manga'}
  22. };
  23.  
  24. const addLinksToSearch = () => {
  25. jQuery('#contentWrapper h1.title-name, #contentWrapper h1 span[itemprop="name"]').each(function (i, element) {
  26. element = jQuery(element);
  27.  
  28. const mediaType = location.href.indexOf('https://myanimelist.net/anime') > -1 ? MediaType.Anime : MediaType.Manga;
  29.  
  30. const isMultiLine = element.html().includes('<br>');
  31. const title = isMultiLine ? element.html().split('<br>')[0] : element.text();
  32.  
  33. const searchWrapper = jQuery(`<div class="custom-search-wrapper"></div>`);
  34.  
  35. const picturesAnchor = jQuery(`<a href="https://www.google.es/search?tbm=isch&q=${encodeURI(title)} ${mediaType.label}"></a>`);
  36. const picturesIcon = jQuery(`<i class="fa fa-picture-o" title="Search for pictures"></i>`);
  37. appendSearchAnchor(searchWrapper, picturesAnchor, picturesIcon);
  38.  
  39. const torrentSearch = `https://nyaa.si/?f=0&s=seeders&o=desc&c=${mediaType.id}&q=${encodeURI(title)}`;
  40. const torrentAnchor = jQuery(`<a href="${torrentSearch}"></a>`);
  41. const torrentIcon = jQuery(`<i class="fa-solid fa-magnet" title="Search for torrents"></i>`);
  42. appendSearchAnchor(searchWrapper, torrentAnchor, torrentIcon);
  43.  
  44. const hsAnchor = jQuery(`<a href="${torrentSearch} SubsPlease 720"></a>`);
  45. const hsIcon = jQuery(`<i class="fa-solid fa-s" title="Search for SubsPlease torrents"></i>`);
  46. appendSearchAnchor(searchWrapper, hsAnchor, hsIcon);
  47.  
  48. isMultiLine ? element.find('br').before(searchWrapper) : element.append(searchWrapper);
  49. });
  50. }
  51.  
  52. const appendSearchAnchor = (container, anchor, icon) => {
  53. anchor.append(icon);
  54. container.append(' ', anchor);
  55. }
  56.  
  57. const appendStyles = () => {
  58. jQuery(`
  59. <style>
  60. .custom-search-wrapper {
  61. display: inline-block;
  62. font-size: 0;
  63. padding: 0 4px;
  64. }
  65.  
  66. .custom-search-wrapper a {
  67. box-sizing: border-box;
  68. display: inline-block;
  69. font-size: 16px;
  70. text-align: center;
  71. text-decoration: none;
  72. transition: .3s;
  73. width: 24px;
  74. }
  75.  
  76. .custom-search-wrapper a:hover {
  77. color: rgba(80, 116, 200, .9);
  78. }
  79. </style>
  80. `).appendTo('head');
  81. }
  82.  
  83. const initialize = () => {
  84. appendStyles();
  85. addLinksToSearch();
  86. }
  87.  
  88. initialize();
  89. })();

QingJ © 2025

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