I found myself waiting yesterday. Nothing seemed to be working out. I have a code review that isn’t really moving. And the lab resources weren’t in a usable state so I was rebuilding them.
And so it happened that I spent much of yesterday hacking on Chrome extensions. It's published to the Chrome web store and the source is on github.
The Assignment
I gave myself a short assignment to add button that gives me the html text of the work ID and description of a work item wrapped in an a-href, automatically copied to the clipboard.
This is a repeat-pattern that shows up in my work because I track my active tasks in Evernote so that I can get one-click access to the items on our internal Salesforce instance, which we use to track just about everything.
Usually this involves 6 steps:
- copy the work ID text
- paste into Evernote using plain text paste (CMD-SHIFT-v)
- copy the description text
- paste into Evernote
- copy URL
- select the text in Evernote, and apply URL to the text (CMD-k, CMD-v)
It doesn't take that much time to do this process manually but it's not a good use of time either and requires that you setup a couple of windows side by side.
A “Short” Assignment?
So I did what I usually do which is to spend a chunk of time trying to figure out if I can make this easier, and there was the potential that my effort could fail yielding nothing.
Onward! It was an hours-long exercise in google-fu and debugging.
I had to learn about how chrome sandboxes different parts of the extension to keep the browsing secure.
- My extension adds a button, which loads a popup html page, and its own javascript file.
- There is also a “content script” which can interact with the page loaded in the browser tab. I put the code for grabbing values from the document in the content script.
- Then, to allow for communication between the two, I have to add some messaging hooks. A listener on the content script, which replies to the popup with page data.
Chrome has this tendency toward asynchronous calls with callbacks and I’m not quite getting how to return values out to my main logic area. So I’m not proud of the code because I just got around it by nesting a lot of closures. But it works for now and I’ll pretty it up later.
Wasting Time?
You might consider this to be wasting time. It is certainly not productive in any way that I am measured in my job.
But, this is who I am.
What did I do over the years to acquire the skills that I possess in automation? I took the long and hard way. The way with some pricey-looking up-front costs.
You have to be willing to do things badly.
You have to be willing to do things slowly.
Paraphrasing Paul Graham: innovation tends to be heretical.
I was not very productive yesterday. And I didn’t even write elegant code.
And yet, I enjoyed the way I used my time yesterday. I’ve always been willing to do things the slow way up front so that I can do it methodically via code. It’s an investment and generally a more enjoyable experience than brute copy-paste efficiency.