Tweet Tweet...

As the title suggests, let's see you javascript-guru's break out the grease and integrate twitter. This is absolutely necessary because the community has a sharp division over what SO is, and is not. Some say twitter should be avoided because SO isn't a social-networking site, and yet many of us find twitter to be a part of our normal every-day life.

Start your engines. And integrate "Tweet This"!

Hello World: http://twitter.com/home?status=hello+world


1 Answer 1


Preview of SOtweet

..and it works

// ==UserScript==
// @name           SOtweet
// @namespace      org.neverfear.sotweet
// @include        http://stackoverflow.com/*
// @include        http://serverfault.com/*
// @include        http://meta.stackoverflow.com/*
// ==/UserScript==

// Set CSS style
var style = window.document.createElement('style');
style.type = 'text/css';
style.innerHTML = '#tweeeet{display:none;position:absolute;left:30%;top:40%;width:350px;height:100px;padding:10px;background:#9AE4E8;-moz-border-radius:10px}#tweetmsg{display:none;} #tweetsubmit{display:none}';

  function GM_wait() {
    if(typeof unsafeWindow.jQuery == 'undefined') { 
    } else { 
      $ = unsafeWindow.jQuery; letsJQuery(); 

  function letsJQuery() {
    function getTinyURL(longURL, success) {
        var API = 'http://json-tinyurl.appspot.com/?url=';
        var URL = API + encodeURIComponent(longURL) + '&callback=?';

        $.getJSON(URL, function(data){
            success && success(data.tinyurl);

    // The tweet'ify div, shown by the tweet link
    $('body').prepend('<div id="tweeeet"><form id="tweetform"><div id="tweetloading"><img src="http://stackoverflow.com/content/img/ajax-loader.gif" width="24" height="24"><span id="loadingmsg"></span></div><p><img src="http://img189.imageshack.us/img189/6721/twitterlogotransparent.png" width="27" height="26"><textarea rows="3" cols="40" id="tweetmsg"></textarea></p><p><input type="button" value="Close!" id="tweetclose">&nbsp;<input type="submit" value="Twitter\'ify it!" id="tweetsubmit"></p></form></div>');

    $('.post-menu').append('<span class="link-separator">|</span><a href="#" id="tweetifylink">tweet</a>');

    $('#tweetifylink').bind('click', function(){

      // Show loading thingy, hide form until tinyurl is grabbed
      $('#loadingmsg').append('Getting TinyURLified address');

      $('#tweetclose').bind('click', function(){

      getTinyURL(document.location, function(tinyurl){
        // TinyURLification complete, enter into tweetmsg input, submit
        $('#tweetmsg').val(tinyurl + ' "' + document.title +'"');

          var submiturl = 'http://twitter.com/home?status=' + encodeURIComponent($('#tweetmsg').val());
          window.location.href = submiturl;



  • Make tweet buttons on each answer submit the link to the answer's permalink, not the question
  • Tidy up CSS styles from a single-line string
  • Tidy up HTMl additions from a single string
  • Truncate title if too long
  • Use #stackoverflow/#serverfault/#metaso hashtag, and remove - Stack Overflow/etc from message?
  • Move imageshack-hosted Twitter logo into data: URI?
  • Only add styles on-click, rather than at the scripts top level?
  • Dim page background when popup is added
  • Look for http://is.gd JSONP service, instead of tinyurl (shorter URL)?
  • Add support for SuperUser
  • is there an install script for this? if not how do you manually install a greasemonkey script Jul 13, 2009 at 15:58
  • 2
    Firefox > Tools > Greasemonkey > New User Script
    – Sampson
    Jul 13, 2009 at 16:00
  • I can see this build out the twitter URL, but nothing seems to happen after that...
    – RSolberg
    Jul 13, 2009 at 17:14
  • 1
    I hope this script puts the integrate a "Twitter Link" requests to bed.
    – ahsteele
    Jul 13, 2009 at 17:24
  • 1
    @ahsteel: that request is just getting started... GreaseMonkey scripts don't work on all platforms...
    – RSolberg
    Jul 14, 2009 at 7:07
  • @RSolberg which platforms? You mean outside the Firefox ecosystem? Assuming you mean only those that aren't using Firefox if it is that important to them they can use Firefox and Greasemokey for SO.
    – ahsteele
    Jul 15, 2009 at 17:15
  • 1
    dbr: You forgot Superuser! Also, how about bit.ly instead of is.gd? Sure the URLs will be a bit longer, but I like their support for metrics. Jul 19, 2009 at 16:00
  • Another thing: It doesn't seem to work for tweeting answers, just questions. Jul 19, 2009 at 16:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .