Updated
Added documentation to methods Fixed avatars not initially loading Just generally cleaned up the codebase
This commit is contained in:
parent
cfa2d5757f
commit
aac2c7027e
@ -1,7 +1,8 @@
|
|||||||
# Simple ScoreSaber Overlay
|
# ScoreSaber Overlay with real-time data
|
||||||
|
|
||||||
The public url to view/use this is: `https://bs-overlay.fascinated.cc`</br>
|
The public url to view/use this is: `https://bs-overlay.fascinated.cc`</br>
|
||||||
To use your scoresaber: `https://bs-overlay.fascinated.cc/?id=765611`
|
To use your scoresaber: `https://bs-overlay.fascinated.cc/?id=76561198449412074`</br>
|
||||||
|
Support Server: https://discord.gg/4FYVVhZPm7
|
||||||
|
|
||||||
## Getting Started with developent
|
## Getting Started with developent
|
||||||
|
|
||||||
|
BIN
cache/0bf56fa581064964f936833a15d6351f0382a322.jpg
vendored
Normal file
BIN
cache/0bf56fa581064964f936833a15d6351f0382a322.jpg
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 9.2 KiB |
BIN
cache/4bbdaa1004a00eeb9c8d9432640e1c7d490b46d9.jpg
vendored
Normal file
BIN
cache/4bbdaa1004a00eeb9c8d9432640e1c7d490b46d9.jpg
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.5 KiB |
BIN
cache/6423f3a3429d503fa97a1c5282155436d12a9366.jpg
vendored
Normal file
BIN
cache/6423f3a3429d503fa97a1c5282155436d12a9366.jpg
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.9 KiB |
BIN
cache/a79af292ca03aca894e7acc3bd8c3cacfddf2906.jpg
vendored
Normal file
BIN
cache/a79af292ca03aca894e7acc3bd8c3cacfddf2906.jpg
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 8.9 KiB |
@ -2,7 +2,7 @@ import Image from "next/image";
|
|||||||
|
|
||||||
const Avatar = (props) => {
|
const Avatar = (props) => {
|
||||||
return <>
|
return <>
|
||||||
<Image className={'player-avatar'} src={props.url} width={180} height={180} alt={'Avatar image'} />
|
<Image className={'player-avatar'} src={props.url} width={180} height={180} alt={'Avatar image'} loading='lazy'/>
|
||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import ReactCountryFlag from "react-country-flag";
|
import ReactCountryFlag from "react-country-flag";
|
||||||
|
|
||||||
const PlayerStats = (props) => {
|
const PlayerStats = (props) => {
|
||||||
|
|
||||||
return <div className={'player-stats'}>
|
return <div className={'player-stats'}>
|
||||||
<p>{props.pp}pp</p>
|
<p>{props.pp}pp</p>
|
||||||
<p>#{props.globalPos}</p>
|
<p>#{props.globalPos}</p>
|
||||||
|
@ -6,8 +6,14 @@ export default class ScoreStats extends Component {
|
|||||||
super(params);
|
super(params);
|
||||||
}
|
}
|
||||||
|
|
||||||
getAverage(values) {
|
/**
|
||||||
return values.reduce((p, c) => p + c, 0) / values.length;
|
* Returns the average of the provided numbers list
|
||||||
|
*
|
||||||
|
* @param {List<Number>} hitValues
|
||||||
|
* @returns The average value
|
||||||
|
*/
|
||||||
|
getAverage(hitValues) {
|
||||||
|
return hitValues.reduce((p, c) => p + c, 0) / hitValues.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
@ -4,8 +4,7 @@ module.exports = {
|
|||||||
domains: [
|
domains: [
|
||||||
'cdn.scoresaber.com',
|
'cdn.scoresaber.com',
|
||||||
'bs-overlay.fascinated.cc',
|
'bs-overlay.fascinated.cc',
|
||||||
'localhost:3000',
|
'localhost:3000'
|
||||||
''
|
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,12 +4,13 @@ export default async function handler(req, res) {
|
|||||||
const mapHash = req.query.hash;
|
const mapHash = req.query.hash;
|
||||||
|
|
||||||
const mapData = await Utils.getMapData(mapHash.replace("custom_level_", ""));
|
const mapData = await Utils.getMapData(mapHash.replace("custom_level_", ""));
|
||||||
if (mapData === undefined) {
|
if (mapData === undefined) { // Check if a map hash was provided
|
||||||
return res.json({ error: true, message: "Unknown map" })
|
return res.json({ error: true, message: "Unknown map" })
|
||||||
}
|
}
|
||||||
const data = {
|
const data = { // The maps data from the provided map hash
|
||||||
bsr: mapData.id,
|
bsr: mapData.id,
|
||||||
songArt: "http://" + req.headers.host + "/api/beatsaver/art/" + mapHash + "?ext=" + mapData.versions[0].coverURL.split("/")[3].split(".")[1]
|
songArt: "http://" + req.headers.host + "/api/beatsaver/art/" + mapHash + "?ext=" + mapData.versions[0].coverURL
|
||||||
|
.split("/")[3].split(".")[1]
|
||||||
};
|
};
|
||||||
res.json({ error: false, data: data })
|
res.json({ error: false, data: data });
|
||||||
}
|
}
|
||||||
|
@ -176,4 +176,3 @@
|
|||||||
margin-top: 8px;
|
margin-top: 8px;
|
||||||
font-size: large;
|
font-size: large;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,6 +3,13 @@ import Config from '../config.json';
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
BEATSAVER_MAP_API: Config.proxy_url + "/https://api.beatsaver.com/maps/hash/%s",
|
BEATSAVER_MAP_API: Config.proxy_url + "/https://api.beatsaver.com/maps/hash/%s",
|
||||||
// todo: cache map data for 12 hrs
|
// todo: cache map data for 12 hrs
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a specified maps data from BeatSaver
|
||||||
|
*
|
||||||
|
* @param {string} hash
|
||||||
|
* @returns The map data
|
||||||
|
*/
|
||||||
async getMapData(hash) {
|
async getMapData(hash) {
|
||||||
const data = await fetch(this.BEATSAVER_MAP_API.replace("%s", hash), {
|
const data = await fetch(this.BEATSAVER_MAP_API.replace("%s", hash), {
|
||||||
headers: {
|
headers: {
|
||||||
|
Reference in New Issue
Block a user