AutoLink user script
AutoLink turns plain text URLs, email addresses, bug numbers, ISBNs, and US phone numbers into links. For example, it turns all of these into links:
- http://www.squarefree.com/userscripts/
- jruderman@gmail.com
- Bug 162020
- Bug 162020 comment 0
- ISBN 0-340-82899-4
- (555) 555-5555
You can add new filters if you know how to use JavaScript regular expressions. Here is an example filter, rewrapped to fit in my blog:
{ name: "Bug number", regexp: /bug \#?(\d+)/ig, href: function(match) { return "https://bugzilla.mozilla.org/show_bug.cgi?id=" + match[1]; } }
To install a user script into Firefox, install Greasemonkey, restart Firefox, open the user script, and select "Install User Script..." from the Tools menu.
May 22nd, 2005 at 9:00 am
Excellent, I’ve been using your AutoLoginJ, Valid XHTML, Bookmarklets to User Scripts and have now added AutoLink. They’ve become indispennsible.
Thank you.
May 22nd, 2005 at 10:08 am
Can I replace linkification with this? Or is it not as good when it comes to detecting links?
May 22nd, 2005 at 10:44 am
Very nice: excellent job of keeping your modifications obvious.
The ISBN regex needs a couple-three tweaks: they can be either \d-\d{3}-\d{5} or \d-\d{2}-\d{6}, and the last “digit” is a check digit that’s (mod 11) of a weighted sum of the rest, so it’s actually [\dXx], and I have the feeling that I’ve seen a fair number written with spaces instead of the correct dashes, but I’ll have to look around to see if that’s really true.
May 22nd, 2005 at 10:46 am
[…]
davidbisset.com
Greasemonkey: AutoLink User Script Turns plain text URLs, email addresses, bug numbers, ISBNs, and US phone numbers into links. [ via […]
May 22nd, 2005 at 11:48 am
Wups, I was still being anglocentric: we also want to match “Historia de la PsicologÃa. ISBN: 94-309-2299-7.” Per the hyphenation instructions, the first hyphen can be after one to five digits, the second hyphen can be after three to eight digits, and only the third hyphen is fixed before the last digit/X. Um. ((\d(-)?){9}[\dXx]) maybe?
May 22nd, 2005 at 11:02 pm
That is some excellent JavaScript. I have a small quibble with it though — it seems to be putting a lot of functions and variables in the global namespace. Could it be wrapped with function() { … } or something of the sort?
May 22nd, 2005 at 11:36 pm
Aankhen, Greasemonkey 0.3.3 and higher does that automatically.
May 23rd, 2005 at 12:24 am
Thanks Phil. I uploaded a new version that uses your regular expression.
May 23rd, 2005 at 5:28 am
This script does not appear to be gmail friendly… shrugs..
May 23rd, 2005 at 5:41 am
Curious, can you elaborate on what’s wrong with the script at Gmail for you? It has some special-casing for Gmail (search autolink.user.js for “Gmail”), and it works for me at Gmail.
May 23rd, 2005 at 8:24 am
Bahh humbug… had an old version of Greasemonkey!
May 23rd, 2005 at 2:29 pm
[…] ;
May 23, 2005
greasmonkey AutoLink
Filed under: sweet, cool
Jesse Ruderman » AutoLink user script This is so great. A long long time the thing I’ve […]
May 24th, 2005 at 11:50 am
This should be added to the script. It is for the UPS, USPS, and FedEx tracking.
May 27th, 2005 at 4:13 pm
In Conjuction with a certain userscript my Firefox would leak memory until it grew to sizes of over 150MB. I am in the process of tracking it down to a certain user script, and I think it _may_ be Autolink. Therefore I wanted to ask if anybody else has made similar observations?
May 28th, 2005 at 10:40 am
Great tool! Unfortunately, it often gets confused by ‘bold’ tags that often occur in the middle of search results in Google or Gmail. I’ve posted fixes on my blog to solve this issue.
See http://www.cs.toronto.edu/~james/firefox/2005/05/bold-autolinking-using-greasemonkey.html
May 30th, 2005 at 11:47 pm
Autolink will turn:
http://www.squarefree.com/userscripts/
into a link, but will it turn
http://www.squarefree.com/userscripts/
into a script, as well?
June 5th, 2005 at 7:49 am
Greasemonkey User Script for Washington Post RSS Query Strings
Greasemonkey is a Firefox extension that allows changing the behavior of websites through the addition of “user scripts.” User scripts are also supported in the latest version of Opera, and in Internet Explorer through Trixie and the not-y…
June 24th, 2005 at 1:06 pm
What about links like hxxp? How can they be transormed into valid?
June 29th, 2005 at 1:23 am
Top quality script, very usefull!
August 29th, 2005 at 12:58 pm
Beautiful work on the detail finish, playing nicely even in harsh page environments!
I’ve done a tiny but useful modification to the script, adding an optional scope regexp parameter. When a filter is equipped with one, the filter will only be applied for pages whose URL matches the provided regexp. It’s mainly useful for keeping local environments separate, such as linking ticked id:s on your corporate network to the company issue tracker, while still linking bugs on the rest of the web to mozilla.org.
Diff: http://www.lysator.liu.se/~jhs/userscript/*/autolink.diff
August 31st, 2005 at 1:35 pm
Should this work with Greasemonkey 0.5.1? It doesn’t seem to do anything when I installed it using that version.
September 5th, 2005 at 10:43 am
The examples at the top of the page do not seem to work in 0.5.1 (making an attempted demostration of the Autolink script go horribly awry), but the user script does seem to work on other pages.
September 6th, 2005 at 1:04 am
Martey, I had the same problem using Greasemonkey 0.5.1 with branch nightlies of Firefox. I upgraded to Greasemonkey 0.6.1 and now it works.