Greasy Fork

Mutual and suscribe to youself on osu!

Allows you to mutual and subscribe to your own osu profile

当前为 2023-08-21 提交的版本,查看 最新版本

// ==UserScript==
// @name         Mutual and suscribe to youself on osu!
// @namespace    osu
// @version      2.0.0
// @description  Allows you to mutual and subscribe to your own osu profile
// @author       Magnus Cosmos
// @include      https://osu.ppy.sh/*
// @require      https://greasyfork.org/scripts/441010-osupageobserver/code/OsuPageObserver.js
// ==/UserScript==

function getReactFiber(el) {
    return el[Object.keys(el).filter(prop => /__reactFiber/.test(prop))[0]];
}

function getReactProps(el) {
    return el[Object.keys(el).filter(prop => /__reactProps/.test(prop))[0]];
}

const observer = new OsuWebObserver(_, () => {
    const friendButton = document.querySelector(".user-action-button");
    const subscribeButton = document.querySelectorAll(".user-action-button")[1];
    if (friendButton && !friendButton.classList.contains("user-action-button--mutual")) {
        friendButton.classList.add("user-action-button--mutual");
        const state = getReactProps(friendButton).children[1]._owner.stateNode;
        state.followersWithoutSelf++;
    }
    if (subscribeButton && subscribeButton.disabled) {
        subscribeButton.removeAttribute("disabled");
        subscribeButton.onclick = getReactProps(subscribeButton).onClick;
    }
});