[MAL] Additional features

Adds image and torrent search for each anime / manga entry, removes search results already on the user's list and removes a few adds.

当前为 2017-05-13 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name [MAL] Additional features
  3. // @description Adds image and torrent search for each anime / manga entry, removes search results already on the user's list and removes a few adds.
  4. // @version 1.0.1
  5. // @author MetalTxus
  6.  
  7. // @include https://myanimelist.net/topanime.php?*
  8. // @include https://myanimelist.net/topmanga.php?*
  9. // @include https://myanimelist.net/anime*
  10. // @include https://myanimelist.net/manga*
  11.  
  12. // @icon https://dl.dropbox.com/s/8m20m7iqc5bz1ke/mal.png
  13. // @namespace https://greasyfork.org/users/8682
  14. // ==/UserScript==
  15.  
  16. (function() {
  17. 'use strict';
  18.  
  19. var MEDIA_TYPE = {
  20. anime: { id: '1_2', label: 'anime' },
  21. manga: { id: '3_1', label: 'manga'}
  22. }, CSS =
  23. '<style>' +
  24. '.custom-search-wrapper a { text-decoration: none; font-size: 16px; transition: .3s;}' +
  25. '.custom-search-wrapper a:hover { color: rgba(80,116,200,.9); }' +
  26. '.fa-magnet::before { content: "\\f076" }' +
  27. '.fa-picture-o::before { content: "\\f03e" }' +
  28. '</style>';
  29.  
  30. function removeResultsInOwnList () {
  31. $('.ranking-list .btn-anime-watch-status:not(.notinmylist)').parents('.ranking-list').remove();
  32. $('.js-block-list [title="Completed"],' +
  33. '.js-block-list [title="Dropped"],' +
  34. '.js-block-list [title="Plan to Watch"]'
  35. ).parents('.js-seasonal-anime, tr').remove();
  36. }
  37.  
  38. function addLinkToSearch () {
  39. $('#contentWrapper h1 span[itemprop="name"]').each(function (i, element) {
  40. element = $(element);
  41.  
  42. var mediaType = location.href.indexOf('https://myanimelist.net/anime') > -1 ? MEDIA_TYPE.anime : MEDIA_TYPE.manga,
  43. title = element.text();
  44.  
  45. var searchWrapper = $('<span class="custom-search-wrapper"></span>');
  46.  
  47. var picturesAnchor = $('<a href="https://www.google.es/search?tbm=isch&q=' + encodeURI(title) + ' ' + mediaType.label + '"></a>');
  48. var picturesIcon = $('<i class="fa fa-picture-o" title="Search for pictures"></i>');
  49. picturesAnchor.append(picturesIcon);
  50. searchWrapper.append(' ', picturesAnchor);
  51.  
  52. var torrentAnchor = $('<a href="https://nyaa.si/?f=0&s=seeders&o=desc&c=' + mediaType.id + '&q=' + encodeURI(title) + '"></a>');
  53. var torrentIcon = $('<i class="fa fa-magnet" title="Search for torrents"></i>');
  54. torrentAnchor.append(torrentIcon);
  55. searchWrapper.append(' ', torrentAnchor);
  56.  
  57. element.append(searchWrapper);
  58. });
  59. }
  60.  
  61. function removeAdds () {
  62. $('[href^="/membership?"]').each(element => $(element).parents('div').eq(0).remove());
  63. $('._unit').each(element => $(element).remove());
  64. }
  65.  
  66. $(CSS).appendTo('head');
  67. setTimeout(removeAdds, 1000);
  68. removeResultsInOwnList();
  69. addLinkToSearch();
  70. })();