Skip to content

Instantly share code, notes, and snippets.

@erickzhao
Last active July 31, 2020 01:48
Show Gist options
  • Save erickzhao/2b20438c64a99ccbaf8713d841306598 to your computer and use it in GitHub Desktop.
Save erickzhao/2b20438c64a99ccbaf8713d841306598 to your computer and use it in GitHub Desktop.
Power Hour Runner

Power Hour Runner

.~~~~.    .~~~~.    .~~~~.    .~~~~.    .~~~~.    
i====i_   i====i_   i====i_   i====i_   i====i_   60 MINUTES
|cccc|_)  |cccc|_)  |cccc|_)  |cccc|_)  |cccc|_)  60 SONGS
|cccc|    |cccc|    |cccc|    |cccc|    |cccc|    60 OZ OF BEER
`-==-'    `-==-'    `-==-'    `-==-'    `-==-'    

This quick utility allows you to run a power hour instantly, provided you have the Spotify Web Player with a playlist ready.

🍻 What's a Power Hour?

A Power Hour follows the basic format of consuming one shot (1 fl. oz.) of beer every minute for 60 minutes. This is equivalent to consuming 5 beers in one hour. Participants are usually put in a large room with sets of tables. Each set of tables has a few facilitators to hand out the beer and the shot glasses during the event. It's rare that everyone drinks exactly 1 shot of beer every minute. The event usually devolves into just casual drinking and dancing after about 30-45 minutes.

Source: EUS Wiki

🏗 Setup

  1. Open the Spotify Web Player (with Spotify Premium).
  2. Queue your power hour playlist.
  3. Open Dev Tools Console.
  4. Paste POWERHOUR.js into the console.

⚙️ Configuration

There are some variables set up for you to customize your Power Hour experience.

  HORN_LINK     // change horn sound
  SONG_TIME     // in ms
  NUM_SONGS     // change number of songs played
  NUM_END_SONGS // number of songs to play in full at the end

📄 LICENSE

WTFPL

        DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 
                    Version 2, December 2004 

 Copyright (C) 2004 Sam Hocevar <sam@hocevar.net> 

 Everyone is permitted to copy and distribute verbatim or modified 
 copies of this license document, and changing it is allowed as long 
 as the name is changed. 

            DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 
   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 

  0. You just DO WHAT THE FUCK YOU WANT TO.
const buttons = {
next: document.querySelector('[title="Next"]'),
play: document.querySelector('[title="Play"]'),
}
// CONFIGURATION CONSTANTS
const HORN_LINK = 'https://raw.githubusercontent.com/bread-gang/SAAS/master/airhorn.mp3'; // change horn sound
const SONG_TIME = 60000; // in ms
const NUM_SONGS = 60; // change number of songs played
const NUM_END_SONGS = 1; // number of songs to play in full at the end
const horn = document.createElement('audio');
horn.setAttribute('src', HORN_LINK);
buttons.next.appendChild(horn);
const playLoop = () => {
setTimeout(() => {
buttons.play.click();
horn.play();
}, SONG_TIME);
}
let counter = 0;
horn.addEventListener('ended', () => {
if (counter < NUM_SONGS - NUM_END_SONGS) {
if (counter === 0) {
buttons.play.click();
} else {
buttons.next.click();
}
playLoop();
} else if (counter === NUM_SONGS - NUM_END_SONGS) {
buttons.next.click();
}
counter++;
});
horn.play();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment