Skip to content

Instantly share code, notes, and snippets.

@bumi
Created December 1, 2008 15:32
Show Gist options
  • Save bumi/30753 to your computer and use it in GitHub Desktop.
Save bumi/30753 to your computer and use it in GitHub Desktop.
adds a nice RT button to the tweet action buttons that allows you to instantly retweet a post
ReTweeter = {
initialize: function() {
$(".status").each(function(count,status) {
var actions = $(status).find("td.actions div");
var link = $("<a/>").attr({href:"/home/?status="+ReTweeter.reTweetOf(status)});
link.append( $("<img/>").attr({src:"http://railslove.com/rt.gif", alt:"REtweet this"}) )
link.bind("click",function(e){
e.preventDefault();
var status = $(this).parents(".status");
$("#status").val(ReTweeter.reTweetOf(status));
$("#status").trigger("click");
$("#status").trigger("focus");
$("#doingForm").trigger("submit");
});
actions.append(link);
});
},
authorOf: function(status) {
return $(status).find("td.status-body div strong a").text();
},
textOf: function(status) {
return $(status).find(".status-body div span.entry-content").text().replace(/^\s+/, '').replace(/\s+$/, '');
},
reTweetOf: function(status){
return ("RT @" + ReTweeter.authorOf(status) + ":" + ReTweeter.textOf(status)).substring(0,139);
}
}
ReTweeter.initialize();
// RETweet
// version 0.1 BETA!
// 2008-11-14
//
// --------------------------------------------------------------------
//
//
//
// --------------------------------------------------------------------
//
// ==UserScript==
// @name ReTweet
// @namespace http://railslove.com
// @description Adds a nice RT button to the tweet action buttons that allows you to instantly retweet an post
// @include *twitter.com*
// ==/UserScript==
var head = document.getElementsByTagName("head")[0];
var script = document.createElement("script");
script.src = "http://railslove.com/retweeter.js";
script.type = "text/javascript";
head.appendChild(script);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment