osu beatmap filter

filter osu beatmaps by favourites

目前为 2022-03-23 提交的版本。查看 最新版本

// ==UserScript==
// @name         osu beatmap filter
// @namespace    https://gf.qytechs.cn/zh-TW/users/891293
// @version      0.1
// @description  filter osu beatmaps by favourites
// @author       Oscar0159
// @match        https://osu.ppy.sh/beatmapsets
// @match        https://osu.ppy.sh/beatmapsets?*
// @grant        none
// @license      MIT
// ==/UserScript==

var favourite_threshold = 100;

var opacity = "15%";

(function() {
    'use strict';
    window.onload = function() {
        var hasElement = document.querySelector(".beatmapsets__items");
        if (hasElement) {
            main();
        }
    }

    function main(){
        // preload
        document.querySelectorAll(".beatmapsets__item").forEach(
            function(elem) { //beatmapsets__item
                var favourites = elem.childNodes[0].childNodes[1].childNodes[1].childNodes[4].childNodes[0].childNodes[1].textContent;
                if (favourites < favourite_threshold){
                    elem.style.opacity = opacity;
                }
            }
        );

        // afterload
        onAppend(document.querySelector(".beatmapsets__items"), function(added) {
            added[0].childNodes.forEach(
                function(elem) { //beatmapsets__item
                    var favourites = elem.childNodes[0].childNodes[1].childNodes[1].childNodes[4].childNodes[0].childNodes[1].textContent;
                    if (favourites < favourite_threshold){
                        elem.style.opacity = opacity;
                    }
                }
            );
        })
    }

    function onAppend(elem, f) {
        var observer = new MutationObserver(function(mutations) {
            mutations.forEach(function(m) {
                if (m.addedNodes.length) {
                    f(m.addedNodes)
                }
            })
        })
        observer.observe(elem, {childList: true})
    }


})();

QingJ © 2025

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