A Consuming Experience

Thoughts on my experiences as a consumer of products, services, people (well maybe not that last one...), from reviews to raves, rants and random thoughts - concentrating on technology, gadgets, software, product usability, consumer issues, customer service. Including some introductory guides and tips on various subjects (like blogging!) which stumped me until I figured them out. And the occasional ever so slightly naughty observation.

Deutsch | Español | Français | Italiano | Português | 日本語 | 한국어 | 汉语

Add this blog to Del.icio.us, Digg or Furl | Create Watchlist for this blog

Add this blog to my Technorati Favorites!


Blogger: fix toolbar problem with "Keep current time", other Greasemonkey scripts

Monday, April 16, 2007
Deutsch | Español | Français | Italiano | Português | 日本語 | 한국어 | 汉语
Add this post to Del.icio.us, Digg or Furl | Create Watchlist




This post is on fixing the Blogger toolbar problem with the Keep current time Greasemonkey script. It might be of interest to those trying to fix other Greasemonkey userscripts which produce the same toolbar problem.

The problem

After a recent upgrade to the free Greasemonkey extension for the Firefox browser, my Blogger post editor toolbar stopped working - click a toolbar icon, nothing happened, even the preview link and the button for posting pics stopped working.

I tracked the problem down to a conflict with Jasper's Keep Current Time userscript, which Aditya had updated for the now feature complete fancy New Blogger, formerly known as Blogger Beta.

That free userscript, for those not familiar with it, is essential if you write draft posts for publishing at a later time - because if you don't have the script, you have to manually change the post date and time before you hit Publish, otherwise Blogger gives your post the date and time of when you originally created the draft, not the date and time you published it (which in my case can be weeks or even months later!). Then you wonder where the post has gone... (more on Greasemonkey and Firefox for those not familiar with them). The script adds to the Blogger post editor a "Keep current date/time" box, pre-ticked, which ensures that your post is "stamped" with, you guessed it, the current date and time of when you publish it:


Fortunately, Kirk came to the rescue yet again. That man's armour is even shinier than the mirror on the LG Shine, I tellya. Well, he sure spanked that monkey into submission.

Fixes and changes

He's updated the userscript to:
  • fix the toolbar problem - it's working properly again!
  • fix a bug that bit when you published a post between 12 noon and 1 pm (which gave the post a time of 12-something am - I only noticed it because I happened to publish a draft post at that time, and wondered where my post had disappeared to), and
  • sort the spellcheck problem which Kato spotted, it's working on my system and Kirk's too, at least - bonus!
  • tweak the part which keeps the post options field open automatically - it closed when you toggled between edit / compose mode, but now it stays open.
If you've suffered the Blogger toolbar icon or spellcheck problem, you can now download the updated script from Aditya's blog. Use that instead, and you're sorted. You should be able to install it over your existing Keep Current Time script, if you've already got it.

What's more, Kirk's solution for the toolbar issue may be of more general interest, because it might help others solve similar problems with the Blogger toolbar conflicting with some other Greasemonkey scripts. So I'm going to set out Kirk's explanation here, in more detail, for developers and others interested.

The reason for the problem, and the solution

The issue is down to a timing mismatch between the Greasemonkey and Blogger scripts. Either Greasemonkey is now running faster, or Blogger is running slower (or both!).

In other words, either Greasemonkey version 0.6.8+ is generating its scripts a bit faster than before, or Blogger's addition of new scripts (which they recently did, for the video stuff Kirk spotted) has delayed their form script in the execution order so that it comes in later than it did previously.

Greasemonkey always waits until the DOM is loaded before it executes (it needs a page before it can modify it), but what was happening was that with the new Greasemonkey version (or Blogger's adding of new scripts), Greasemonkey was executing the Keep Current Time script just a tick or so ahead of the Blogger script.

The Keep Current Time script adds a form checkbox with an ID. The Blogger form.js comes in just behind it, and does some checking and looks for forms - but with names instead of IDs. And this is where it was choking. It had a new form element which didn't have a name as expected, causing the whole Blogger script to fail... and the formatting buttons etc in the toolbar not to work.

It's not uncommon to have to make Greasemonkey wait a little longer with Blogger, as some of the things in the post editor don't get added until all the scripts load, and you can't work on them until they do (for an example see the Magical Sheep Technorati tagger).

What Kirk basically did was to wrap the whole Greasemonkey userscript in an onload function, so that it now waits until all the Blogger scripts (in particular the form.js) have loaded, before executing. And that solved the problem very neatly.

Thanks to Kirk the Monkey Master, as always!

Labels: , , ,

| View blog reactions | Links to this post | Post a comment or view 5 comment(s) | Subscribe to Post Comments [Atom] | Subscribe to all comments on all posts