gist: 41207 Download_button fork
public
Public Clone URL: git://gist.github.com/41207.git
rvtl.ubiq.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
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',
});
 

Owner

satyr

Revisions