This repository has been archived by the owner on May 3, 2023. It is now read-only.
forked from sunghwan2789/osu-preview
-
Notifications
You must be signed in to change notification settings - Fork 0
/
preview.html
287 lines (251 loc) · 10.2 KB
/
preview.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
<!DOCTYPE html>
<html>
<!--
osu-preview reborn by aeongdesu
with NeriNyan ❤
https://github.com/aeongone/osu-preview
- Respect
https://github.com/sunghwan2789/osu-preview
https://github.com/jmir1/osu-preview
- Thanks to
^ repect developers
osu!
cloudflare pages
vercel
nerinyan
osuplus edited script if you want
https://github.com/aeongone/osuplus/raw/master/osuplus.user.js
-->
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="robots" content="nofollow, noarchive">
<meta property="og:url" content="https://osu.pages.dev/">
<meta property="og:title" content="osu!preview - more stable">
<meta property="og:description" content="hosted by pages.dev">
<title>osu.pages.dev</title>
<link rel="icon" sizes="any" href="https://cdn.discordapp.com/emojis/705002474838163467.png">
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Material+Icons">
<link rel="stylesheet" href="css/style.css">
</head>
<body class="h">
<div id="container" class="x-viewbox"></div>
<button id="play" class="material-icons"></button>
<div id="speed">
<button value="1.5">DT</button>
<button class="e" value="1">-</button>
<button value="0.75">HT</button>
</div>
<div id="mania">
<button value="1">+</button>
<button id="scroll">20</button>
<button value="-1">-</button>
</div>
<div id="control">
<input id="progress" type="range" min="0" max="0" value="0">
<input id="volume" type="range" min="0" max="100" value="100">
<button id="fullscreen" class="material-icons"></button>
</div>
<div id="title">
<a id="beatmapdl" target="_blank"><img src="https://cdn.discordapp.com/emojis/705002474838163467.png" width="30"
height="30" alt="osuNyan"></a>
<a id="beatmapinfo" target="_blank">Loading beatmap info...</a>
</div>
<script src="https://cdn.statically.io/gh/jquery/jquery/3.6.1/dist/jquery.slim.min.js"></script>
<script src="https://cdn.statically.io/gh/gildas-lormeau/zip.js/v2.6.29/dist/zip.min.js"></script>
<script src="https://cdn.statically.io/gh/brix/crypto-js/4.1.1/crypto-js.min.js"></script>
<script src="https://cdn.statically.io/gh/Doxee/NoSleep.js/b9e7414386799c6b54aa3769093e4ee7cd7eecb8/dist/NoSleep.min.js"></script>
<script src="js/util.js"></script>
<script src="js/beatmap/beatmap.js"></script>
<script src="js/beatmap/timingpoint.js"></script>
<script src="js/beatmap/hitobject.js"></script>
<script src="js/beatmap/point.js"></script>
<script src="js/beatmap/scroll.js"></script>
<script src="js/standard/standard.js"></script>
<script src="js/standard/hitcircle.js"></script>
<script src="js/standard/slider.js"></script>
<script src="js/standard/curve/curve.js"></script>
<script src="js/standard/curve/equaldistancemulticurve.js"></script>
<script src="js/standard/curve/linearbezier.js"></script>
<script src="js/standard/curve/catmullcurve.js"></script>
<script src="js/standard/curve/curvetype.js"></script>
<script src="js/standard/curve/bezier2.js"></script>
<script src="js/standard/curve/centripetalcatmullrom.js"></script>
<script src="js/standard/curve/circumstancedcircle.js"></script>
<script src="js/standard/spinner.js"></script>
<script src="js/taiko/taiko.js"></script>
<script src="js/taiko/donkat.js"></script>
<script src="js/taiko/drumroll.js"></script>
<script src="js/taiko/shaker.js"></script>
<script src="js/mania/mania.js"></script>
<script src="js/mania/hitnote.js"></script>
<script src="js/mania/holdnote.js"></script>
<script src="js/preview.js"></script>
<script src="js/viewbox.js"></script>
<script>
var preview = new Preview($("#container")[0])
var audio = new Audio()
$(window).on("hashchange", async function () {
$(audio).trigger("pause")
$("#mania").removeClass("e")
$("#play").removeClass("e")
// example
var beatmapID = isNaN(location.hash.split("#")[1]) ? 1751496 : location.hash.split("#")[1]
var statusText = text => $("#beatmapinfo").text(text)
statusText("Loading...")
const nerinyan = await fetch(`https://api.nerinyan.moe/search?q=${beatmapID}&option=mapid&s=all&nsfw=1`)
if (nerinyan.ok) {
var osu
var bgname
var audioname
var bgURL
var audioURL
statusText("beatmap found! downloading osz...")
const beatmapInfo = (await nerinyan.json())[0]
// download osz and decompress (idea from jmir1, thanks!)
const blob = await fetch(`https://proxy.nerinyan.moe/d/${beatmapInfo.id}`).then(res => res.blob())
const reader = new zip.ZipReader(new zip.BlobReader(blob))
const files = await reader.getEntries()
statusText("finding files...")
for (file in files) {
if (files[file].filename.includes(".osu")) {
for (bm in beatmapInfo.beatmaps) {
const beatmap = beatmapInfo.beatmaps[bm]
if (beatmap.id == beatmapID && files[file].filename == beatmap.osu_file) {
osu = await files[file].getData(new zip.TextWriter("utf-8"))
console.log(`${osu.slice(0, 996)}\n...`)
checkbg = osu.match(/(?<=0,0,").+(?=")/)
if (checkbg) bgname = checkbg[0]
checkaudio = osu.match(/(?<=AudioFilename: ).+(?=)/)
if (checkaudio) audioname = checkaudio[0]
break
}
}
}
}
if (bgname) {
for (file in files) {
if (files[file].filename == bgname.replace(/[\\\/:*?"<>|]/g, "")) {
const bgblob = await files[file].getData(
new zip.BlobWriter(`image/${bgname.split(".").pop()}`)
)
bgURL = URL.createObjectURL(bgblob)
break
}
}
}
if (audioname) {
for (file in files) {
if (files[file].filename == audioname.replace(/[\\\/:*?"<>|]/g, "")) {
const bgblob = await files[file].getData(
new zip.BlobWriter(`audio/${audioname.split(".").pop()}`)
)
audioURL = URL.createObjectURL(bgblob)
break
}
}
}
await reader.close()
if (osu) {
return await preview.load(osu, bgURL, function () {
audio.src = audioURL
$("#beatmapinfo").prop("href", "https://osu.ppy.sh/b/" + beatmapID)
.text(isNaN(location.hash.split("#")[1]) ? "[EXAMPLE MAP] Usage: osu.pages.dev/preview#BEATMAP_ID" : this.beatmap.toString())
$("#beatmapdl").prop("href", `https://api.nerinyan.moe/d/${beatmapInfo.id}`)
if (this.beatmap instanceof Mania) {
$("#mania").addClass("e")
$("#scroll").text(this.beatmap.scrollSpeed)
}
$("#play").addClass("e")
},
function (e) {
alert(e)
console.log(e)
})
} else {
alert("Can't find the beatmap file!\nPlease contact me to fix this issue faster!\nDiscord: https://discord.deta.dev")
return statusText("Can't find the beatmap file!")
}
} else return statusText("beatmap not found")
}).trigger("hashchange")
$(document.body).on("mousemove", function () {
var self = $(this)
clearTimeout(self.data("h"))
self.addClass("h").data("h", setTimeout(function () {
if (!audio.paused) {
self.removeClass("h")
}
}, 3000))
})
const noSleep = new NoSleep()
$(audio).on("pause", function (e) {
$(document.body).trigger("mousemove")
$("#play").addClass("e")
noSleep.disable()
}).on("play", function (e) {
preview.beatmap.refresh()
if (e.isTrigger) {
e.preventDefault()
preview.at(audio.currentTime * 1000)
}
else {
$("#play").removeClass("e")
requestAnimationFrame(function foo() {
preview.at(audio.currentTime * 1000)
if (!audio.paused) {
requestAnimationFrame(foo)
}
})
noSleep.enable()
}
}).on("durationchange", function () {
$("#progress").val(0).prop("max", this.duration)
$("#volume").trigger("change")
$("#speed .e").trigger("click")
}).on("timeupdate", function () {
$("#progress").val(this.currentTime)
})
$("#progress").on("change", function () {
audio.currentTime = this.value
$(audio).trigger("play")
})
$("#volume").on("change", function () {
audio.volume = this.value / 100
})
$("#speed button").on("click", function () {
$("#speed .e").removeClass("e")
audio.playbackRate = $(this).addClass("e").val()
})
$("#mania button").on("click", function () {
var val = this.value | 0
if (val) {
preview.beatmap.scrollSpeed += val
$("#scroll").text(preview.beatmap.scrollSpeed)
$(audio).trigger("play")
}
})
$("#play").on("click", function (e) {
e.preventDefault()
if ($(this).hasClass("e")) {
audio.play()
}
else {
audio.pause()
}
})
$("#fullscreen").on("click", function (e) {
e.preventDefault()
var doc = window.document
var docEl = doc.documentElement
var requestFullScreen = docEl.requestFullscreen || docEl.mozRequestFullScreen || docEl.webkitRequestFullScreen || docEl.msRequestFullscreen
var cancelFullScreen = doc.exitFullscreen || doc.mozCancelFullScreen || doc.webkitExitFullscreen || doc.msExitFullscreen
if (!doc.fullscreenElement && !doc.mozFullScreenElement && !doc.webkitFullscreenElement && !doc.msFullscreenElement) {
requestFullScreen.call(docEl)
}
else {
cancelFullScreen.call(doc)
}
})
</script>
</body>
</html>