Pages

Showing posts with label Greasemonkey. Show all posts
Showing posts with label Greasemonkey. Show all posts

Monday, 17 December 2007

Blogger: Technorati tagger for multiple word tags fixed






On Friday various changes to the Blogger post editor broke the Magical Sheep tagger userscript (which helps you add Technorati tags easily to your Blogger posts via the Firefox browser, using the free Greasemonkey extension). MC spotted the problem first. Or at least, was the first to point it out to me.

Fortunately that Javascript Jenius Kirk has fixed the user script so that it's all working again. Install the updated script and as long as your Post Options are visible, you'll see the tagger box as before. UPDATE: the script has further been tweaked to make sure the Post Options section stays open permanently even when you switch between Compose and Edit HTML modes. Links below are to the updated version.

If you've already installed the script, you can just install the tweaked script over your existing one and your MeTags etc will be preserved, no need to uninstall anything first.

I've uploaded the updated script to various places (same as before) so that the old links remain usable, but just point to the updated script (too small a fix to call it an "upgrade"!):
- and I've also updated my main post about that tagging tool to note the fix and to update the links there.

If you're a Blogger / Blogspot.com user who hasn't yet installed the script and you'd like to try it, or indeed find out more on what this is all about, see my intro on what are Technorati tags and my Technorati tag creator overview, step by step installation instructions and links.

Maybe those behind the Greasemonkey Gmail API could start turning their thoughts towards a Greasemonkey Blogger API soon? Pretty please?

Saturday, 17 November 2007

Blogger "Keep current time" tool fixed





It's annoying to publish a draft post on Blogger / Blogspot and then realise it's been dated not the date / time when you hit Publish, but when you first created the draft post, which could be days or, in my case, weeks or months ago!

That's one solution to the mystery of the disappearing draft post that you just published - it's just been filed away in the archives at the date and time of the draft post's original creation, that's why you can't see it on your main home page (unless of course you first created the draft quite recently).

Apart from having always to remember to fix the date / time before you click "Publish Post", which I'm terrible at doing, the only consistent easy solution I know of so far is Jasper's free "Keep current time" userscript for Firefox and Greasemonkey, which ensures your published post will always automatically bear the right date and time.

Jasper kindly updated it once, but come the now feature complete fancy New Blogger, formerly known as Blogger Beta, with its widgety goodness and enhanced developer-friendliness, it was Aditya who got the script working with the new Blogger code.

However, during the last month or so the user script has broken again, because of formatting changes behind the scenes at Blogger. When you go to edit a previously-saved draft post, the "Keep current time" box is no longer automatically ticked.

Aditya seems to have been offline for some months now, I assume with his studies, as there's been no activity on his blog for a while, and I've not been able to contact him about this script.

Fortunately Kirk has come to the rescue (as always) and fixed the script so that it now works again, thanks Kirk, mwah! Man I wish Google would roll out an API for Blogger and Greasemonkey, like they did for Gmail and Greasemonkey.

As Aditya's MIA I've uploaded the corrected script so that everyone can benefit from the fixes (Aditya please let me know if you've a problem with that): Get the updated Keep current time script.

How to get the script, for beginners to Blogger / Greasemonkey


Sunday, 11 November 2007

New Gmail Greasemonkey API - & Blogger, please??





Tucked away in an update to a recent official Gmailblog blog post about future behind the scenes changes to Google's Gmail was some good news for Greasemonkey fans.

Greasemonkey is a free extension for the free and wonderful Firefox browser, which lets people write userscripts to do all sorts of clever things to webpages like change the way they look and work, improve your browser security etc - see this post for instance for a Technorati tagging script for Blogger /Blogspot.com, and instructions generally on how to install Greasemonkey and install user scripts too.

Lots of scripts have been written for Google services, even Book Search.The Gmail team appreciated that when they tinker with the underlying code for a web service for which Greasemonkey user scripts have been written, that can mess up existing Greasemonkey scripts. (Previously new releases of Google Reader had broken Greasemonkey scripts too, and there are many Greasemonkey scripts for Reader including with Google Gears).

So to help us all they've released an experimental Gmail / Greasemonkey API which should make Greasemonkey scripts for Gmail easier to write and more resistant to being broken when Gmail code is changed. (The forthcoming changes will apparently involve a new Javascript implementation for Gmail.) Greasemonkey has been used for Google Reader and Gears too

Yay, I say! That should make Greasemonkey gurus like Kirk and Jasper happy.

However, Greasemonkey scripts have been known to stopped working not just when Gmail code changes are implemented, but also when other web services have been changed. Or indeed when Firefox has been updated, or Greasemonkey itself has been updated. You get the drift...

As this blog is on Blogger, personally my biggest use of Greasemonkey scripts is in order to get Blogger, particular its post editor, to work the way I want it to, making up for several shortcomings or gaps I feel exist in the current interface (e.g. prettying up the font). I'd go so far as to say my Blogger Greasemonkey scripts are absolutely indispensable to this blog.

Unfortunately, something must also have changed behind the scenes in Blogger's code these last few weeks, because the Keep Current Date/Time script (essential if you save drafts on Blogger for later publishing), which Aditya had updated for New Blogger, no longer automatically ticks the "Keep current date/time! box when you're editing a saved draft. Also, my script to enlarge the Blogger template editor doesn't work anymore either, boohoo.

So here's hoping that the Blogger team will similarly roll out a Blogger / Greasemonkey API soon too for those interested in the Blogger API, which saw a new Javascript client library recently.

Monday, 16 April 2007

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





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!