Middle Click Close For Safari
January 23rd, 2008 13:14:00
I love Safari on my shiny Mac Pro, particularly because it’s so much faster than Firefox. But one thing I missed from Firefox was being able to do a middle-click on a tab and have it close. After several failed attempts, I finally got some help from Mark Rowe who pointed me to a proper method-swizzling implementation. After switching my code to use that swizzler, everything fell into place. I’ve been happily using it ever since, I just never released it. I got an email the other day asking for it, so here it is.
Unlike my Export to Archive plugin for iPhoto, I didn’t build an installer for this one. It’s easy to install, but you still have to do it yourself. And there’s a dependency: SIMBL. Now, before Leopard shipped the word was that Input Managers would no longer be supported. After Leopard shipped we saw that wasn’t entirely true. So, once you get SIMBL installed and working, using my plugin is easy. This should work on both Tiger and Leopard. I’ve only tested it recently on Leopard, but I originally wrote it on a Tiger system.
- Get the binary package: MiddleClickClose.zip
- Create ~/Library/Application Support/SIMBL/Plugins if it doesn’t exist
- Unzip the MiddleClickClose.zip into this directory. You should end up with a directory called MiddleClickClose.bundle
- Restart Safari
If all goes well, you should now be able to use your middle mouse button to close Safari tabs. It works for me. If it doesn’t work for you, run the OSX Console and look for “MiddleClickClose loaded” in the “Console Messages” section.
If you want the source code, download it here.
I should mention that this really is a dirty hack, and may not work with future versions of Leopard. It works for me, but your mileage may vary. I hope it works for you, but it may not.
This code is distributed under the GPL v2.
March 21st, 2008 at 12:12:55
Hi,
I love MiddleClickClose, but since upgrading to Safari 3.1 it doesn’t work anymore..
Are you planning on making it compatible?
Kind regards,
Lorenzo
March 21st, 2008 at 14:17:43
Yes. I’ve got it working again and will be releasing it later today.
April 14th, 2008 at 04:14:39
You are a legend! Thank you.
Safari should have this along with the middle click on back button opens a new tab by default.
Matt
April 15th, 2008 at 19:05:10
Works great with Safari 3.1, thanks for this!