maraigue (owner)

Revisions

gist: 116915 Download_button fork
public
Description:
Source code for Twitter "ReTweet" bookmarklet (use in Twitter status page)
Public Clone URL: git://gist.github.com/116915.git
Embed All Files: show embed
ReTweet.js #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
(function(){
    var h,x,b;
    if(location.href.match(/^https?:\/\/(m\.|explore\.)?twitter\.com\/([0-9A-Z_a-z]+)\/status/)){
        h="RT+@"+RegExp.$2+":+";
    }else{
        alert("Not in a tweet page!");
        return;
    }
    x=(document.getElementsByTagName("body"))[0].innerHTML.match(/<span class="?entry-content"?>(.+?)<\/span>/ig);
    if(x && x.length==1){
        b=RegExp.$1;
        b=b.replace(/@<a href="?\/([0-9A-Z_a-z]+)"?>\1<\/a>/ig,function(s,p){return "@"+p;});
        b=b.replace(/<a [^>]*?class="?hashtag"?[^>]*?>#(.+?)<\/a>/ig,function(s,p){return "#"+p;});
        b=b.replace(/<a href="?(https?:\/\/.+?)"? rel="?nofollow"? target="?_blank"?>.+?<\/a>/ig,function(s,p){return p;});
        location.href="http://twitter.com/?status="+h+encodeURIComponent(b);
    }else{
        alert("Can not extract the tweet!");
    }
})();