Created
December 29, 2008 07:16
-
-
Save satyr/41207 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Twit = 'http://twitter.com/', | |
Icon = Twit +'favicon.ico', | |
PageMax = 40, | |
Style = <style><![CDATA[ | |
ol{padding:0} | |
li{margin-left:24px;font-size:80%;clear:left} | |
li.status{max-width:50em} | |
a.page{font-weight:bold;margin-right:-12px} | |
img{border:none} | |
img.fn{float:left;margin-right:4px} | |
img.inset{width:auto;height:auto;max-width:100%} | |
strong{display:block} | |
.actions{display:none} | |
.entry-meta{display:block} | |
]]></style>, | |
LongURLAPI = 'http://api.longurl.org/v1/expand?format=json&url=', | |
ReLnk = /^\s*https?:/, | |
ReImg = /\.(?:jpe?g|gif|png)$/i; | |
function fixLinks(q){ q.find('li a').each(expand) } | |
function expand(){ | |
with(this) if(ReLnk.test(innerHTML)) jQuery.getJSON( | |
LongURLAPI + href, function({long_url, title}){ if(long_url){ | |
var dlu = decodeURIComponent(long_url); | |
innerHTML = (title | |
? title +' ('+ dlu +')' | |
: (ReImg.test(long_url) | |
? '<img src="'+ long_url +'" class="inset"/>' | |
: dlu)); | |
}}); | |
} | |
CmdUtils.CreateCommand({ | |
name: 'reversed-timeline', | |
synonyms: ['rvtl'], | |
icon: Icon, | |
takes: {page: { | |
_name: 'twitter_pages', | |
default: function(p) CmdUtils.makeSugg((p || PageMax) +''), | |
suggest: function(txt, htm, cb, sx)( | |
sx ? [] : [this.default((txt & 63) % (PageMax + 1))]), | |
}}, | |
description: 'Opens '+ 'your timeline'.link(Twit) +' in reverse order', | |
help: 'Powered by '+ 'longurl'.link('http://longurl.org/'), | |
execute: function({text: p}){ | |
var htm = 'data:text/html,'+ | |
(<head><title>{this.name +' '+ p}</title><base | |
href={Twit} target="_blank"/><link | |
rel="icon" href={this.icon}/></head> + Style), | |
tab = (Application.activeWindow | |
.open(Utils.url(htm.replace(/\s*([<>])\s{0,}/g, '$1')))); | |
tab.events.addListener('load', function(){ | |
for(var {document: {body}} = tab; p; --p) +function(u){ | |
var ol = (jQuery(<ol><a class="page" href={u}>{p}</a></ol>+'') | |
.appendTo(body)); | |
jQuery.get(u, function(htm){ | |
var ls = jQuery('div.s + ul > li, #timeline > li', htm); | |
fixLinks(ol.append(Array.reverse(ls))); | |
}); | |
}(Twit +'home?page='+ p); | |
}); | |
}, | |
preview: function(pbl, {text: p}){ | |
pbl.innerHTML = this.description +' from page <b>'+ p +'</b>.'; | |
}, | |
previewDelay: 0, | |
author: 'satyr'.link('http://ubigist.appjet.net/?o=satyr'), license: 'MIT', | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment