Mutual and suscribe to youself on osu!

Allows you to mutual and subscribe to your own osu profile

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Mutual and suscribe to youself on osu!
// @namespace    osu
// @version      2.0.7
// @description  Allows you to mutual and subscribe to your own osu profile
// @author       Magnus Cosmos
// @match        https://osu.ppy.sh/*
// @match        https://lazer.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]];
}

function staticFn() {}

let osuCore, document;
if (unsafeWindow) {
  osuCore = unsafeWindow.osuCore;
  document = unsafeWindow.document;
}

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