Middle Click Close For Safari
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.











Lorenzo:
Hi,
March 21, 2008, 12:12:55I love MiddleClickClose, but since upgrading to Safari 3.1 it doesn’t work anymore..
Are you planning on making it compatible?
Kind regards,
Lorenzo
Joey Gibson:
Yes. I’ve got it working again and will be releasing it later today.
March 21, 2008, 14:17:43Matt Martin:
You are a legend! Thank you.
April 14, 2008, 04:14:39Safari should have this along with the middle click on back button opens a new tab by default.
Matt
Alex:
Works great with Safari 3.1, thanks for this!
April 15, 2008, 19:05:10Javier:
How do you install SIMBL, where do i get SIMBL from?
September 18, 2008, 15:33:12sorry if this sounds like a silly question i’m new to this.
joeygibson:
Javier, SIMBL is available from http://www.culater.net/software/SIMBL/SIMBL.php There are directions there for installing it (basically just unzip it to the proper direction).
September 18, 2008, 15:50:19PedroCC:
jesus dude, i love this, thanks
September 19, 2008, 17:49:00Jack:
Hey, just grabbed SIMBL and set this up. Amazingly useful; thank you.
September 22, 2008, 13:12:24joeygibson:
Thanks, Jack. It’s a dirty, dirty hack, but until Apple builds this functionality into Safari, it’s all we have. I actually wonder if Apple will ever include something like this, since the Mac culture is so against multi-button mice.
September 22, 2008, 13:47:12Tony:
Love the plugin, but since I’ve installed it I’ve noticed more and more Safari hangups and crashes. It’s fairly infrequent but can be a bother.
November 8, 2008, 03:50:26