Roblox Library Spam Trasher

Automatically hides free robux bot spam comments in Roblox library.

  1. // ==UserScript==
  2. // @name Roblox Library Spam Trasher
  3. // @namespace RBXSpamTrasher
  4. // @version 1.0
  5. // @description Automatically hides free robux bot spam comments in Roblox library.
  6. // @author Author
  7. // @match https://www.roblox.com/library/*/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13. var loadStep = 20; //The target number of non-spam comments to load before stopping
  14.  
  15. var spamStrictness = 3;
  16. // Spam strictness levels:
  17. // 0 - blocks nothing, all bot spam is visible
  18. // 1 - blocks only bot spam, does not block any human spam
  19. // 2 - blocks bot spam and human bot-related spam, such as "HEY SCAMMERS,DID YOU GET YER ROBUX?"
  20. // 3 - blocks bot spam and a bunch of human spam, such as "if you are reading this you will die in the next hour if you post this on another item tomorrow will be the best day of your life"
  21. var botSpam = [
  22. "that means you're qualified",
  23. "Want ROBUX?",
  24. "No info or downloads",
  25. "Instantly receive your ",
  26. "Just get a code, and redeem here",
  27. "You're eligible for BUX",
  28. "Processed Instantly for tons of",
  29. "Visit the link: ",
  30. "Go see the link: ",
  31. "Redeem your BUX now",
  32. "No details needed! Unlock",
  33. "Go to the link: ",
  34. "New rewards site with instant BUX and passes",
  35. "finish a quick offer to get the option",
  36. "ROBUX piles coming your way",
  37. "Unlock ALL Game VIP",
  38. "rewardbuddy",
  39. "instantreward",
  40. "Want Thousands of ROBUX Instantly Free of Cost Too",
  41. "Go To The Following Link: ",
  42. "ABSOLUTELY No Login Info Needed",
  43. "Celebrate 2018 with FREE Game Passes to EVERY Game!",
  44. "Instantly receive Codes for ROBUX",
  45. "You are eligible to receive Thousands of ROBUX Instantly",
  46. "Get your full redemption code before its too late!",
  47. "I got thousands of ROBUX just by entering those redemption codes no INFO was asked for AT ALL",
  48. "Thats right THOUSANDS OF ROBUX, no account inoformation, NO DOWNLOAD, simply get your full redemption codes",
  49. "‌[‌W‌O‌R‌K‌‌S‌] ‌Ge‌t ‌‌R‌$ ‌ju‌st ‌‌ ‌ente‌‌r y‌‌our na‌‌me @‌ "
  50. ]; // Bot spam blacklist. You can add more if you wish. Don't forget the comma
  51. var botRelatedHumanSpam = [
  52. "💙Don't be fooled for scams",
  53. "HEY SCAMMERS,DID YOU GET YER ROBUX",
  54. "Copy and paste this everywhere you can to save ROBLOX from SCAMMERS",
  55. "Copy and paste this everywhere! The word must be spread",
  56. "POST THIS EVERYWHERE TO STOP HACKERS AND SPAMMERS",
  57. "Copy and paste this everywhere you can to save our 💚",
  58. "Copy and paste this everywhere so you can save our wonderful Roblox",
  59. "COPY AND PASTE THIS AS QUICK AS POSSIBLE BEFORE YOU OR YOUR FRIENDS ACCOUNTS GETS STOLEN",
  60. "Copy and paste this to save our wonderful roblox",
  61. "Simply don’t go to the link 👉: SCAM",
  62. "Because your...👉 FAKE!!!",
  63. "Copy and paste this everywhere so you can save our world",
  64. "Copy and paste this everywhere to save the ROBLOX we love",
  65. "🍀Do you want your account TAKEN?🍀",
  66. "🍀Do you want NO ROBUX?🍀",
  67. "Instant redemption!🍀 💚Redeem Never!",
  68. "👉Simply go to the link👉: "
  69. ] // Bot-related human spam blacklist. You can add more if you wish. Don't forget the comma
  70. var humanSpam = [
  71. "reading",
  72. "▒█▀▀▀▒█..░▒█▒█▀▀█",
  73. "You will die in the next hour",
  74. "you will die in the next hou",
  75. "you will die in the next hour",
  76. "Hold your breath, cross your legs, and don't breathe or uncross your legs until you post this on another audio"
  77. ]; // Human spam blacklist. You can add more if you wish. Don't forget the comma
  78.  
  79. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  80.  
  81. // Check if comments are even enabled before continuing
  82. if(document.getElementById("AjaxCommentsContainer") == null){
  83. return 0;
  84. }
  85.  
  86.  
  87. // Create our blacklist array that contains the correct values.
  88. var spamContains = [];
  89. if(spamStrictness > 0){
  90. spamContains = spamContains.concat(botSpam);
  91. }
  92. if(spamStrictness > 1){
  93. spamContains = spamContains.concat(botRelatedHumanSpam);
  94. }
  95. if(spamStrictness > 2){
  96. spamContains = spamContains.concat(humanSpam);
  97. }
  98.  
  99. // Hide the default comment template to avoid bot spam comments flashing then quickly disappearing when the script hides it.
  100. Array.from(document.getElementsByClassName("comments-item-template")).forEach(function(element, index, array){
  101. element.getElementsByTagName("div")[0].style.display = 'none';
  102. });
  103.  
  104.  
  105. var cln;
  106.  
  107. function initializeFakeLoader(){ // Creates a second loading animation that we have more control over and prevents the regular one from appearing
  108. // This is necessary because the original loading animation pops up and disappears as more comments are loaded, and we don't want it to be constantly flashing, disappearing and re-appearing
  109.  
  110. // Hide any loading animations already in display
  111. Array.from(document.getElementsByClassName("loading-animated")).forEach(function(element, index, array) {
  112. element.style.display = 'none';
  113. });
  114.  
  115. // Set the template to be invisible and create our second loading animation clone
  116. Array.from(document.getElementsByClassName("loader-template")).forEach(function(element, index, array) {
  117. cln = element.getElementsByTagName("div")[0].cloneNode(true);
  118. element.getElementsByTagName("div")[0].style.display = 'none';
  119. });
  120.  
  121. // Insert the second loading animation in the correct position and un-hide it
  122. var contain = document.getElementById("AjaxCommentsContainer").getElementsByTagName("div")[1]
  123. contain.insertBefore(cln, contain.childNodes[6]);
  124. cln.style.display = '';
  125.  
  126. // Hide the "Show more" button while loading as it's not necessary
  127. Array.from(document.getElementsByClassName("btn-control-sm rbx-comments-see-more")).forEach(function(element, index, array) {
  128. element.style.visibility = 'hidden';
  129. });
  130. }
  131.  
  132. initializeFakeLoader();
  133. var stillLoading = true;
  134. var iters = 0;
  135. var nonSpam = 0;
  136.  
  137. // Make the "Show more" button start loading via our script again
  138. Array.from(document.getElementsByClassName("btn-control-sm rbx-comments-see-more")).forEach(function(element, index, array) {
  139. element.onclick = function(){
  140. if((!(element.classList.contains("hidden"))) && nonSpam >= loadStep){
  141. nonSpam = 0;
  142. iters = 0;
  143. stillLoading = true;
  144. initializeFakeLoader();
  145. }
  146. };
  147. });
  148.  
  149.  
  150.  
  151. // Repeat every 0.75s. There's probably a better way to do this but this works fine too
  152. setInterval(function() {
  153. // Remove our second loading animation and restore the show more button if we've loaded enough comments.
  154. if((!stillLoading) && (cln.parentNode)){
  155. cln.parentNode.removeChild(cln);
  156. Array.from(document.getElementsByClassName("loader-template")).forEach(function(element, index, array) {
  157. element.getElementsByTagName("div")[0].style.display = '';
  158. });
  159. Array.from(document.getElementsByClassName("btn-control-sm rbx-comments-see-more")).forEach(function(element, index, array) {
  160. element.style.visibility = '';
  161. });
  162. }
  163.  
  164. // Click the show more button automatically to make Roblox load more comments if we haven't loaded enough yet.
  165. Array.from(document.getElementsByClassName("btn-control-sm rbx-comments-see-more")).forEach(function(element, index, array) {
  166. if ((!(element.classList.contains("hidden"))) && nonSpam < loadStep) {
  167. iters++;
  168. element.click();
  169. stillLoading = true
  170. }else{
  171. stillLoading = false
  172. }
  173. });
  174.  
  175. // Check comments for spam
  176. Array.from(document.getElementsByClassName("comment-content list-content")).forEach(function(element, index, array) {
  177. if(element.alreadyCheck != "true"){
  178. var isSpam = false;
  179. spamContains.forEach(function(a, b, c){
  180. if (element.innerHTML.indexOf(a)>=0){
  181. element.parentNode.parentNode.style.display = 'none';
  182. isSpam = true;
  183. }
  184. });
  185.  
  186. // The comment template has the word "text" in it and we don't want to un-hide it
  187. if(element.innerHTML == "text"){
  188. isSpam = true;
  189. }
  190.  
  191. if (isSpam == false){
  192. nonSpam++;
  193. element.parentNode.parentNode.style.display = '';
  194. }
  195. element.alreadyCheck = "true";
  196. }
  197. });
  198. }, 750);
  199. })();