Skip to content

Instantly share code, notes, and snippets.

@jphastings
Created October 27, 2024 08:17
Show Gist options
  • Save jphastings/9bd607309159a699079ac5d66b667906 to your computer and use it in GitHub Desktop.
Save jphastings/9bd607309159a699079ac5d66b667906 to your computer and use it in GitHub Desktop.
A random comment picker for scalzi.com

Random Comment Picker for Scalzi.com

A short script that can be dropped in the developer console, or used as a bookmarklet, on Scalzi.com that will highlight & move to the comment with the specified number. (The prompt pre-populates with a randomly chosen comment.)

I will look at the the total number of comments, ask Alexa to pick a number in that field of numbers, and then painstakingly go through the comments until I find the comment that corresponds to that number, and then pick that one. This will be an enormous pain in my ass, so I hope at least one of you gets the moon right.

Hey, Want an ARC of “When the Moon Hits Your Eye”? on Scalzi.com

const c = document.querySelectorAll('li.comment');
const n = window.prompt(`Which comment? (1-${c.length})`, Math.floor(Math.random()*c.length)+1)
c[n].style.backgroundColor = '#F0F0D5'
c[n].scrollIntoView({ behavior: "smooth" })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment