Greasy Fork

Greasy Fork is available in English.

Roblox duplicate games remover

Removes duplicate game entries from the games section

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Roblox duplicate games remover
// @namespace    billy donjon gang
// @version      1.01
// @description  Removes duplicate game entries from the games section
// @author       billy#0182
// @match        https://www.roblox.com/games*
// @grant        none
// @run-at       document-idle
// ==/UserScript==

/* jshint esversion: 6 */

(function() {
    function checkDupe(memory, id) {
        if (memory.find(elem => elem === id)) {
            //console.log("dupe " + id);
            return true;
        }
        memory.push(id);
        return false;
    }
    function onNodeAdded(memory, mutationsList) {
        for (let mutation of mutationsList) {
            if (mutation.addedNodes.length > 0 && mutation.addedNodes[0].className == "game-card game-tile") {
                const element = mutation.addedNodes[0];
                if (checkDupe(memory, element.firstElementChild.firstElementChild.id)) {
                    element.remove();
                }
            }
        }
    }
    function init(memory, grid) {
        for (let child of grid.children) {
            if (checkDupe(memory, child.firstElementChild.firstElementChild.id)) {
                child.remove();
            }
        }
        const observer = new MutationObserver(function(mutList) { onNodeAdded(memory, mutList); });
        window.addEventListener('popstate', (event) => { memory = []; observer.disconnect(); }, { once: true });
        observer.observe(grid, {childList: true});
    }
    function checkForGrid(memory, mutationsList, observer) {
        for (let mutation of mutationsList) {
            if (mutation.addedNodes.length > 0 && mutation.addedNodes[0].className === "games-list-container") {
                init(memory, mutation.addedNodes[0].querySelector(".game-grid-container"));
                observer.disconnect();
            }
        }
    }
    async function run(){
        var memory = [];
        const nodeAddedObserver = new MutationObserver((mutList, observer) => { checkForGrid(memory, mutList, observer); });
        window.addEventListener('popstate', (event) => { nodeAddedObserver.disconnect(); }, { once: true });
        nodeAddedObserver.observe(document.body, {subtree: true, childList: true});
        const gameGrid = document.querySelector(".game-grid-container");
        if (gameGrid) {
            init(memory, gameGrid);
        }
    }
    window.addEventListener('popstate', (event) => { run(); });
    run();
})();