Detect the Vimium Chrome extension

by
, posted

Update: The API has changed since this post.

In short: I made some code to detect Vimium.

Vimium is among my favorite Google Chrome extensions, and if you’re not using it, stop reading this post and go get it! If you’re a web developer and you want to do something when a user has Vimium installed, I whipped up a bit of code.

I add two methods to the document object: hasVimium and onDetectVimium. hasVimium returns whether the extension is detected, and onDetectVimium takes a function and will execute it when Vimium is detected. That’s pretty much it.

Check out the GitHub repository for more info.

Detecting Vimium isn’t foolproof (and can’t be done with existing methods). My code looks for an HTML element with the class vimiumReset. If it’s there, you have Vimium. (This, of course, doesn’t work if you have an element classed with vimiumReset for some reason.)

It’s a tiny bit of code (263 characters when minified)—go and give it a try if you’re looking to add Vimium-specific behavior.