Twitter Hashtag Auto-Link

Here’s a little script I’ve made for Greasemonkey to link the hashtags to twitter’s search.

You can download it from here: http://oprod.net/index.php/downloads/category/7-greasemonkey

And here’s the sourcecode:

// ==UserScript==
// @name           Twitter Hashtag Auto-Link
// @namespace      http://oprod.net
// @description    Auto-Links Twitter Hashtags to twitter search
// @include        http://twitter.com/*
// @include        https://twitter.com/*
// ==/UserScript==

var entries, entry;

entries = document.evaluate(
    "//*[@class='entry-content']",
    document,
    null,
    XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
    null);

for(var i = 0; i < entries.snapshotLength; i++) {
    entry = entries.snapshotItem(i);
    entry.innerHTML = entry.innerHTML.replace(/#([^ ]+)/g, '<a href="http://twitter.com/#search?q=%23$1"
title="$1"  target="_blank">#$1</a>');
}