Roblox duplicate games remover

Removes duplicate game entries from the games section

  1. // ==UserScript==
  2. // @name Roblox duplicate games remover
  3. // @namespace billy donjon gang
  4. // @version 1.01
  5. // @description Removes duplicate game entries from the games section
  6. // @author billy#0182
  7. // @match https://www.roblox.com/games*
  8. // @grant none
  9. // @run-at document-idle
  10. // ==/UserScript==
  11.  
  12. /* jshint esversion: 6 */
  13.  
  14. (function() {
  15. function checkDupe(memory, id) {
  16. if (memory.find(elem => elem === id)) {
  17. //console.log("dupe " + id);
  18. return true;
  19. }
  20. memory.push(id);
  21. return false;
  22. }
  23. function onNodeAdded(memory, mutationsList) {
  24. for (let mutation of mutationsList) {
  25. if (mutation.addedNodes.length > 0 && mutation.addedNodes[0].className == "game-card game-tile") {
  26. const element = mutation.addedNodes[0];
  27. if (checkDupe(memory, element.firstElementChild.firstElementChild.id)) {
  28. element.remove();
  29. }
  30. }
  31. }
  32. }
  33. function init(memory, grid) {
  34. for (let child of grid.children) {
  35. if (checkDupe(memory, child.firstElementChild.firstElementChild.id)) {
  36. child.remove();
  37. }
  38. }
  39. const observer = new MutationObserver(function(mutList) { onNodeAdded(memory, mutList); });
  40. window.addEventListener('popstate', (event) => { memory = []; observer.disconnect(); }, { once: true });
  41. observer.observe(grid, {childList: true});
  42. }
  43. function checkForGrid(memory, mutationsList, observer) {
  44. for (let mutation of mutationsList) {
  45. if (mutation.addedNodes.length > 0 && mutation.addedNodes[0].className === "games-list-container") {
  46. init(memory, mutation.addedNodes[0].querySelector(".game-grid-container"));
  47. observer.disconnect();
  48. }
  49. }
  50. }
  51. async function run(){
  52. var memory = [];
  53. const nodeAddedObserver = new MutationObserver((mutList, observer) => { checkForGrid(memory, mutList, observer); });
  54. window.addEventListener('popstate', (event) => { nodeAddedObserver.disconnect(); }, { once: true });
  55. nodeAddedObserver.observe(document.body, {subtree: true, childList: true});
  56. const gameGrid = document.querySelector(".game-grid-container");
  57. if (gameGrid) {
  58. init(memory, gameGrid);
  59. }
  60. }
  61. window.addEventListener('popstate', (event) => { run(); });
  62. run();
  63. })();