Skip to content

Instantly share code, notes, and snippets.

@metruzanca
Last active July 26, 2021 16:47
Show Gist options
  • Save metruzanca/81b426f83604964ad6935b99693eec97 to your computer and use it in GitHub Desktop.
Save metruzanca/81b426f83604964ad6935b99693eec97 to your computer and use it in GitHub Desktop.

Rip, CORS in discord's console :(

This doesn't work, like I feared.

Usage

Paste this into the discord console

fetch("https://api.github.com/gists/81b426f83604964ad6935b99693eec97")
  .then(d => d.json())
  .then(d => eval(d.files['tally.js'].content))
{
function getWinner(message) {
try{
const people = message.split('\n').map(line => line.split(':')[0])
const winner = people.filter( p => p.startsWith('+ '))[0].substr(2)
return winner
}
catch(err) {
return 'n/a' // If 1, means today's winner wasn't announced yet. If 2, matt fucked up
}
}
const messages = [...document.querySelectorAll("div.contents-2mQqc9 > div > pre > code")]
.map(el => el.textContent)
const stats = messages.reduce((acc, curr) => {
const winner = getWinner(curr)
return {...acc, [winner]: (acc[winner] || 0) + 1}
},{})
console.log(stats)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment