Every day I use Gmail and Hipchat. They’re almost always open for me. Whenever I want to quit my browser, Hipchat always asks me if I’m absolutely sure I want to quit. Hipchat accomplishes this by setting a window global “onbeforecallback” to a function. Using Mozilla’s addon SDK, I hacked up a fix:
Not uncommonly, I ran into a snag on the way to my final answer. Due to some JS sandbox issues (I think), onbeforeunload wasn’t actually the right object, so I had to awkwardly insert a script element to get this working.
After I got this working, I reloaded Hipchat, and suddenly felt a rush of excitement: something I wrote changed a product I use every day for the better! If you are a web developer and you haven’t played around with addons with browsers like Firefox, Chrome, or Safari, it’s a fun, empowering way to add a little more control to your everyday web experience. It’s streamlined almost to its perfect form with the addon builder.
Tags: addons, hipchat, mozilla, onbeforeunload