Last active
August 30, 2021 10:59
-
-
Save lackofdream/eef8bbbe51a55fe5c907ba1e03e4ef5d to your computer and use it in GitHub Desktop.
Nelson Drops.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="UTF-8" /> | |
<title>Nelson Drops</title> | |
<script src="https://unpkg.com/react@17/umd/react.development.js"></script> | |
<script src="https://unpkg.com/react-dom@17/umd/react-dom.development.js"></script> | |
<!-- Don't use this in production: --> | |
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script> | |
<style> | |
.drops { | |
font-size: 24px; | |
} | |
</style> | |
</head> | |
<body> | |
<div id="root"></div> | |
<script type="text/babel"> | |
function NelsonDrops(props) { | |
const [info, updateInfo] = React.useState({}); | |
const [updatedAt, updateUpdatedAt] = React.useState(new Date(70, 1)); | |
React.useEffect(() => { | |
getInfo().then(i => { | |
updateInfo(i); | |
updateUpdatedAt(new Date()); | |
}); | |
}, []); | |
React.useEffect(() => { | |
const interval = setInterval(() => { | |
getInfo().then(i => { | |
updateInfo(i); | |
updateUpdatedAt(new Date()); | |
}); | |
}, 60000); | |
return () => { | |
clearInterval(interval); | |
}; | |
}, []); | |
return (<div> | |
<div className="drops"> | |
Nelson Drops: | |
{info.drops}/{info.total} | |
</div> | |
<div className="updated-at"> | |
updated at: {updatedAt.toString()} | |
</div> | |
</div>) | |
} | |
ReactDOM.render( | |
<NelsonDrops />, | |
document.getElementById('root') | |
); | |
function getInfo() { | |
return fetch('https://tsunkit.net/api/routing/drops?map=51-2&edges=39%2C41&start=2021-07-31&minDiff=4&maxDiff=4&minHqLvl=1&maxHqLvl=120&cleared=-1&dupeCount=1&ranks=S').then(resp => { | |
return resp.json() | |
}).then(data => { | |
return data['entries'].filter(x => x && x.name && x.name === 'Nelson')[0]; | |
}); | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment