Posts

Showing posts from June, 2011

Google +1 Button and Twitter, +1 a Tweet from this Chrome Extension

Image
This weekend I built a simple Chrome Extension which adds the Google +1 button to twitter.com.  The "Tweets +1" extension lets you +1 tweets from directly inside Twitter (well, New Twitter to be specific).  You can now +1 a tweet without ever leaving Twitter, plus see how many other people have +1'd a tweet. Install the Tweets +1 extension and let me know your thoughts.  Of course, it's open source thanks to GitHub.


Tim Bray does a good job explaining what the +1 button is and why we should care.


How it works

This Chrome Extension uses a "content script" which is a fancy way of saying "inject some JavaScript from the extension into an existing web app or web page".

The extension manifest declares which script to embed into the host page, and what pages should use the extension:



The first bit of JavaScript needed to scan through the page and look for tweets inside of the HTML.  Luckily, thanks to querySelectorAll and matchesSelector this was fairly e…