Skip to content

Instantly share code, notes, and snippets.

@HorizonCode
Created August 16, 2020 14:56
Show Gist options
  • Save HorizonCode/7aa025aa1fe83f1a3693109e1138fedc to your computer and use it in GitHub Desktop.
Save HorizonCode/7aa025aa1fe83f1a3693109e1138fedc to your computer and use it in GitHub Desktop.
osu!Akatsuki ReplayID Crawler
<head>
<title>osu!Akatsuki Replay Crawler</title>
<style>
*{
margin: 0;
padding: 0;
}
html{
width: 100vw;
height: 100vh;
}
/* CSS which you need for blurred box */
body{
background-repeat: repeat;
background-attachment: scroll;
background-size: auto;
background-position: top;
background-image: url(https://osu.gatari.pw/static/images/backgrounds/bg2.png);
width: 100%;
height: 100%;
font-family: Arial, Helvetica;
letter-spacing: 0.02em;
font-weight: 400;
-webkit-font-smoothing: antialiased;
}
.blurred-box{
position: relative;
width: 250px;
height: 350px;
top: calc(50% - 175px);
left: calc(50% - 125px);
background: inherit;
border-radius: 2px;
overflow: hidden;
}
.blurred-box:after{
content: '';
width: 300px;
height: 300px;
background: inherit;
position: absolute;
left: -25px;
left position
right: 0;
top: -25px;
top position
bottom: 0;
box-shadow: inset 0 0 0 200px rgba(255,255,255,0.05);
filter: blur(10px);
}
/* Form which you dont need */
.user-login-box{
position: relative;
margin-top: 50px;
text-align: center;
z-index: 1;
}
.user-login-box > *{
display: inline-block;
width: 200px;
}
.user-icon{
width: 100px;
height: 100px;
position: relative;
border-radius: 50%;
background-size: contain;
background-image: url(https://a.akatsuki.pw/1);
}
.user-name{
margin-top: 15px;
margin-bottom: 15px;
color: white;
}
input.user-search {
width: 120px;
height: 18px;
opacity: 0.4;
border-radius: 2px;
padding: 5px 15px;
border: 0;
}
button {
background: none;
border: 2px solid;
font: inherit;
line-height: 1;
margin: 0.5em;
padding: 1em 2em;
color: var(--color);
transition: 0.25s;
cursor: pointer;
transition: color 1s ease;
}
button:disabled {
background: none;
border: 2px solid;
font: inherit;
line-height: 1;
margin: 0.5em;
padding: 1em 2em;
color: 525252;
transition: 0.25s;
cursor: pointer;
transition: color 1s ease;
}
.pulse {
--color: #ef6eae;
}
.pulse:hover, .pulse:focus {
animation: pulse 1s;
box-shadow: 0 0 0 2em rgba(255, 255, 255, 0);
}
@keyframes pulse {
0% {
box-shadow: 0 0 0 0 var(--color);
}
}
/* The spinner */
@keyframes spinner {
to {transform: rotate(360deg);}
}
.spinner,
.spinner:before {
width: 20px;
height: 20px;
box-sizing: border-box;
}
.spinner:before {
content: '';
display: block;
border-radius: 50%;
border: 1px solid #ccc0;
border-top-color: #ffffff;
animation: spinner .6s linear infinite;
}
.spinner-absolute {
position: relative;
left: 45%;
}
/* Animations */
.spinner-add,
.spinner-remove {
animation-fill-mode: both;
animation-duration: .4s;
}
.spinner-add {
animation-name: spinner-add;
}
@keyframes spinner-add {
from {transform: scale(0);}
to {transform: scale(1);}
}
.spinner-remove {
animation-name: spinner-remove;
}
@keyframes spinner-remove {
to {transform: scale(0);}
}
</style>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/izitoast/1.4.0/css/iziToast.min.css" integrity="sha512-O03ntXoVqaGUTAeAmvQ2YSzkCvclZEcPQu1eqloPaHfJ5RuNGiS4l+3duaidD801P50J28EHyonCV06CUlTSag==" crossorigin="anonymous" />
</head>
<html>
<div class="blurred-box">
<div class="user-login-box">
<span class="user-icon"></span>
<div class="user-name">Enter Username/ID</div>
<input class="user-search" id="user-search" type="text" />
<button class="pulse" id="start-crawl" type="button">Start Crawling</button>
</div>
</div>
</html>
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/izitoast/1.4.0/js/iziToast.min.js" integrity="sha512-Zq9o+E00xhhR/7vJ49mxFNJ0KQw1E1TMWkPTxrWcnpfEFDEXgUiwJHIKit93EW/XxE31HSI5GEOW06G6BF1AtA==" crossorigin="anonymous"></script>
<script>
var page = 1;
var totalQuery = "";
function addSpinner(el, static_pos)
{
var spinner = el.children('.spinner');
if (spinner.length && !spinner.hasClass('spinner-remove')) return null;
!spinner.length && (spinner = $('<div class="spinner' + (static_pos ? '' : ' spinner-absolute') + '"/>').appendTo(el));
animateSpinner(spinner, 'add');
}
function removeSpinner(el, complete)
{
var spinner = el.children('.spinner');
spinner.length && animateSpinner(spinner, 'remove', complete);
}
function animateSpinner(el, animation, complete)
{
if (el.data('animating')) {
el.removeClass(el.data('animating')).data('animating', null);
el.data('animationTimeout') && clearTimeout(el.data('animationTimeout'));
}
el.addClass('spinner-' + animation).data('animating', 'spinner-' + animation);
el.data('animationTimeout', setTimeout(function() { animation == 'remove' && el.remove(); complete && complete(); }, parseFloat(el.css('animation-duration')) * 1000));
}
function isInt(value) {
if (isNaN(value)) {
return false;
}
var x = parseFloat(value);
return (x | 0) === x;
}
$("#start-crawl").on("click", function(){
if(totalQuery != ""){
showOutput();
return;
}
var search = $("#user-search").val();
if(isInt(search)){
var parseUrl = "https://akatsuki.pw/api/v1/users/full?id=" + search;
$.getJSON(parseUrl, function(data) {
if(data.code == 200){
var button = $("#start-crawl");
button.prop('disabled', true);
button.html("");
addSpinner(button, false);
iziToast.info({
message: 'Please wait until the crawler is done, you will get a another Notification when its done!',
icon: "",
position: 'topRight',
overlayClose: false,
close: false,
transitionOut: "fadeOutUp"
});
var userID = data.id;
console.log("ID is " + userID);
loadJSONFromURL("https://akatsuki.pw/api/v1/users/scores/recent?id=" + userID + "&l=100&p=" + page, userID);
}else{
iziToast.error({
message: 'Enter a valid Username or ID',
icon: "",
position: 'topRight',
overlayClose: false,
close: false,
transitionOut: "fadeOutUp"
});
}
});
}else{
var parseUrl = "https://akatsuki.pw/api/v1/users/full?name=" + search;
$.getJSON(parseUrl, function(data) {
if(data.code == 200){
var button = $("#start-crawl");
button.prop('disabled', true);
button.html("");
addSpinner(button, false);
iziToast.info({
message: 'Please wait until the crawler is done, you will get a another Notification when its done!',
icon: "",
position: 'topRight',
overlayClose: false,
close: false,
transitionOut: "fadeOutUp"
});
var userID = data.id;
console.log("ID is " + userID);
loadJSONFromURL("https://akatsuki.pw/api/v1/users/scores/recent?id=" + userID + "&l=100&p=" + page, userID);
}else{
iziToast.error({
message: 'Enter a valid Username or ID',
icon: "",
position: 'topRight',
overlayClose: false,
close: false,
transitionOut: "fadeOutUp"
});
}
});
}
});
$("#user-search").on("input", function(){
setTimeout(function () {
var current = $("#user-search").val();
if(current !== "") {
var search = current;
if(isInt(search)){
var parseUrl = "https://akatsuki.pw/api/v1/users/full?id=" + search;
$.getJSON(parseUrl, function(data) {
console.log(data.stats);
if(data.code == 200){
var imageUrl = "https://a.akatsuki.pw/" + data.id;
if($('.user-icon').css('background-image') != "'url('" + imageUrl + "')'")
$('.user-icon').css('background-image', 'url(' + imageUrl + ')');
}else{
var imageUrl = "https://a.akatsuki.pw/1";
if($('.user-icon').css('background-image') != "'url('" + imageUrl + "')'")
$('.user-icon').css('background-image', 'url(' + imageUrl + ')');
}
});
}else{
var parseUrl = "https://akatsuki.pw/api/v1/users/full?name=" + search;
$.getJSON(parseUrl, function(data) {
if(data.code == 200){
var imageUrl = "https://a.akatsuki.pw/" + data.id;
if($('.user-icon').css('background-image') != "'url('" + imageUrl + "')'")
$('.user-icon').css('background-image', 'url(' + imageUrl + ')');
}else{
var imageUrl = "https://a.akatsuki.pw/1";
if($('.user-icon').css('background-image') != "'url(' + imageUrl + ')'")
$('.user-icon').css('background-image', 'url(' + imageUrl + ')');
}
});
}
}else{
var imageUrl = "https://a.akatsuki.pw/1";
$('.user-icon').css('background-image', 'url(' + imageUrl + ')');
}
}, 50);
});
function showOutput(){
var win = window.open("", "Crawler Output", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=780,height=200,top="+(screen.height-400)+",left="+(screen.width-840));
win.document.body.innerHTML = totalQuery;
}
function loadJSONFromURL(url, userID){
$.getJSON(url, function(data) {
for (i in data.scores) {
var id = "https://akatsuki.pw/web/replays/" + data.scores[i].id;
totalQuery += id + "<br>";
}
setTimeout(function () {
if ($.isArray(data.scores) && data.scores.length) {
page++;
loadJSONFromURL("https://akatsuki.pw/api/v1/users/scores/recent?id=" + userID + "&l=100&p=" + page, userID);
} else {
var button = $("#start-crawl");
removeSpinner(button);
setTimeout(function () {
button.html("Show Output");
button.prop('disabled', false);
}, 250);
iziToast.success({
message: 'Crawling finished!',
icon: "",
position: 'topRight',
overlayClose: false,
close: false,
transitionOut: "fadeOutUp"
});
}
}, 1000);
});
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment