/* jshint browser: true */

window.addEventListener("load", function () {
	window.setInterval(function () {
		var d = new Date();
		var hours = d.getHours();
		var mins = d.getMinutes();
		var secs = d.getSeconds();
		var red = ("0" + Math.floor(256 / 24 * hours).toString(16)).slice(-2);
		var green = ("0" + Math.floor(256 / 60 * mins).toString(16)).slice(-2);
		var blue = ("0" + Math.floor(256 / 60 * secs).toString(16)).slice(-2);

		hours = ("0" + hours).slice(-2);
		mins = ("0" + mins).slice(-2);
		secs = ("0" + secs).slice(-2);

		var hex = "#" + red + green + blue;

		document.getElementById("clock").innerHTML = hours + " : " + mins + " : " + secs;
		document.getElementById("hex").innerHTML = hex;

		document.body.style.background = hex;
	}, 1000);
});

@@ -107,17 +107,19 @@
 %7B%0A%09%09var 
-d
+now
  = new D
@@ -127,24 +127,21 @@
 te()
-;%0A%09%09var 
+,%0A%09%09%09
 hours = 
 d.ge
@@ -132,25 +132,27 @@
 %0A%09%09%09hours = 
-d
+now
 .getHours();
@@ -154,24 +154,26 @@
 rs()
-;%0A%09%09var min
+,%0A%09%09%09minute
 s = 
-d
+now
 .get
@@ -185,24 +185,26 @@
 es()
-;%0A%09%09var sec
+,%0A%09%09%09second
 s = 
-d
+now
 .get
@@ -216,28 +216,34 @@
 ds()
-;%0A%09%09var red = (%220%22 +
+,%0A%09%09%09background = %7B%0A%09%09%09%09r:
  Mat
@@ -271,375 +271,402 @@
 urs)
-.toString(16)).slice(-2);%0A%09%09var green = (%220%22 + Math.floor(256 / 60 * mins).toString(16)).slice(-2);%0A%09%09var blue = (%220%22 + Math.floor(256 / 60 * secs).toString(16)).slice(-2);%0A%0A%09%09hours = (%220%22 + hours).slice(-2);%0A%09%09mins = (%220%22 + mins).slice(-2);%0A%09%09secs = (%220%22 + secs).slice(-2);%0A%0A%09%09var hex = %22#%22 + red + green + blue;%0A%0A%09%09document.getElementById(%22clock%22).innerHTML = 
+,%0A%09%09%09%09g: Math.floor(256 / 60 * minutes),%0A%09%09%09%09b: Math.floor(256 / 60 * seconds)%0A%09%09%09%7D,%0A%09%09%09hBackground = colorToHex(background),%0A%09%09%09hForeground = getLuminance(background) %3E 125 ? %22#000000%22 : %22#FFFFFF%22,%0A%09%09%09nClock = document.getElementById(%22clock%22),%0A%09%09%09nHex = document.getElementById(%22hex%22),%0A%09%09%09nBody = document.body;%0A%0A%09%09nBody.style.background = hBackground;%0A%09%09nClock.innerHTML = numberFormat(
 hours
+)
  + %22
@@ -676,130 +676,525 @@
 %22 + 
-mins + %22 : %22 + secs;%0A%09%09document.getElementById(%22hex%22).innerHTML = hex;%0A%0A%09%09document.body.style.background = hex;%0A%09%7D, 1000);
+numberFormat(minutes) + %22 : %22 + numberFormat(seconds);%0A%09%09nClock.style.color = hForeground;%0A%09%09nHex.innerHTML = hBackground;%0A%09%09nHex.style.color = hForeground;%0A%09%7D, 1000);%0A%0A%09function colorToHex(color) %7B%0A%09%09return %22#%22 + numToHex(color.r) + numToHex(color.g) + numToHex(color.b);%0A%09%7D%0A%0A%09function numToHex(num) %7B%0A%09%09return (%220%22 + num.toString(16)).slice(-2);%0A%09%7D%0A%0A%09function getLuminance(color) %7B%0A%09%09return 0.2126 * color.r + 0.7152 * color.g + 0.0722 * color.b;%0A%09%7D%0A%0A%09function numberFormat(num) %7B%0A%09%09return (%220%22 + num).slice(-2);%0A%09%7D
 %0A%7D);

Complete rewrite