Writing Greasemonkey User Scripts for Firefox and Chrome

Greasemonkey was initially only a Firefox extention but due to its popularity it’s quickly adopted by major browsers. Since Opera takes a very small market share, here on the topic of cross browser user scripts, I’m only going to talk about Chrome and Firefox. As for Internet Explorer, I just don’t like it.

Now Chrome doesn’t need an extension to enable user scripts. It had the functionality built in. But the way it handles the scripts is quite different from Firefox’s. At first when I wanted to test if my Greasemonkey script worked in Chrome, I tried to figure out where it stored the script. That’s the way I always do in Firefox – just right click on a user script and edit, save and refresh to see it in effect right away.

Continue reading “Writing Greasemonkey User Scripts for Firefox and Chrome”

“Google Reader Unread Count in Gmail” Script Again

After Google unveiled its “plus” social network to combat Facebook, its whole product line got an interface update and my “Google Reader Unread Count in Gmail” Greasemonkey script no longer worked. So it’s time to update it again.

Install latest version.

Google Reader Unread Count in Gmail

Now it seems Google hides Reader link in the “more” drop down. Or at least it’s the situation in my account. Anyway, If that’s the case, my script will swap it with the last one in the menu bar.

What’s more, It now supports Chrome! Day by day I’m getting more used to Chrome and discarding Firefox. And looking at the market share data, Chrome is also making great progress.

Google Reader and Readability, Kindle

Readability has browser extensions for reading current page or sending current web page to Kindle, but I read a lot in Google Reader where many articles are on the same page. It seems that Readability staff considered this feature and did investigate on that. But until now I didn’t find a mechanism for Reader’s native send to feature to work with Readability. So I spent several hours writing this Greasemonkey script, so far very happy with it.

Click here to install. It supports both Chrome and Firefox. After it’s installed, open Google Reader and view any entry, you’ll find Readability’s button on the right of the actions bar below the entry content. Like this:

Google Reader Readability Send To Kindle

If you don’t already know Readability, you should try it. After clicking the button, the article is saved to your reading list in your Readability account, and Readability sends (after some processing to make it “readable”) it to [your name]@free.kindle.com. Then when you connect your Kindle to a WIFI spot, the articles are automatically downloaded.

Basically I utilized the JavaScript from Readability’s publisher tool. Luckily they didn’t obfuscate the code and it indeed has good readability :) Anyway I think Readability should develop a page which can be used in Google Reader’s native send to popup. That would be easy and better than my script, since I have to update it every time Google Reader interface changes or Readability updates their JavaScript library.

A minor issue of readability is that it doesn’t extract the redirected URL so all the articles from blogs using feedburner’s service will seem to be from feedproxy.google.com and in readability’s account you’ll see feedburner’s favicon displaying before most items.

Using ImageMagick for WordPress Thumbnail Generation

When you upload an image in WordPress, the blogging software tries to generate several scaled versions of the images uploaded. So after it’s done, WordPress provides 4 different sizes of the image for you to insert into the post – thumbnail, small, large, original.

I noticed that for my WordPress install, only the original image was available and the other options were disabled. The reason is that the PHP on my server was compiled by me myself and I didn’t compile many of the extensions. WordPress uses GD extension for thumbnail generation. But this time I didn’t recompile PHP with GD (I didn’t know how to compile GD alone as an extension). Instead I used ImageMagick and here’s the whole process.

Continue reading “Using ImageMagick for WordPress Thumbnail Generation”

Switching to Chrome (from Firefox)

The other day I left my Linux desktop on for several hours and when I came back, it seemed everything hung there. I managed to open `top`, and found the cause being Firefox eating up all the memory. Long ago I complained that and somebody told me that it must be some extension. But anyway I’m considering a switch to Google Chrome seriously. Now, several days later, I’m quite happy with Chrome and here is my summary.

Continue reading “Switching to Chrome (from Firefox)”

Crontab Command Substitution not Working – Solution

By default crontab sends the cron job output to /var/spool/mail/{username} but this time I wanted one of my daily cron job to write to a different log file each day. So I changed it to something like:

30 2 * * * myscript.sh &> /.../`date +%F`.log

But the next day I found that the script didn’t run at all. I tried to copy the command and execute it directly in shell – it worked. Then I looked at /var/spool/mail/{my username} and found the following error message:

/bin/sh: -c: line 0: unexpected EOF while looking for matching “’
/bin/sh: -c: line 1: syntax error: unexpected end of file

At last I found that it was because of the “%” character. Percent symbol has special meanings in crontab. Escaping it with backslash solves the problem:

30 2 * * * myscript.sh &> /.../`date +\%F`.log