afuna: Cat under a blanket. Text: "Cats are just little people with Fur and Fangs" (Default)
I am playing with the thought of sharing the extensions I wrote/talked about in my previous entry. I feel like at least one other person could benefit from it!

But on the other hand, I'm feeling unsure of myself: I based the idea on a very useful Firefox extension (Copy Link Text), and I based the final working code on another Google Chrome extension (Auto Copy).

And then there's the matter of putting up $5 to be able to submit to the gallery! (It's not purely the cost, but it's the cost being enough of a speedbump that I'm making myself think about whether I want to do this or not).

I want to share, but I also feel like I don't have sufficient whatever to share. Ugh. Will try this again after getting some rest; that sometimes helps.
afuna: Cat under a blanket. Text: "Cats are just little people with Fur and Fangs" (Default)
Have finally redownloaded Google Chrome because I need it for some troubleshooting. Before doing so, I looked up how to disable auto-update, and discovered that it's now a matter of changing a setting via the Terminal, rather than deleting the auto-update program. This seemed a lot less virus-like creepy, so I have Google Chrome on my system right now, and feel okay about it.

While moving over settings, I discovered I'd have to restart Firefox -- shutting down Firefox took over an hour! And ate up all my CPU! I had to force-quit it after all; luckily didn't lose any data.

As a bit of amusement, I decided to see what it would take to get me to switch over to use Google Chrome regularly. At a minimum, I'd need:

  • Adblock and/or JS blocker (I went with Adblock, but I'll try to retain all my casual browsing on Firefox with NoScript on)
  • Something to keep count of open tabs (settled on TabGlutton)
  • Ability to quickly edit and preview CSS (probably somewhere, but I haven't looked for it; just the current hacky ways are enough for now)
  • Firebug or equivalent (built-in)
  • Greasemonkey script support (built-in)
  • ReadItLater (Found ChromeItLater; slightly clumsier than the official extension Firefox, but workable)
  • A JS shell (I have a bookmarklet, but I eventually decided to go with the jsshell extension)
  • a JSON prettifier (JSONView for chrome)
  • The ability to copy just the link text instead of the link address

I found what I needed, or a good-enough equivalent, for everything but the last one. Searching through the extensions site and through the greater web turned up nothing. So.... I ended up writing my own.

screenshot )

It didn't take long; however, figuring out the difference between the content_scripts side (which lets you manipulate the webpage) and the main extension body in background_html (which lets you manipulate the browser behavior) took some doing.

The basic "hello world" example shows you how to create a regular extension, one which interacts with the browser. It took me an embarrassingly long time to figure out there was something beyond that.

After I figured out that the reason my extension wasn't doing anything was because it was running once when the extension loaded, when it needed to be running once per page, I slowly came to the realization that I'd need something like body.onload. Unfortunately, even after going through all the links from the getting started portion of the tutorial, I had still overlooked the other part of the API which would enable me to interact on a per-page basis (hello content_scripts!). I tried to force it by using chrome.tabs.onUpdated.AddListener... if ( changeInfo.status == "complete" ) as a poor extension writer's body.onload and that worked, but wow was it ugly :D

I can't remember how I found the link, but after finding that section in the documentation, I was more than halfway there.

In my initial version, I tried to programmatically create a range (document.createRange()) to select the text in the content scripts portion of the page. Right after that, I'd rely on some timing hackery to run document.execCommand("copy") (yeah I didn't know this function existed until now either) in the extension trusted area. It worked, ish, but was ugly and hacky and brittle.

Reason I had to put document.execCommand in the extensions area: it seems to need to be run with higher privileges. If it were available to the website, any website could see your clipboard, and that could potentially leak information. Since extensions are more trustworthy -- you choose whether to install them, and I believe they're vetted to some extent by reviewers before they are distributed in the gallery, they are allowed to execute with higher privileges than Joe Random Website.

On the second version, I figured out I could send just the relevant information (the link text) to the main extension body via a communication pipe, and have the copying take place there. That took away all the worst of the brittleness and most of the hackishness (there still is some ;-)), as well as gave me some flexibility for being able to output in multiple formats should I choose to code that in in the future, and I am quite happy with the results.

I can't take credit for it though: I had the glimmerings of the idea on my own, but I didn't actually get it to work until I peeked into the source code of Auto Copy.

So anyway, there it goes. Have made a Google Chrome extension, it wasn't very painful once I managed to wrap my mind around how everything fit together, and I'm happy with the results.

Ohh one final thing: for a long time, I thought that console.log() didn't work in extensions, and struggled with that. It turns out:

a.) console.dir in Google Chrome is the equivalent of console.log in Firebug; and
b.) If your console.log calls are in your main extension body, you need to open the background.html view from the extensions tab, as the console log output is put there. If your console.log calls are in a content_scripts js file, then they'll show up in the webpage

And there! :D
afuna: Cat under a blanket. Text: "Cats are just little people with Fur and Fangs" (Default)
The last time I tried Google Chrome, I was unimpressed by the way it tried to do updates in the background without asking for permission, or any way to opt out. I didn't bother to dig into what it was doing, or why it was doing what it did at the time, just uninstalled.

Still... I'm in the mood to try out new things while setting up my netbook, and I hear that Chrome may be light and efficient enough to be a good choice. I checked out the Google Chrome download page, and it says that installing Google Chrome will add the google repository to my system, so it can automatically check for updates, with instructions to opt out if I don't want it.

Since it uses the package manager, I know I'll be notified if there are updates *but* I'll have control of when, or whether, to install the updates. Contrast that to before, when I could only sit back helplessly and watch as the daemon mounted the disk image, with no way to cancel if it was inconvenient, and no way to trace what it was actually doing. UGH.

Anyway, I'm feeling more comfortable with the idea of installing Chrome onto Linux/my netbook.

BTW, have you all met pollow yet? My laptop is Blanket (my blanket is named MacBook), my netbook is pollow (I hear it's like pillow, only better :-)), my harddrive is partitioned into Pillow and PILLOW-FAT, my phone has no name, my old FAT-32 1GB USB drive is MEOWSER, and my current thumbdrive is DATA-FU.

Yeah, I don't like all the caps either. Damn you, FAT-32 limitations *fistshake*.

ETA: Mac OSX hints just released a hint explaining how to prevent google chrome's updater from running *amused at the timing*
afuna: Cat under a blanket. Text: "Cats are just little people with Fur and Fangs" (Default)
Lately I've been seeing Growl Notifications of a Google Chrome being mounted on my Mac, while I'm not running Chrome, and without my having done any action on my part. (I have been keeping Chrome around out of curiosity because I want to try the beta, but I haven't run it in a while).

I do not know what's been going on, but I can't find any way to turn it off -- I can't even figure out where to start looking. ps aux | grep -i google (look for "google" in all running processes) just shows me a GoogleTalkPlugin... and I don't know what that is for either, or where it is from.

I suspect there's something that's just trying to be helpful, but since I don't know what it is, and I don't recall giving anything permission to do this, I don't like it :p And not remembering whether I gave it permission or not, may be my memory being faulty, but whether I gave it permission before or not, I can't find any way to turn it off now.

So now I'm trying to figure out how to purge Google Talk Plugin and Google Chrome from my system. Anyone run into any of this behavior before? Any idea how to stop it?

ETA: Mrrrr, found it. Google Software Update was installed automatically on my computer, probably when I installed Gears, or checked out Google Earth or Google Chrome. I don't mind being asked for permission to check for updates when I start a program, but having something automatically update without notification or permission makes me twitchy, so I've removed all the google software I don't need, leaving only gears.

I'll also do this as well: and hope that doesn't kill gears.


Friday, December 28th, 2007 07:44 pm
afuna: Cat under a blanket. Text: "Cats are just little people with Fur and Fangs" (Default)
Just discovered the google IM translation bots which I have dutifully added to bitlbee. Now I wonder: is it possible for me to set up my personal gmail account as a bot and play with my mail that way? risk? Also, may not even be possible at all to access email from GoogleTalk. Hmmm. But I bet I can at least access *some* Google services this way.
afuna: Cat under a blanket. Text: "Cats are just little people with Fur and Fangs" (Default)
Oh interesting. If I add "&client=firefox" to the parameters in a Google search, it redirects me from to The navigation links at the top left hand side are different, as are the order of the search results.

Any value that starts with "firefox" will do. For example, these URLs pass me back to

However, taking out the &client, or giving it a value that does not start with "firefox" does not perform the redirect. For instance:

Finally, the redirect doesn't work if I specify the country:

I wonder how it affects people in other countries? I'm guessing it will probably redirect to your country-specific Google domain.

(This all started because a search for "arno tom ponnixry" returned only results for my journal. And then we found out that searching for "aveleh" returned my journal as the fourth result in [ profile] aveleh's Google search, but as the first result of mine. From there, it was a short step to me comparing both URLs for differences, and accidentally stumbling upon the auto-redirect.)