MyAnimeList(MAL) - Search Filter

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

目前为 2016-03-15 提交的版本。查看 最新版本

  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. // @exclude http://myanimelist.net/anime.php?id=*
  30. // @exclude http://myanimelist.net/manga.php?id=*
  31. // @description This script hides search results that you already have on your list
  32. // @version 1.2.5
  33. // @author Bastvera <bastvera@gmail.com>, Cpt_mathix <fixed script>
  34. // ==/UserScript==
  35.  
  36. //Anchor for checkbox
  37. var allElements = document.evaluate(
  38. "//*[@id='content']/div[contains(@class,'normal_header')]",
  39. document,
  40. null,
  41. XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,
  42. null);
  43.  
  44. var AnchorLink = allElements.snapshotItem(0);
  45.  
  46. if(AnchorLink !== null){
  47.  
  48. //Element Placing
  49. var newElement;
  50. newElement = document.createElement('BR');
  51. AnchorLink.appendChild(newElement);
  52.  
  53. var checkbox = document.createElement('input');
  54. checkbox.type = 'checkbox';
  55. AnchorLink.appendChild(checkbox);
  56.  
  57. newElement = document.createElement('label');
  58. newElement.setAttribute('for','firstName');
  59. newElement.appendChild(document.createTextNode('Hide Search Results that you have on your list.'));
  60. AnchorLink.appendChild(newElement);
  61. newElement.style.fontWeight="normal";
  62. newElement.style.fontSize="10px";
  63.  
  64. //Anime list entries search
  65. allElements = document.evaluate(
  66. "//a[contains(@class,'Lightbox_AddEdit button_edit')]",
  67. document,
  68. null,
  69. XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
  70. null);
  71.  
  72. //Get or Set status of checkbox
  73. var checkboxmem = (localStorage.getItem('checkboxmem_search') === "true"); //Get chceckbox status
  74. if(checkboxmem === null){
  75. checkboxmem=false;
  76. localStorage.setItem('checkboxmem_search', checkboxmem);
  77. checkbox.checked=checkboxmem;
  78. }
  79. else{
  80. checkbox.checked=checkboxmem;
  81. if(checkbox.checked == true)
  82. HideDivs();
  83. }
  84.  
  85. //Listener
  86. checkbox.addEventListener('change',function () {
  87.  
  88. if(checkbox.checked == true){
  89. HideDivs();
  90. }
  91.  
  92. if(checkbox.checked == false){
  93. ShowDivs();
  94. }
  95.  
  96. localStorage.setItem('checkboxmem_search', checkbox.checked);
  97.  
  98. },false)
  99. }
  100.  
  101. function HideDivs(){
  102. for (var i = 0; i < allElements.snapshotLength; i++){
  103. var EditLink = allElements.snapshotItem(i);
  104. if (EditLink.parentNode.parentNode.parentNode.className == "seasonal-anime js-seasonal-anime")
  105. EditLink.parentNode.parentNode.parentNode.style.display="none";
  106. else
  107. EditLink.parentNode.parentNode.style.display="none";
  108. }
  109. }
  110.  
  111. function ShowDivs(){
  112. for (var i = 0; i < allElements.snapshotLength; i++){
  113. var EditLink = allElements.snapshotItem(i);
  114. if (EditLink.parentNode.parentNode.parentNode.className == "seasonal-anime js-seasonal-anime")
  115. EditLink.parentNode.parentNode.parentNode.removeAttribute('style');
  116. else
  117. EditLink.parentNode.parentNode.removeAttribute('style');
  118. }
  119. }