Twitter: raymondcamden


Address: Lafayette, LA, USA

New Chrome Extension - Kittenify

12-11-2012 3,889 views Development, JavaScript Comments

I had an hour to kill this morning before a day of meetings, so I built a new Chrome extension - Kittenify. While not exactly rocket science, it simply takes all the images in a page and replaces them with calls to placekitten.com. As an example:

Stupid, I know. ;) But it did answer one question I had about Chrome extensions. In the docs I saw, there is always an HTML page tied to the click event of icons in the browser UI. I wasn't sure how to simply run random JavaScript code on the click event. Turns out it is rather simple.

First - specify a background JavaScript file and do not specify a default_popup for browser_action. Here's my manifest.json:

Then simply add an onClicked event for the browserAction object. I didn't even know this was possible. (See, this wasn't a waste of time!)