Capturing page loaded events from a Firefox extension

April 6th, 2008

One of my hacks at Over The Air was an attempt to sync browser histories between desktop and mobile. A part of this was a Firefox extension which listens for when I go to a new webpage, gets the URL from the Firefox address bar and sends it to a connected mobile.

As my first attempt at a Firefox extension, I was surprised by how easy this was. I’ve made it, so if anyone wants to learn or build on it, downloading the source may be useful. (Remembering it was thrown together in a bit of a hurry!) But I wanted to highlight a couple of quick points.

Firstly – getting started. Owen pointed me at a brilliant Firefox extension wizard. Fill in the simple form – telling it stuff like whether you want to add an options dialog and preferences, or a context menu item, or a toolbar button, and so on. And it generates you a skeleton Firefox extension ready for you to fill in with code. This probably saved me an hour or two of reading about how to create Firefox extensions!

Secondly – capturing new pages. This was done by adding a listener for DOMContentLoaded events:

var appcontent = window.document.getElementById("appcontent");
appcontent.addEventListener("DOMContentLoaded", 
                            myContentLoadedFunction, 
                            false);

And in my content loaded function, I got the URL like this:

var urlbar = document.getElementById('urlbar');

Over The Air… it’s all over

April 6th, 2008

heading home from Over The Air with our BBC bean bagsHeading home from Over The Air with our BBC bean bags!

Over The Air is all over, and I’m back home again (in time for the first proper snow I’ve seen in years, but I digress… 🙂 ). Just time to jot down a few quick thoughts.

It was talks and presentations in the day, with a hackday competition in the evening.

Read the rest of this entry »

Mobile translation – an unfinished hack!

April 5th, 2008

Fourth of the random ideas for Over The Air hacks – a mobile service that lets you translate foreign text that you come across from your mobile phone.

The plan was to:

  • reuse some old code from last year to control my cameraphone and take a picture
  • upload the image to LeadTools, using their OCR web service to get the text back from the picture
  • translate the text into English using the Google translate API web service
  • display the English text on the phone screen

Unfortunately, too much time spent drinking beer, listening to talks, and generally slacking, meant that I didn’t finish this one.

But I thought it still might be interesting to share my experiences with the LeadTools service.

Read the rest of this entry »

Browser syncing – mobile to desktop

April 5th, 2008

Completing the loop for my browser sync hack for Over The Air – this time, syncing back the browser history from your mobile browser when you get back to your desktop computer.

When you connect your mobile to your computer, the URL history of Pocket Internet Explorer is queried and the most recent item is opened on the desktop using your default web browser.

This was a little tricky to implement and needed me to cobble a few bits and pieces together:

  • A C# service running on the desktop that uses RAPIManager to trap and handle device connection events
    On connection, the service uses RAPI to invoke a process on the mobile…
  • The process on the mobile is something that I wrote in C++ to query the PIE cache – using the FindFirstUrlCacheEntry / FindNextUrlCacheEntry API. The URL retrieved is written to a file on the mobile.
  • The C# service on the desktop transfers the file containing the URL from the mobile, and uses Process.Start to launch it in the desktop’s default web browser

It’s a little icky… but it seems to work!

Browser syncing – desktop to mobile

April 5th, 2008

Third of the random ideas for Over The Air hacks – a browser sync for Windows Mobile.

The aim was to let you transfer your browser history from desktop to a Windows Mobile PDA, so when you leave your desk, you can pick up where you left off in whatever you were doing online.

I’ve written the hack as a Firefox extension, and it currently has two modes:

  • Always on
    Every web page you view in Firefox gets opened on the mobile browser in the background without you noticing. When you disconnect your mobile from the computer, you not only have the most recent page all ready for you in your mobile browser, but you also have a mirror of the Firefox history – so clicking ‘Back’ on your mobile browser will take you back to the previous page you were viewing with desktop Firefox.
  • Single sync
    Take the current page you are viewing in Firefox, and open it on your mobile browser

The toggle to start/stop the ‘always on’ mode, and the switch to perform a single sync are both provided as toolbar buttons.

Install the Firefox extension here

Read the rest of this entry »

Data Capture widget for Windows Mobile

April 4th, 2008

Second of the random ideas for Over The Air hacks – a Data Capture widget for Windows Mobile.

Data Capture widget for Windows MobileScribble a note or capture an idea without waiting for a second or two for an app to be launched!

Enter some text in the box, then tap OK. The text will be appended to a file or Note (of your choice – specify the path it should write to in ‘Options’).

If you tap on the icon, the notes app (of your choice – again, specifying the path to it in ‘Options’) will be launched to the page the widget writes to.

Create an “incoming” or “to be sorted” note or page, and add to it throughout the day. When you’re ready, launch the notes app and go through and process what you’ve collected.

Very GTD. 🙂

It’s a lightweight C++ app, reusing a lot of the code from the Twitter client I posted about earlier.

Download a copy here
To specify paths, go to the Options dialog for “bLADE Wiki Today” from the Today screen control panel applet.

Twitter for Windows Mobile

April 4th, 2008

First of the random ideas for Over The Air hacks – a Twitter client for Windows Mobile.

Twitter client for Windows MobileWhen posting a tweet, the key is speed. I don’t want to wait to launch an app, I don’t want lots of features. I just want something to take my message and post it.

When reading tweets, I don’t mind waiting (e.g. for the list to be gathered).

And on mobile, I don’t really want regular notifications or polling. Following over a hundred people, I’d either hose my phone battery by constantly getting updates, or I’d miss most updates anyway. I just need to be able to see a list of updates when I want.

I went for a Today screen widget for posting, written in C++ to keep it quick and lightweight.
And if you click on the twitter logo, it launches your default browser at the mobile Twitter site http://m.twitter.com/. The best of both worlds 🙂

Download a copy here
To set your username and password, go to the Options dialog for “Twit Today” from the Today screen control panel applet.

Read the rest of this entry »

Over The Air – ideastorming

April 4th, 2008

It’s ridiculously early. And I’m awake. And on a train.

Unusually, I don’t mind too much, because I’m heading to ‘Over The Air‘ – a mobile development event in London. Yay 🙂

Looking at the schedule, there are lots of interesting talks that I want to go to. Too many… in several places there are two or three talks I want to go to at the same time. 🙁

Also on the agenda is a development competition. It’ll probably work out to somewhere between 8 and 12 hours to hack something together (depending on how many talks I go to and how much sleep I want to get!)

Between paternity leave and the joys of coming back to work after a five week break, I’ve not had time to think about what I might create.

So I’m using the train journey to come up with a few ideas – and this is as good a place as any to ideastorm.

Here we go… Bear in mind that it’s early and I’ve not had any coffee yet!

Read the rest of this entry »