joe
All checks were successful
Deploy App / docker (ubuntu-latest, 2.44.0, 17, 3.8.5) (push) Successful in 1m19s
All checks were successful
Deploy App / docker (ubuntu-latest, 2.44.0, 17, 3.8.5) (push) Successful in 1m19s
This commit is contained in:
parent
b08961adf8
commit
4cd6c27b2b
@ -0,0 +1,71 @@
|
||||
// ==UserScript==
|
||||
// @name ScoreSaber Utils
|
||||
// @namespace https://ssu.fascinated.cc
|
||||
// @version 1.0.0
|
||||
// @description Useful additions to ScoreSaber!
|
||||
// @author Fascinated
|
||||
// @match https://scoresaber.com/*
|
||||
// @icon https://www.google.com/s2/favicons?sz=64&domain=scoresaber.com
|
||||
// @license MIT
|
||||
// @run-at document-end
|
||||
// @updateURL https://git.fascinated.cc/Fascinated/ScoreSaberUtils-Backend/raw/branch/master/scoresaber-utils.user.js
|
||||
// @downloadURL https://git.fascinated.cc/Fascinated/ScoreSaberUtils-Backend/raw/branch/master/scoresaber-utils.user.js
|
||||
// @grant none
|
||||
// ==/UserScript==
|
||||
|
||||
/**
|
||||
* Fetches the player from ScoreSaber Utils.
|
||||
*
|
||||
* @param {string} id the player's ID
|
||||
* @returns the player's data
|
||||
*/
|
||||
async function fetchPlayer(id) {
|
||||
const response = await fetch(`https://ssu.fascinated.cc/account/${id}`);
|
||||
return await response.json();
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the player page logic.
|
||||
*/
|
||||
async function playerPage() {
|
||||
const id = window.location.pathname.split("/")[2];
|
||||
const player = await fetchPlayer(id);
|
||||
|
||||
addStat(
|
||||
"+1 PP",
|
||||
player.rawPerGlobalPerformancePoints.toFixed(2) + "pp",
|
||||
"The amount of pp to increase the global pp by 1pp"
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Inserts a stat into the player's stats.
|
||||
*
|
||||
* @param {string} stat The stat name
|
||||
* @param {string} value The stat value
|
||||
* @param {string} hoverText The hover text
|
||||
*/
|
||||
function addStat(stat, value, hoverText) {
|
||||
const statsElement = document.getElementsByClassName("stats-container")[0];
|
||||
const svelteClass = statsElement.getAttribute("class").split(" ")[1];
|
||||
|
||||
const statElement = document.createElement("div");
|
||||
statElement.className = `stat-item ${svelteClass}`;
|
||||
statElement.innerHTML = `
|
||||
<span class="stat-title ${svelteClass}">${stat}</span>
|
||||
<span class="stat-spacer ${svelteClass}"></span>
|
||||
<span class="stat-content ${svelteClass} has-hover" title="${hoverText}">${value}</span>
|
||||
`;
|
||||
statsElement.appendChild(statElement);
|
||||
}
|
||||
|
||||
(function async() {
|
||||
"use strict";
|
||||
|
||||
const path = window.location.pathname;
|
||||
const isPlayerPage = path.startsWith("/u/");
|
||||
|
||||
if (isPlayerPage) {
|
||||
playerPage();
|
||||
}
|
||||
})();
|
Loading…
x
Reference in New Issue
Block a user