MyAnimeList(MAL) - Search Filter

This script hides search results that you already have on your list

当前为 2016-06-12 提交的版本,查看 最新版本

  1. // MAL Search Filter!
  2. // version 1.2
  3. // 2010-06-14
  4. // Copyright (c) 2009, Bastvera <bastvera@gmail.com>
  5. // Released under the GPL license
  6. // http://www.gnu.org/copyleft/gpl.html
  7. //
  8. // --------------------------------------------------------------------
  9. //
  10. // This is a Greasemonkey user script.
  11. //
  12. // To install, you need Greasemonkey: http://greasemonkey.mozdev.org/
  13. // Then restart Firefox and revisit this script.
  14. // Under Tools, there will be a new menu item to "Install User Script".
  15. // Accept the default configuration and install.
  16. //
  17. // To uninstall, go to Tools/Manage User Scripts,
  18. // select "MAL Search Filter", and click Uninstall.
  19. //
  20. // --------------------------------------------------------------------
  21. //
  22. // ==UserScript==
  23. // @name MyAnimeList(MAL) - Search Filter
  24. // @namespace http://thayanger.neostrada.pl
  25. // @include http://myanimelist.net/anime.php?*
  26. // @include http://myanimelist.net/manga.php?*
  27. // @include http://myanimelist.net/anime/genre/*
  28. // @include http://myanimelist.net/manga/genre/*
  29. // @include http://myanimelist.net/anime/producer/*
  30. // @include http://myanimelist.net/manga/magazine/*
  31. // @exclude http://myanimelist.net/anime.php?id=*
  32. // @exclude http://myanimelist.net/manga.php?id=*
  33. // @description This script hides search results that you already have on your list
  34. // @version 1.2.6
  35. // @author Bastvera <bastvera@gmail.com>, Cpt_mathix <fixed script>
  36. // ==/UserScript==
  37.  
  38. //Anchor for checkbox
  39. var allElements = document.evaluate(
  40. "//*[@id='content']/div[contains(@class,'normal_header')]",
  41. document,
  42. null,
  43. XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,
  44. null);
  45.  
  46. var AnchorLink = allElements.snapshotItem(0);
  47.  
  48. if(AnchorLink !== null){
  49.  
  50. //Element Placing
  51. var newElement;
  52. newElement = document.createElement('BR');
  53. AnchorLink.appendChild(newElement);
  54.  
  55. var checkbox = document.createElement('input');
  56. checkbox.type = 'checkbox';
  57. AnchorLink.appendChild(checkbox);
  58.  
  59. newElement = document.createElement('label');
  60. newElement.setAttribute('for','firstName');
  61. newElement.appendChild(document.createTextNode('Hide Search Results that you have on your list.'));
  62. AnchorLink.appendChild(newElement);
  63. newElement.style.fontWeight="normal";
  64. newElement.style.fontSize="10px";
  65.  
  66. //Anime list entries search
  67. allElements = document.evaluate(
  68. "//a[contains(@class,'Lightbox_AddEdit button_edit')]",
  69. document,
  70. null,
  71. XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
  72. null);
  73.  
  74. //Get or Set status of checkbox
  75. var checkboxmem = (localStorage.getItem('checkboxmem_search') === "true"); //Get chceckbox status
  76. if(checkboxmem === null){
  77. checkboxmem=false;
  78. localStorage.setItem('checkboxmem_search', checkboxmem);
  79. checkbox.checked=checkboxmem;
  80. }
  81. else{
  82. checkbox.checked=checkboxmem;
  83. if(checkbox.checked === true)
  84. HideDivs();
  85. }
  86.  
  87. //Listener
  88. checkbox.addEventListener('change',function () {
  89.  
  90. if(checkbox.checked === true){
  91. HideDivs();
  92. }
  93.  
  94. if(checkbox.checked === false){
  95. ShowDivs();
  96. }
  97.  
  98. localStorage.setItem('checkboxmem_search', checkbox.checked);
  99.  
  100. },false);
  101. }
  102.  
  103. function HideDivs(){
  104. for (var i = 0; i < allElements.snapshotLength; i++){
  105. var EditLink = allElements.snapshotItem(i);
  106. if (EditLink.parentNode.parentNode.parentNode.classList.contains("js-seasonal-anime"))
  107. EditLink.parentNode.parentNode.parentNode.style.display="none";
  108. else
  109. EditLink.parentNode.parentNode.style.display="none";
  110. }
  111. }
  112.  
  113. function ShowDivs(){
  114. for (var i = 0; i < allElements.snapshotLength; i++){
  115. var EditLink = allElements.snapshotItem(i);
  116. if (EditLink.parentNode.parentNode.parentNode.classList.contains("js-seasonal-anime"))
  117. EditLink.parentNode.parentNode.parentNode.removeAttribute('style');
  118. else
  119. EditLink.parentNode.parentNode.removeAttribute('style');
  120. }
  121. }