Gmail From Sorter 1.6 unleashed
Having released Gmail From Sorter 1.4 the other day, I continued fiddling with it based Robert’s feedback.
One thing I hadn’t realized was that, as a user of Google Multiple Sign-In, the URLs I see differ slightly from the URLs non-Multiple Sign-In users see. To fix that, I simply relaxed the Greasemonkey @include scope from http://mail.google.com/mail/u/* to http://mail.google.com/mail/*.
I also played around with different methods of hooking into Gmail. Gmail loads in From address fields dynamically, which GFS historically handled by looking for them on the mousedown event. This seemed horrible, so I investigated using other events, such as DOMNodeInserted, DOMContentLoaded and other DOM* events. While some of these events worked, the performance impact they had was horrendous; they caused Gmail to become noticably laggy. Turns out, these DOM mutation events are deprecated for this very reason. I decided to stick with mousedown, and added the keydown event to support those that use Gmail keyboard shortcuts.
In the pursuit of efficiency, I changed the initial Gmail hook-in from using an interval-based check to using the load event, which Firefox dutifully fired. The only problem is that Chrome seems to execute Greasemonkey scripts after the load event has fired, rendering the approach useless. Naturally, there’s always more than one way to do it, but the interval-based approach isn’t that bad, so GFS 1.6 reverted the hook-in changes introduced in GFS 1.5.
Finally, I found out that Opera is also capable of running Greasemonkey scripts, although the installation process is not as seamless as that of Firefox or Chrome. After correctly configuring everything, I tested GFS on Opera and it works just fine. I also updated the GFS Userscripts.org page to include installation instructions for all three supported browsers.
As always, you can download version 1.6 from the Gmail From Sorter Userscripts.org page. Hopefully I don’t need to fiddle with it again for at least another 6 months. :)