Skip to content

Instantly share code, notes, and snippets.

@hawx
Created May 8, 2013 11:16
Show Gist options
  • Save hawx/5539812 to your computer and use it in GitHub Desktop.
Save hawx/5539812 to your computer and use it in GitHub Desktop.
My screensaver, shows random faved tweets on a loop.

Favtwit

My (mac) screensaver. Download and install the IdleWeb screensaver. Put the files above into a folder somewhere along with twitterlib.min.js. Then setup.

html, body {
height: 100%;
width: 100%;
}
body {
background: #14161b;
color: white;
font: 1em/1.4em 'Akzidenz-Grotesk BQ';
text-shadow: 0 3px 6px rgba(0, 0, 0, .7);
display: -webkit-box;
-webkit-box-pack: center;
-webkit-box-align: center;
}
#container {
max-width: 80em;
-webkit-box-flex: 1;
}
h1 {
text-align: center;
font-size: 6em;
line-height: 1.1em;
font-weight: medium;
opacity: .9;
}
h2 {
text-align: center;
font-weight: 300;
font-size: 2.5em;
color: #696f7f;
opacity: .9;
}
a {
color: #d5e3f1;
text-decoration: none;
}
var username = 'hawx';
function random(max) {
return Math.floor(Math.random() * max + 1);
}
function displayTweet() {
var text = document.getElementById('text');
var name = document.getElementById('name');
twitterlib.favs(username, {page: random(6)}, function (tweets, options) {
var tweet = tweets[random(tweets.length)];
if (tweet == undefined) {
tweet = tweets[0];
}
text.innerHTML = this.ify.clean(tweet.text);
name.innerHTML = '@' + tweet.user.screen_name;
});
setTimeout(displayTweet, 12 * 1000);
}
displayTweet();
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title></title>
<link rel="stylesheet" href="favtwit.css" type="text/css" />
</head>
<body>
<div id='container'>
<h1 id='text'></h1>
<h2 id='name'></h2>
</div>
<script src="twitterlib.min.js"></script>
<script src="favtwit.js"></script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment