Day 32 – Old School Twitter Retweet

Modify the Twitter web interface to provide the old school “RT” functionality that many other Twitter clients provide.

ruleset a60x532 {
  meta {
    name "old-school-retweet"
    description <<
    author "Mike Grace"
    logging on

  dispatch {
    domain ""

  global {
    css <<
      .old-school-enabled .old-school-rt {
         background: url("") no-repeat scroll 0 0 transparent;
         background-position: -176px 0;
         display: inline-block;
         margin-bottom: -3px;
         margin-right: 3px;
         position: relative;
         vertical-align: baseline;
         height: 12px;
         margin: 0 2px;
         outline: medium none;
         text-indent: -99999px;
         width: 15px;

  rule twitter_page_loaded {
    select when pageview "twitter\.com"
    pre {
      oldSchool =<<
        <a class="old-school-retweet-action" href="#"><span><span class="old-school-rt"></span><b>RT</b></span></a>
      emit <|
        $K(".stream-item").live("mouseenter", function() {
          var $tweet = $K(this);
          if ( $tweet.hasClass("old-school-enabled") == false ) {

            $tweet.find(".old-school-retweet-action").click(function() {
              var tweet = $K(this).parents(".tweet-content").find(".tweet-text").text();
              var name = $K(this).parents(".tweet-content").find(".tweet-screen-name").text();
              var retweet = "RT @"+name+" "+tweet;
              $K(".draggable textarea.twitter-anywhere-tweet-box-editor").val(retweet).focus();
              $K("#tweet_dialog a.tweet-button.button.disabled").removeClass("disabled");
  • 38 html to emulate same style/layout as other twitter action buttons
  • 43 add the RT button when a user mouses over a tweet
  • 45 only add the button if it hasn’t already been done
  • 48 bind click handler to newly added RT button
  • 49 get the tweet text when the RT button is clicked
  • 50 get the username of the tweeter the tweet came from
  • 51 build new tweet in RT style
  • 52 use Twitter’s jquery to trigger a click on the new tweet button
  • 53 put the cursor in the tweet box and put the RT in the box
  • 54 enable the tweet button so user doesn’t have to type before being allowed to tweet

Tweet moused over after running app on as a Chrome extension

Get the extension to try it out yourself! (Chrome / Firefox / IE)

Gratuitous day 32 Grace face

This entry was posted in Kynetx. Bookmark the permalink.

One Response to Day 32 – Old School Twitter Retweet

  1. Pingback: Old School Style Retweets Via Kynetx App – Michael Grace

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s