Skip to content

Instantly share code, notes, and snippets.

@ucnv
Created March 11, 2011 11:01
Show Gist options
  • Save ucnv/865735 to your computer and use it in GitHub Desktop.
Save ucnv/865735 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Tokyo Kafun on Twitter
// @namespace http://userscripts.org/users/40991
// @include http://twitter.com/*
// ==/UserScript==
function i(d) {
var n = d ? new Date(d) : new Date();
var y = n.getFullYear().toString();
var m = ('0' + (n.getMonth()+1)).match(/\d{2}$/)[0];
var d = n.getDate();
var h = n.getHours();
d = ('0' + (d - (h ? 0 : 1))).match(/\d{2}$/)[0];
h = ('0' + (h ? h : 24)).match(/\d{2}$/)[0];
return 'http://pollen.tokyo-kafun.jp/kafun/Data/bunpuzu/'
+ y + m + d + '/polmpp_' + y + m + d + h +'.jpeg?' + n.getTime();
}
var a = document.createElement('div');
var b = document.createElement('h2');
var c = document.createElement('a');
var d = document.createElement('img');
b.innerHTML = 'Kafun';
c.setAttribute('href', 'http://pollen.tokyo-kafun.jp/kafun/index.php?action=KafunMapNew');
c.setAttribute('target', '_blank');
d.addEventListener('error', function() {
if(!this.nn) this.src = i(Date.now() - 60*60*1000);
this.nn = 1;
}, false);
d.src = i();
d.style.width = '100%';
a.className = 'component';
a.id = 'kafun';
a.appendChild(b);
c.appendChild(d);
a.appendChild(c);
unsafeWindow.setTimeout(function() {
var e = document.getElementsByClassName('dashboard')[0];
e.insertBefore(a, e.firstChild);
}, 1000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment