MyAnimeList (MAL) Hide User Posts

Annoying user posts? Block / hide them!

当前为 2015-03-27 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name MyAnimeList (MAL) Hide User Posts
  3. // @namespace http://rainulf.ca/userscripts
  4. // @description Annoying user posts? Block / hide them!
  5. // @include http://*myanimelist.net/forum/?topicid=*
  6. // @require https://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js
  7. // @require http://gf.qytechs.cn/scripts/2855/code/GM_config.js
  8. // @grant none
  9. // @version 1.1.2
  10. // ==/UserScript==
  11.  
  12. $.noConflict();
  13.  
  14. GM_config.init("MAL Hide User Posts - Settings", {
  15. 'blockedUsers': {
  16. 'section': ['Hide user posts', 'Enter one user per line please?'],
  17. 'type': 'textarea',
  18. 'default': '',
  19. 'cols': 20,
  20. 'rows': 10
  21. }
  22. });
  23.  
  24.  
  25.  
  26. var malHide = (function() {
  27. var blockedUsers = [], hiddenPosts = 0
  28. , // -->
  29.  
  30. Init = function() {
  31. var confText = GM_config.get('blockedUsers');
  32. blockedUsers = confText.split("\n");
  33. jQuery("#myanimelist").append(jQuery("<div></div>")
  34. .attr("id", "malHideButtons")
  35. .attr("style", "position:fixed;bottom:0;right:0;"));
  36.  
  37. jQuery("#malHideButtons").append(jQuery("<button></button>")
  38. .attr("class", "inputButton")
  39. .text("MAL Hide Settings")
  40. .click(function(){
  41. GM_config.open();
  42. })
  43. );
  44.  
  45. traversePosts();
  46. },
  47.  
  48. isBlocked = function(username) {
  49. var i = 0;
  50.  
  51. for(i in blockedUsers) {
  52. if(blockedUsers[i] === username) {
  53. return true;
  54. }
  55. }
  56. return false;
  57. },
  58.  
  59. traversePosts = function() {
  60. jQuery(".forum_border_around").each(function(index){
  61. var currentUsername = "", temp = "";
  62.  
  63. currentUsername = jQuery("table tr td div a strong", this).text();
  64. // Posts of blocked users
  65. if(isBlocked(currentUsername)) {
  66. hiddenPosts++;
  67. jQuery(this).attr("class", "toHide");
  68. // Hide em
  69. jQuery(this).toggle();
  70. // Set grey bg
  71. jQuery("table tr *", this).css("background-color", "#808080");
  72. // Add fancy to unhide button
  73. jQuery("table tr td:eq(0)", this)
  74. .append("<br>")
  75. .append(
  76. jQuery("<button></button>")
  77. .attr("class", "inputButton")
  78. .text("Unhide Posts")
  79. .click(function(){
  80. temp = jQuery(this).parent().find("div a strong").text();
  81. blockedUsers.splice(blockedUsers.indexOf(temp), 1);
  82. GM_config.set('blockedUsers', blockedUsers.join("\n"));
  83. GM_config.open(); // field[i].node is set to null, so it cannot be save directly
  84. })
  85. );
  86. // Posts of non-blocked users
  87. } else {
  88. // Add fancy to hide button
  89. jQuery("table tr td:eq(0)", this)
  90. .append("<br>")
  91. .append(
  92. jQuery("<button></button>")
  93. .attr("class", "inputButton")
  94. .text("Hide Posts")
  95. .click(function(){
  96. temp = jQuery(this).parent().find("div a strong").text();
  97. blockedUsers.push(temp);
  98. GM_config.set('blockedUsers', blockedUsers.join("\n"));
  99. GM_config.open(); // field[i].node is set to null, so it cannot be save directly
  100. })
  101. );
  102. }
  103. });
  104.  
  105. // Add toggle for hidden posts
  106. if(hiddenPosts > 0) {
  107. jQuery("#malHideButtons").append(
  108. jQuery("<button></button>")
  109. .attr("class", "inputButton")
  110. .text("Toggle " + hiddenPosts + " hidden post" + (hiddenPosts > 1 ? "s" : ""))
  111. .click(function(){
  112. jQuery(".toHide").toggle();
  113. })
  114. );
  115. }
  116. }; // <--
  117.  
  118. return {
  119. init: Init
  120. }
  121. })();
  122.  
  123. jQuery(document).ready(function() {
  124. malHide.init();
  125. });

QingJ © 2025

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