Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let uid = document.location.href.substring(25);
- let totalBMs = document.querySelector("div.user-profile-pages.ui-sortable > div:nth-child(4) > div > h3:nth-child(4) > span").textContent;
- async function getBMs(uid) {
- let a = await fetch(`https://osu.ppy.sh/users/${uid}/beatmapsets/most_played?offset=1&limit=${totalBMs}`, {
- "credentials": "include",
- "headers": {
- "User-Agent": "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:84.0) Gecko/20100101 Firefox/84.0",
- "Accept": "*/*",
- "Accept-Language": "en-US,en;q=0.5",
- "X-CSRF-Token": "uy3Ba5IyVV5EITQHqiq3DNnlll9CEBRM2iVmmdKY",
- "X-Requested-With": "XMLHttpRequest",
- "Sec-GPC": "1"
- },
- "referrer": `https://osu.ppy.sh/users/${uid}`,
- "method": "GET",
- "mode": "cors"
- });
- let b = await a.json();
- return(b);
- };
- function foo(arr) {
- var a = [],
- b = [],
- prev;
- arr.sort();
- for (var i = 0; i < arr.length; i++) {
- if (arr[i].count !== prev) {
- a.push(arr[i].count);
- b.push(1);
- } else {
- b[b.length - 1]++;
- }
- prev = arr[i].count;
- }
- return [a, b];
- }
- let info = await getBMs(uid);
- let result = foo(info);
- console.log('[' + result[0] + ']', '[' + result[1] + ']')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement