Skip to content
Oisín Bates
GitHubLinkedin

rickroll.js

JavaScript1 min read

I’ve always found it interesting how some people can be fascinated by the sight of terminals printing logs. The logs could be nonsense, but the sight itself is often enough to attract attention. In this sense, it’s the perfect opportunity for Rickrolling.

1const NEVER_GONNA_GIVE_YOU_UP = {
2 "songForm":[
3 "verse1",
4 "preChorus1",
5 "chorus",
6 "verse2",
7 "preChorus2",
8 "chorus",
9 "chorus",
10 "bridge",
11 "verse2",
12 "preChorus1",
13 "chorus",
14 "chorus"
15 ],
16 "chorus":"Never gonna give you up Never gonna let you down Never gonna run around and desert you Never gonna make you cry Never gonna say goodbye Never gonna tell a lie and hurt you\n\n",
17 "preChorus1":"I just wanna tell you how I'm feeling Gotta make you understand\n\n",
18 "preChorus2":"And if you ask me how I'm feeling Don't tell me you're too blind to see\n\n",
19 "verse1":"We're no strangers to love You know the rules and so do I A full commitment's what I'm thinking of You wouldn't get this from any other guy\n\n",
20 "verse2":"We've known each other for so long Your heart's been aching but you're too shy to say it Inside we both know what's been going on We know the game and we're gonna play it\n\n",
21 "bridge":"Never gonna give, never gonna give\n(Give you up)\n(Ooh) \nNever gonna give, never gonna give\n(Give you up)\n\n"
22}
23
24const SLEEP = (lyrics, count) => {
25 process.stdout.write(lyrics.charAt(count));
26 return new Promise(resolve => setTimeout(resolve, 100));
27}
28
29const RICK_ROLL = async () => {
30 //boolean as a constant because Rick Astley will never give you up
31 const RICK_ASTLEY_IS_GIVING_YOU_UP = false;
32
33 //infinite loop for infinite rick-rolling
34 while(!RICK_ASTLEY_IS_GIVING_YOU_UP) {
35 for(let section of NEVER_GONNA_GIVE_YOU_UP['songForm']) {
36 for(let i=0; i<NEVER_GONNA_GIVE_YOU_UP[section].length;i++){
37 await SLEEP(NEVER_GONNA_GIVE_YOU_UP[section], i);
38 }
39 }
40 }
41}
42
43RICK_ROLL();

Rickroll screenshot

GitHub repo here