Saturday, February 04, 2012


Every once in awhile I get a burr up my butt (usually because there's an application I want but that doesn't seem to exist), and decide it's time to learn to some very basic programming (actually, scripting usually these days) again, using one of those newfangled languages that's very different from Commodore BASIC.

Last time around it was PHP, so that I could make some fairly major alterations to a Wordpress theme. That was a week of sheer terror, and I'm not sure I retained anything I learned, but by golly the job got done.

This time it's Javascript, which I'm trying to use to write a Firefox add-on.  And I'm all thumbs.

The sample code provided by Mozilla for add-on development newbies serendipitously enables the two general tasks I want my add-on to accomplish -- it puts a favicon in the status bar, and when you click on that favicon, it opens a URL.

Modifying the favicon from a Firefox logo to a graphic representing my cool idea was easy. I went to, designed the graphic (actually, I just extensively modified someone else's), released it under a public license, got it hosted at IconJ, (if you want a logo of lips with a mole, called "Marylin," help yourself!) and changed the URL in the sample code.

The next two steps are:

  1. Modifying the sample code to have the URL open in a pop-up window (of a given size, in a given screen location) rather than in a new tab; and
  2. Tapping into a publicly available API to construct that URL dynamically based on the page the user is on when he clicks the favicon.
It's the first of those next two steps that has me flummoxed (the API might bumfuzzle me too, but from what I've read so far, probably not).

It's probably the simplest thing in the world to onclick, etc., but I seem to be messing up the use of brackets, quotes, parentheses and semi-colons and commas in the coding. No matter what I do, the new result when I test the add-on is that now nothing happens. Nothing.

This, too, shall pass.

Or not.

28 years ago, if you threw a BASIC term at me in my sleep, I could give you the syntax, the required and optional arguments, etc., and show you how to use it to do something. Hell, I could tell you how much to add or subtract from X to move a character on the screen in any of eight directions, based on the VIC-20's use of RAM locations as screen memory.

These days the simplest things of that nature are much harder for me to learn and nearly impossible for me to keep straight without frequent recourse to references.

Update: I have no idea why it didn't occur to me to just show the code snippet I'm talking about, so that smart people can advise me. Here's what it looks like (just a modification of the sample code to show my favicon and open a URL -- not the URL the add-on will eventually open, btw):

    id: "whwomyt",
    label: "We Have Ways of Making You Talk",
    contentURL: "",
    onClick: function(event) {

All I'm trying to do right now is make a URL open in a pop-up window, 400 pixels wide and 300 pixels tall, with scrollbars, in the lower right-hand corner of the screen, optionally with the window title "We Have Ways of Making You Talk" (that's the name of the add-on).

But no matter which changes I make (from various web searches on the subject I try), I end up with an add-on that doesn't do anything. It doesn't even show the icon. Which seems to me means that I'm not just getting the command syntax wrong, but that I'm also hooking it into the nested sequences incorrectly such that it prangs even the first part of the code.

Yes, I know that this is pretty lame. Believe me, I wouldn't have tried to crowdsource the solution if I hadn't already tried 14 different ideas of my own about where all those brackets, etc. go.

After I get that part figured out, I dive into Disqus's API and try to figure out how to make that newly opening window be a) the existing Disqus comment thread for the URL of the page the user is on, if there is such a thread (thus preserving the site owner's moderation authority, etc.), or b) a new Disqus comment thread, if the site in question doesn't use Disqus.

If I can figure out how to do that, then I will have implemented my harebrained "universal commenting" scheme as a Firefox add-on. After which I'll be back here asking a bunch of stupid questions about how to code Chrome extensions.

blog comments powered by Disqus
Three Column Modification courtesy of The Blogger Guide
Some graphics and styles ported from a previous theme by Jenny Giannopoulou