Skip to content

Instantly share code, notes, and snippets.

@HerrLevin
Created April 15, 2014 17:59
Show Gist options
  • Save HerrLevin/10753262 to your computer and use it in GitHub Desktop.
Save HerrLevin/10753262 to your computer and use it in GitHub Desktop.
A simple script to display a specific #NowPlaying-Page of last.fm with a clock. (Mostly not working because of the frame-SecurityError.) //Live preview: http://np.oderso.org/
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<style type="text/css">
body {
margin: 0;
}
html, body {
height: 100%;
}
.txt {
color: #ffffff;
font-size: 50px;
line-height: 60px;
font-family: 'Lucida Grande', Arial, Helvetica, Verdana, sans-serif;
position: absolute;
top: 5%;
right: 10%;
overflow: visible;
text-shadow:
rgba(0, 0, 0, 0.298039) 0px -1px 0px,
rgba(0, 0, 0, 0.701961) 0px 0px 10px,
rgba(0, 0, 0, 0.298039) 0px 0px 50px;
}
* {
overflow: hidden;
}
object, embed {
width: 100%;
height: 100%
}
</style>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script>
function startTime() {
var today = new Date();
var h = today.getHours();
var m = today.getMinutes();
var s = today.getSeconds();
// add a zero in front of numbers<10
h = checkTime(h);
m = checkTime(m);
s = checkTime(s);
document.getElementById('txt').innerHTML=h+":"+m+":"+s;
t = setTimeout(function(){startTime()},500);
}
function checkTime(i) {
if (i<10) {
i="0" + i;
}
return i;
}
var $_GET = {};
document.location.search.replace(/\??(?:([^=]+)=([^&]*)&?)/g, function () {
function decode(s) {
return decodeURIComponent(s.split("+").join(" "));
}
$_GET[decode(arguments[1])] = decode(arguments[2]);
});
var user = "";
if (typeof $_GET['username'] === 'undefined' || $_GET['username'] === '') {
var user = "HerrLevin_";
} else {
var user = $_GET['username'];
}
//For testing purposes
//document.write("http://www.last.fm/user/"+user+"/now");
//document.write(user);
//document.write($_GET['username']);
$(function(){
$("object").attr("data", "http://www.last.fm/user/"+user+"/now");
$("embed").attr("src", "http://www.last.fm/user/"+user+"/now");
});
</script>
</head>
<body onload="startTime()" style="">
<p id="txt" class="txt"></p>
<object id="object" data="http://www.last.fm/user/HerrLevin_/now">
<embed id="embed" src="http://www.last.fm/user/HerrLevin_/now" />
Your browser doesn't support embedded data. Your browser sucks!
</object>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment