Skip to content

Instantly share code, notes, and snippets.

@andrewwoods
Created February 15, 2015 06:27
Show Gist options
  • Save andrewwoods/afd8550af236342f151e to your computer and use it in GitHub Desktop.
Save andrewwoods/afd8550af236342f151e to your computer and use it in GitHub Desktop.
Rick Roll
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Rick Roll Example</title>
<script>
document.addEventListener( "DOMContentLoaded", function( event ) {
// Sun=0
// Mon=1
// Tue=2
// Wed=3
// Thu=4
// Fri=5
// Sat=6
// Rick Astley - Never Gonna Give You Up
var youtubeUrl = 'https://www.youtube.com/watch?v=dQw4w9WgXcQ';
var now = new Date();
//
// every monday and saturday
// when it's an even hour (2, 4, 6, 8, 10, etc)
// and the minutes are 0, 12, 24, 36, 48
//
// e.g. 8:00, 10:36 will open the window, but 8:01 or 10:30 will not
if ( (now.getDay() == 1 || now.getDay() == 6 )
&& ( now.getHours() % 2 == 0 ) && ( now.getMinutes() % 12 == 0 )
) {
rrWin = window.open( youtubeUrl, 'rickroll' );
console.log( rrWin );
}
});
</script>
</head>
<body>
<h1>Sample Page</h1>
<p>
Imagine this page is your blog post.
</p>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment