Mutual and suscribe to youself on osu!

Allows you to mutual and subscribe to your own osu profile

  1. // ==UserScript==
  2. // @name Mutual and suscribe to youself on osu!
  3. // @namespace osu
  4. // @version 2.0.7
  5. // @description Allows you to mutual and subscribe to your own osu profile
  6. // @author Magnus Cosmos
  7. // @match https://osu.ppy.sh/*
  8. // @match https://lazer.ppy.sh/*
  9. // @require https://greasyfork.org/scripts/441010-osupageobserver/code/OsuPageObserver.js
  10. // ==/UserScript==
  11.  
  12. function getReactFiber(el) {
  13. return el[Object.keys(el).filter(prop => /__reactFiber/.test(prop))[0]];
  14. }
  15.  
  16. function getReactProps(el) {
  17. return el[Object.keys(el).filter(prop => /__reactProps/.test(prop))[0]];
  18. }
  19.  
  20. function staticFn() {}
  21.  
  22. let osuCore, document;
  23. if (unsafeWindow) {
  24. osuCore = unsafeWindow.osuCore;
  25. document = unsafeWindow.document;
  26. }
  27.  
  28. const observer = new OsuWebObserver(staticFn, () => {
  29. if (osuCore.currentUser) {
  30. const friendButton = document.querySelector(".user-action-button");
  31. const subscribeButton = document.querySelectorAll(".user-action-button")[1];
  32. if (friendButton && !friendButton.classList.contains("user-action-button--mutual")) {
  33. const state = getReactProps(friendButton).children[1]._owner.stateNode;
  34. if (state.props.userId === osuCore.currentUser.id) {
  35. friendButton.classList.add("user-action-button--mutual");
  36. state.followersWithoutSelf++;
  37. }
  38. }
  39. if (subscribeButton && subscribeButton.disabled) {
  40. subscribeButton.removeAttribute("disabled");
  41. subscribeButton.onclick = getReactProps(subscribeButton).onClick;
  42. }
  43. }
  44. });