omdbButtonAdder

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

Tính đến 05-01-2023. Xem phiên bản mới nhất.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

Bạn sẽ cần cài đặt một tiện ích mở rộng như Tampermonkey hoặc Violentmonkey để cài đặt kịch bản này.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(Tôi đã có Trình quản lý tập lệnh người dùng, hãy cài đặt nó!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         omdbButtonAdder
// @namespace    omdbButtonAdder
// @version      1.02
// @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 currentURL = window.location.href;

var addButton = function() {
  console.log(currentURL.includes("beatmapsets"));
  if (currentURL.includes("beatmapsets") && currentURL.includes("#") && !currentURL.includes("#taiko") && !currentURL.includes("#fruits") && !currentURL.includes("#mania")) {
    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-link"></span></span></span></span></a>';
  }
}

var checkURL = function() {
  var doubleCheck = function() {
 		if (window.location.href != currentURL) {
    	currentURL = window.location.href;
    	addButton();
  	}
  }
  
  setTimeout(doubleCheck, 2000);
}

setTimeout(addButton, 1000);
document.addEventListener("click", checkURL);