omdbButtonAdder

Adds "Rate on OMDB" button on osu! beatmap pages

As of 2023-01-04. See the latest version.

// ==UserScript==
// @name         omdbButtonAdder
// @namespace    omdbButtonAdder
// @version      1
// @author       cyndifusic
// @run-at       document-start
// @description  Adds "Rate on OMDB" button on osu! beatmap pages

// @include   http://osu.ppy.sh*
// @include   https://osu.ppy.sh*
// ==/UserScript==

var addButton = function() {
	var currentURL = window.location.href;
  var startIndex = currentURL.indexOf("beatmapsets") + 12;
  var go = true;
  var i = startIndex;
  var setID = "";
  while (go) {
      if (currentURL.charAt(i) == "#") {
          go = false;
      } else {
          setID += currentURL.charAt(i);
          i++;
      }
  }
  var omdbAddress = "https://omdb.nyahh.net/mapset/" + setID;

  var buttonsDiv = document.getElementsByClassName("beatmapset-header__buttons")[0];
  buttonsDiv.innerHTML += '<a class="btn-osu-big btn-osu-big--beatmapset-header" href="' + omdbAddress + '" data-turbolinks="false" target="_blank"><span class="btn-osu-big__content"><span class="btn-osu-big__left"><span class="btn-osu-big__text-top">Rate on OMDB</span></span><span class="btn-osu-big__icon"><span class="fa fa-fw"><span class="fas fa-download"></span></span></span></span></a>';
}

setTimeout(addButton, 1000);