What would you do if you didn’t have to work?

Workhacks

Lottery tickets offer us the dream of escaping to a different life. Often I find myself wondering what it would be like if I didn’t have to work full time. I always imagine spending more time on my open source software projects, getting in better shape and doing some freelance consulting to pay the time.

About ten years ago I got to see my parents make the transition from working full-time to retirement. It wasn’t an easy switch for them. There was some sadness, a lack of motivation and a lonliness as they lost the human contact the workplace gave them each day.

Now, this isn’t anything special by any means. I know that there are tons of people out there who have given up the daily slog of 9-5 to be a full-time internet marketer.  Some people have even started trading stocks and forex while still in their pyjamas. I know one guy who know makes around £20,000 a month by trading currencies in his bedroom.  He uses a service called spread betting, which allows you to take positions on the financial market with much smaller deposits than you would traditionally need to. Spread betting allows you to trade on whether a market will move up or down, with you profiting if the market moves in your direction. I think he said he found his current broker at http://www.spreadbettingbonus.co.uk. Needless to say, with all the furore surrounding Syria and now Russia, it has been a turbulent time in the financial markets with a lot of volatility. He tells me that this is the perfect time to start spread betting and I’m inclined to believe him.

Anyway, for the past two months I’ve gotten to experience what it’s like not to work every day. I was laid off from my previous job with severance. While I money wasn’t tight, there wasn’t enough to jet set off to Europe or go on any big vacations other than the ones I already had planned for the summer. I was stressed out most of the time until I found myself a new job. After I accepted the job offer, I gave myself a big window until I had to start so that I could relax and enjoy my time off.

This was the longest stretch of time I had booked off; it has been 14 years since I’ve had that much time to myself all at once. When I was working, I imagined all the web projects I could do if I didn’t have to go to work. The reality of the experience was quite different. Once you have the freedom to do anything you want with your day, sitting in front of the computer is the last thing you want to do.

For the first few weeks I found myself irritated by 3pm every day. I quickly realized that it was the lack of structure; if I got myself out of the house the feeling went away. So time was spent walking around the city, going to the library and reading in coffee shops. The beautiful weather really helped. Why stay inside on a sunny day if you don’t have to? Part of it was a desire to be around real people, instead of the virtual people I usually associate with if I’m stuck on a computer.

There was a definite priority shift. With the freedom to do anything I wanted with my day, it made so much more sense to focus on those long term, important but not urgent goals. Organizing things around the house. Getting a new family doctor. Renewing my passport. Getting new contacts. Removing clutter from my house and my life. I had to laugh one day when I found an old to-do list from 2006. There was stuff on that list that was important to my life and my well being that I was finally getting around to.

I found it amazing how much clearer it was to process my task list and choose the most important tasks for the day. Because I felt no urgency in any of my tasks, I was able to make much better decisions about what was important vs what wasn’t even worth doing.

I’m about to enter the workforce again, and I hope I can take some of the clairity I currently feel with me.

Dude, your online portfolio sucks

I’ve been browing through my local photographers looking for family portrait photographers and wedding photographers. As someone who is very familiar with the web, I’m always struck at how poorly some people do their web portfolioes.

How Do They Find You?

Like anything, the most important thing about a photography site is how it ranks on google for location + keyword searches.

  • http://www.google.ca/search?q=ottawa+photography
  • http://www.google.ca/search?q=ottawa+wedding+photography
  • http://www.google.ca/search?q=ottawa+portrait+photography

I’m sure that ottawaportraitphotographers.com does quite well when it comes to new clients finding them via Google.

The Good

I chose my wedding photographer because he uses a blog to display his pictures. The pictures are big enough that I can see the quality, there isn’t anything hiding the images, and enough pictures load all at once that I can get a good indication that I want to see more without having to click on each individual photo. Blogs also have the added feature where I actually can tell that the photos are recent work. With some sites only the hairstyles give any indication of when the photo was taken.

There were a few Ottawa wedding photographers who use this approach of having both a blog and a flash-based gallery, and I have to say I was impressed with all of them.

  • Mike Dickson – Ottawa Wedding Photographer blog (flash site)
  • Byron Brydges – Ottawa Wedding Photographer blog (flash site)
  • Andrew Geddes – Ottawa Wedding Photographer blog (flash site)

The blogs are photo galleries all on their own. None of them mix personal blog posts in with the photos.

The Bad

One of my biggest pet-peeves with photo gallery sites is having to click on each individual photograph to load it. It isn’t so bad if I can middle-click on them to open them in a new tab to look at later, but with some flash- or javascript-based sites it takes forever! I have to click on each individual picture, wait for it to load, look at it, then click again… it ends up taking 20 times as long to view the entire gallery vs a blog-based sites.

If you use a flash-based site for displaying your photos, it has to be FAST. Use something like SimpleViewer instead of coding it yourself.

Another pet-peeve is when the pictures aren’t big enough to see the photo in detail. Thumbnails are great for overall navigation, but it’s very hard to tell photo quality when the picture takes up less than one fifth of my screen.

The Ugly

One of the worst things I’ve seen is watermarks embedded in the image. We all understand that you don’t want other people to steal your livelyhood, but much like how digital rights management shouldn’t prevent people from watching a DVD, the embedded watermark in a photo shouldn’t prevent your potential customer from seeing how good your pictures are. I can’t appreciate a photo when the writing on top of them is too distracting.

Of course, it’s even worse to have blurry photos in your portfolio. Thank you, but if I wanted an out-of-focus shot I could do it myself.

I hope if there are any amateur or semi-pro photographers in the audience they can learn a few things about what customers are looking for.

Why Google Chrome isn’t my default browser

Web Browser Tips & Tricks

Google Chrome has been public for all of about 30 minutes now. I am very impressed with how fast it downloads and installs, with almost no need for user prompts (except to close your web browser so it can import bookmarks/passwords). It’s fast as fast can be.

I can’t get over how fast it is. If you type “about:memory” into the address/search bar you’ll see a memory comparison between Chrome and any other web browsers you’re currently running. It uses so much less memory than Firefox.

Lifehacker has a good round-up of what’s “new” in Chrome, as well as ways to tweak Firefox to get the same features. But I can’t switch to Chrome because of my dependency on multiple profiles and my Firefox extensions.

Profiles?

Multiple profiles let me log into Gmail with different user accounts at the same time, and keep my browsing history and bookmarks separate from my girlfriend who shares the computer with me.

Heck, I keep my blogging related bookmarks separated from my Joe Public bookmarks for my day-to-day email, Facebook, and job related stuff so I can be more productive.

Plugins?

  • I can’t log into my accounts without Password Hasher. Not only do I not use the same password for every account, I don’t even KNOW my password for most accounts.
  • I don’t want to surf the web without Ad-block.
  • I’ve written so many custom Greasemonkey scripts that are unavailable on Chrome.
  • I don’t want to even think about doing any kind of web stuff without Firebug at my beck and call.
  • I’m missing my Delicious tag button for bookmarking.

My forex trading platform?

Another thing not provided.  Recently I have been trading with a spread betting service and I’ve found the platform to be quick and responsive.  However, this is only the case in Firefox.  As soon as I try and open and close trading charts and modify my positions on Chrome, I get a lot of issues.  As you will know, you need speed and precision when trading forex on a spread betting platform and so if your browser can’t provide it, you better believe that I’ll move on and try elsewhere.

RSS?

There doesn’t seem to be any RSS auto-discovery in Chrome. I hate how painful it is to subscribe to feeds in Google Reader using Internet Explorer, it looks like it’ll be even worse in Chrome.

Chrome looks very cool, but I think anyone who has been reading Lifehacker for the past few years is going to find they’re missing too much of what is “essential” to them. It’s really too bad, because I’d love to run some Greasemonkey scripts inside of Chrome with it’s better memory debugging. I’m hoping that one of the big brained Googlers figures out a way to transparently run Greasemonkey userscripts so we don’t have the same Firefox vs Opera vs Internet Explorer vs Safari development sinkhole.

On the other hand, Chrome might be the best thing ever for people who use Internet Explorer and aren’t co-dependent on all of Firefox’s wonderful extensions.

To Jott or not to Jott

In my efforts to actually get off my ass and get things done, the Remember the Milk (RTM) to-do list software has been a life saver. Two weeks ago I decided to try out a bunch of 3rd party extensions to RTM like Jott.

Jott is a speech to text service. You call up a phone number, say something, and what you say will be emailed back to you (along with the voice message), send to a contact, or send to another service like Twitter or Remember the Milk.

My first experience testing the RTM integration blew my mind. I could call the number and say “job interview tomorrow at 9am” and it would show up in my Remember the Milk todo list as “job interview” with the due date set as tomorrow at 9am.

!!!

But all good things must come to an end, and after less than a week of trying out the free service (that admittedly, had been around for over a year before I tried it) Jott switched to a pay service. You can still record 15 second voice mails for free, but to get the Remember the Milk intergration will cost $4 a month (well, $3 a month if you were using the service while it was in beta).

Is it worth $40 to $50 a year worth it to be able to Jott my to-do list to Remember the Milk?

Judging by the way my girlfriend rolls her eyes every time I try to Jott something, the answer is no. When you add to the fact that I’m likely paying airtime fees when I Jott from my cellphone [1], then we’re talking around $150 a year for a service that isn’t even my main to-do list application.

It might be my cellphones fault, but often Jott would have trouble understanding me. Having to prefix my messages with “me” or “remember the milk” gets old fast when I have to say “remember the milk” five times before I can start recording. Why can we set up a speed dial hotkey for services so we can hit a number instead of saying a name?

One of my non-tech friends summed it up well when I tried to explain Jott to him over breakfast: “isn’t that something you can just do with an app running on your cellphone?” Yeah, or with a pen and a piece of paper.

Media Shifts

Does anyone read books anymore? When I was growing up I was a voracious reader, often devouring more than one book a week. A few years ago I was in a second hand book store that used to specialize in science fiction/fantasy and the owner was lamenting to me about how he’s lost his customer base — they’d all rather be playing World of Warcraft than reading Forgotten Realms.

 

I can see the effects of this at my local drug store where they’ve moved the books and magazine section from a place of prominence to a rack in the back of the store. The local library used to have shelves upon shelves of paperbacks but now they have at most two shelves for each genre. Even the video stores have slashed their back catalog of movies, have expanded their video game sections and are focusing on reselling “previously viewed/played” movies/games.

 

The video game market has already become the largest media entertainment market in media sound bites. Predictions say that by 2011 the video game industry will be worth twice the music industry. But part of the reason video games are soaring so high is the way that the numbers are calculated. The movie industry is still much bigger than the video game industry if you combine movie tickets with DVD sales, not to mention all the merchandising off-shoots.

 

But does this mean dire times for the book industry? Trends show that the gaming industry is increasing 9% per annum while the book industry increases 3% per annum. I find the drug stores and supermarkets are the place to watch for what is happening in the mainstream. They were the last places to abandon VHS and widely adopt DVD. Yet I already see a huge sign on the local drug store advertising the Xbox 360 and Nintendo Wii.

Social media – what is it good for?

Social Bookmarking and Social Voting

I took a three month break from blogging and social media sites so that I could focus 100% on a critical project at work. Strangely enough I didn’t miss the flow of information; I was still able to find interesting links for coffee break time by browing Hackers News. Here’s a break down of my experience from leaving for so long and rejoining it.

Blog

Blog traffic went down -26% (vs -12% for the previous period).

Feed subscriptions up 9% (vs 12% for the previous period).

My blog email address is inundated with press releases and the very occassional question about an old post or tool.

My blog comments are a horrible nightmare of spam that I still have yet to wade through. WordPress has anannoying bug that when you click “Mark As Spam” it always returns you to the start. There’s been 20 pages of comments. It’s likely that most are spam.

It makes me wonder how much time a day I was spending on blog maintenance. The time sink in blogging isn’t writing posts; it’s all the related activities.

News

Surprisingly, I didn’t miss out on much by not having my lips attached to the news firehouse. Some crazy PM is trying to put me in jail with a new Canadian copyright bill that someone needs to question him about how it benefits his constituents. The iPhone is finally available in Canada, and the data plan is almost-but-not-quite liveable. Facebook has a redesign in the works. Xbox has some cool ideas for release next fall.

I’m sure there were plenty of things happening that I could have gotten worked up about, but nothing happened that directly affects my life that I would have found out about on the Internet.

LinkedIn

I’ve had a strict policy of only using LinkedIn for people I’ve actually worked/went to university with, and it’s been a good tool for contacting ex-coworkers years later about new job opportunities. Spam free.

Facebook

I try to keep Facebook to “real life people only”, and that works well for me. I only use it for group emails, and for photo sharing. Spam free once you get rid of those people who invite you to use applications.

Google Reader

I’m oversubscribed still. When you check your RSS feeds once a month, it becomes much more about the people who consistently keep you thinking or providing good information. Of course, information is only useful if it has impact on your life.

We, the information overloaded, collect new information but I wonder how much of it is retained and has lasting impacting on our lives?

Twitter

I didn’t feel any pain of Twitter downtime because I didn’t log into it. I need to cull my friendslist to make it more useful. But I found Kathy Sierra on twitter and if that’s the real thing then it’s a good sign for twitter having the potential for making me think vs phasing it completely out of my life because of the constant self-promotion.

I still like twitter for chatting with other bloggers that I respect.

Friend Feed

Still not sure if I like rooms or not. The Friend Feed hacking community is kicking even harder lately with a ton of new greasemonkey scripts thanks to Hao Chen. It looks like Lou Cypher is getting involved in Friend Feed as well which means even more cool little hacks.

Nothing new has been happening with ffapps or friendfeedwatch though.

Delicious

It might be time for me to abandon delicious for something new to use for bookmarking. The future does not look peachy for delicious with Josh leaving Yahoo. Maybe it’s time to look at Google Reader shares as an alternative.

Last.FM

I’m still using it, still finding great music because of it. I do like The Filter for making lastfm-esque playlists of my own music collection.

Real Life

I’ve been enjoying the summer and having more time for family, friends and non-Internet hobbies like reading, movies, and games. I really appreciate the knowledge I’ve built up with the programming I’ve done. I plan to continue that in that direction: releasing useful free software and delving into creating my own web apps. I want to spend less time participating and more time creating.

Building a better job search site

Workhacks

Job hunting is a massive industry, but unfortunately it’s one that that always leaves job hunters feeling unsatisfied.Monster and Dice are painful to use. The hierarchy trees of job categories are often incorrect and confusing to someone who is looking for a job. There are a few places that are doing something different:

LinkedIn - resume and networking tools to keep in contact with ex-coworkers. The best way to find a job is often through people who know you. You get a job, they often get a referral bonus — win/win.

Doing your own SEO – if you can promote yourself in an effective way, then you are bound to end up with more leads. One of the most effective ways that you can promote yourself or your online business is if you embrace search engine optimisation.  SEO, as it is better known, is the process of making sure that Google promotes your results higher in the search engine results.  You can achieve this by writing quality content and building something of worth for users.  One of the things that an seo company will frequently recommend is to monitor your site speed and your inbound links. If you can make your site quick and you don’t try to ‘game’ the algorithms, you can promote your website, or even your CV, very highly in Google.

Peter’s New Jobs - regional tech job searches in Ottawa and Toronto, worth the yearly subscription even if you have a job because it’s a great way to stay current with the job market and how companies are doing.

Standout Jobs - Montreal startup that is focused on humanizing the job search process and giving companies a chance to sell themselves.

Working With Rails - job listings based on people working with a common technology.

Site-based Job Boards – job listings for readers of blogs like 37signals, Joel on Software, and Tech Crunch.

There are a few things I’d like to see in a job search site.

LinkedIn Integration

LinkedIn has taken over as the business contacts networking tool and it has a robust resume feature, yet we’re still forced to manually enter our resume into most job sites.

No Job Categories

Job sites like Dice and Monster all suffer from bad usability with elements like the job category navigation that takes several minutes to fill out. It’s so much simpler to have saved search agents for keywords in resumes and job postings.

Google Maps

I’d really like to see all of the job locations on a Google Map centered around my home address with different colours based on how the fresh the listing is. Job decision is often based on locality and I’ve yet to see a job search site that lets me easily list.

Stock History

For publicly trade companies there is no reason not to integrate a stock ticker widget so that job applicants can quickly see how a company is performing.

How the Xbox 360 can reinvent itself

Video Games

The entertainment industry is shifting. Video games dominate all forms of media as an estimated 46 billion dollar industry. Your local video chain likely carries as many video games as it does DVDs. Blueray has beaten HD-DVD as the new media for watching movies at home, but it has the potential to be squashed by digital downloads. Not watching movies on your computer, but rather watching them on a box that is already hooked up to your entertainment system: your gaming console.

Netflix has existed for several years as a DVD-by-snail-mail service. This year they released the Roku box in the US that lets you subscribe to your Netflix service as digital downloads rather than DVDs. 10,000s of movies for $9 a month plus the cost of a $100 box.

I’ve been using my Xbox 360 with a media server for watching movies and TV shows for a few months now and it is so much more convient than having to deal with DVDs. On Monday Microsoft announced that they’d be partnering with Netflix for the Xbox 360. This is huge because Netflix is already a proven movie subscription model that works, and now they’re working with a gaming console that millions of people already own instead of yet another standalone box.

It sounds like the update next fall will fix quite a few other issues that have been bugging me as an Xbox 360 owner. Some of the planned updates:

Netflix

Netflix subscribers who are also Xbox Live Gold subscribers can stream movies from their Netflix queue for free. Unfortunately Netflix still isn’t available to Canadians.

Load Times

Trying to navigate through your Xbox Live arcade games / demos is painful. It can take up to a minute for games to load. Navigating your music library is equally as painful. They should cache the data to the local hard drive.

Xbox Marketplace on the Web

Trying to find something on the Xbox Marketplace is next to impossible. A web interface would be much simpler and would allow for easy searching.

Rip to Hard Drive

Games can be copied to hard drive to play faster (and quieter).

“Live Party”

I’m hoping this will let you set up the equivalent to a “chat channel” amongst your friends. One of my biggest pet peeves with using the 360 for voice communication is that I can’t set up a private group of just my friends when playing a multiplayer game unless that game itself supports that.

I don’t want to talk with people I don’t know online.

What I’d Like To See

There are some big improvements, but there’s still room for more. Here are a few things I’d like to see for my 360 to earn it’s spot in my TV room.

Targetted Content

The current Xbox 360 interface already offers a few advertisement locations. These are horribly used. Microsoft knows my play history for all of my games. They should be data mining that information and targetting advertisement for games I’m likely to want to play based on the games I usually play.

They don’t even do a good job of highlighting that there’s downloadable content available for the games I am currently playing.

Photo Zoom

I’m absolutely flabbergasted that we can’t zoom into pictures on the 360. It seems like it would be a very trivial application to support. Zooming would offer up some interesting 3rd party hacks like reading web comics / downloaded CBZ/CBR files as image files or converting e-books to images.

There has already been a homebrew Nintendo DS web surfer program that works by converting web pages to images on the DS.

Videos

There’s no reason why the Xbox 360 can support more video codecs. I’d really like to be able to play anything I download on the 360 without having to re-convert it.

Video Meta Data

We need something like ID3 tags for video files. I’d love to be able to tag my digitized video collection with director, main actors, and Rotten Tomatoes scores as well as being able to navigate by cover art like I can with my music collection.

Xbox Homebrew

The Xbox 360 already has a homegrew gaming development community, but they’ve starved it by charging a yearly fee to access it. I got to play some of the games when they had a free trial offer a few months ago, and while there were some gems there was nothing to compell me to pay the fee.

This is a huge shortsightedness, by making the games freely available to Xbox 360 gold members they would be giving hobby developers a huge reason to develop games on the play form. Sure, charge developers to have their games listed as that will weed out the utter crap, but at least let them have an audience.

Web Browsing

There’s no reason why the Xbox 360 couldn’t be used as a web browser. There’s even a neat little keyboard attachment you can buy that fits in with the controller. I’d be pretty happy if I could pause a game, check my email, and write a quick response.

I’m surprised Opera hasn’t teamed up with the 360 team to develop a pay browser like they did with the Nintendo DS.

Filtering reddit and hacker news

Social Bookmarking and Social Voting

Giles had a fantastic rant this week that cut to the heart of what’s wrong with all of these “social web application sites”:

People who waste their own time have, in effect, more votes than people who value it – to elevate bad but popular ideas and irretrievably sink independent thinking.

It’s analogous to what’s wrong with the entire massively online roleplaying game genre (eg: World of Warcraft) in that success is a greater factor of the time invested than of skill or talent. Many social web applications add extra features to keep the users interacting with the site, even if this interaction offers dubious value to their lives.

 

It’s a Game and We’re All Losers

Is it more important for a site to be useful or to be sticky?

The worst obstacle of all is the system of upmodding and downmodding comments. Your search for news becomes derailed into a video game – anything which involves computers and scoring points ultimately becomes a video game – and as video games go, it isn’t a lot of fun. It sure as hell isn’t Tetris.

Worse yet, it’s almost ubiquitous. If you’re highly vulnerable to distraction, this game will steal your time. We should all know that it’s an incompetent social networking strategy because it comes from Slashdot originally – a site which specializes in crashing innocent servers so that nerds have an excuse to swear at each other – but despite this horrible pedigree, it’s a very popular approach. Every site which uses this approach inevitably ends up hated by former users, so it’s kind of weird that the approach is so popular, but there’s an easy explanation. The ultimate reason, of course, is a mistaken belief – specifically, the idea that user numbers are a better metric for Web app success than usefulness. This implies that anything which generates more traffic is inherently better. But purely for the sake of argument, let’s abandon this 1997 mentality and ask ourselves how useful a site like Reddit or Hacker News can ever really be.

When you build a system where you get points for the number of people who agree with you, you are building a popularity contest for ideas. However, your popularity contest for ideas will not be dominated by the people with the best ideas, but the people with the most time to spend on your web site. Votes appear to be free, like contribution is with Wikipedia, but in reality you have to register to vote, and you have to be there frequently for your votes to make much difference. So the votes aren’t reallyfree - they cost time. If you do the math, it’s actually quite obvious that if your popularity contest for ideas inherently, by its structure, favors people who waste their own time, then your contest will produce winners which are actually losers. The most popular ideas will not be the best ideas, since the people who have the best ideas, and the ability to recognize them, also have better things to do and better places to be.

I use social networking sites as information gatekeepers, but when time invested is the greatest factor of success then the people who are most successful will be the ones who invest the most time. You have to ask yourself if those are the people whom you want to be shaping and seeding your thoughts and ideas. Popularity contests always reduce the discussion to the lowest common denominator between the participants. Is that what you want to limit yourself to?

Delicious Gets It

Delicious remains one of the few “web2.0? sites that has been around for a long time and maintained a ridiculously high signal to noise ratio, mainly because the programmers wanted to avoid the social networking devolution:

As the population gets larger, the bias drifts; del.icio.us/popular becomes less interesting to the original community members. Work out ways to let the system fragment in to different areas of attention.

“Spam is attention theft” – that’s one of the reasons del.icio.us doesn’t have a top 10 links of all time – it’s an attractive nuisance.

When you’ve figured out someone is spamming, don’t let them know – let them keep posting and just silently junk their stuff. Automatic tags lose a lot – doesn’t help the user really achieve their goals. That’s why the “add to del.icio.us” badges don’t let you suggest tags. Value in Delicious is in the “attention” – auto-tagging detracts from this.

Measure behavior rather than claims. del.icio.us doesn’t have stars because why would you bookmark something that was no good? This way people bookmark things that they really care about rather than trying to tell the system things.

It’s a tool. The community can grow elsewhere. No threading etc. “del.icio.us sux” is an awful experience I’d rather user’s didn’t have.

The only way to make sense of this information glut is by having the appropriate filters in place.

Filter Reddit and Hacker News

I decided to solve Giles’ problem with Hacker News / Reddit and create a Greasemonkey script that lets you maintain a personal ban list.

Click on the “ban site” link beside any site you never want to see again on Hacker News or Reddit. You can edit your list of banned sites at any time.

Your personal list of banned sites lives in your web browser and is shared between Reddit and Hacker News. Use it to remove the most popular sites so you can pay more attention to the long tail, or to cut out the domains you already read using RSS. It’s your web.

Click here to install the script (you will need Greasemonkey and Firefox).

Become a ninja with jQuery

Programming Tips

This is for all the Greasemonkeyers in the house who want to learn how to be much more productive when it comes to hacking together Greasemonkey script by using my favorite Javascript library:jQuery. jQuery will turn a 700 line Greasemonkey script into a 12 line Greasemonkey script. I learned about jQuery through all of the Greasemonkey scripts I created to work with Friend Feed.

This is advanced stuff that is of interest to people writing Javascript. If you’re just a Greasemonkey user then you can safely skip this one.

 

What is jQuery?

jQuery lets you very concisely access any element on the page through the use of normal CSS selectors and custom selectors specific to jQuery. If you can access it with CSS or XPath then you can access it with jQuery. It gives you more options for selecting elements than CSS or XPath.

It also support method chaining which makes for some stupidly concise javascript code compared to the normal pain of walking the DOM or calling XPath that you see in most Greasemonkey scripts.

The other thing I love about jQuery is that it has plugins you can grab and import into your Greasemonkey scripts.Check out this concise plugin that lets you call Firebug’s console.log from within a jQuery method chain. That’s a perfect example of how powerful jQuery is.

jQuery Makes Me Happy

The hardest part of using jQuery with Greasemonkey is importing it. There are several ways to include jQuery into a Greasemonkey script. I’m going to walk through three of them. I would love it if jQuery became an official component of Greasemonkey, and I think that would greatly increase the number of useful Greasemonkey scripts being created.

Technique #1: Site already uses jQuery

If the site already uses jQuery (friendfeed.com, wordpress admin) then you’re in luck: you don’t have to import it.

You can find out if the site uses jQuery by running ‘alert($)‘ in the Firebug console or by looking at the imported scripts.

Technique #2: Import from Remote Host

If the site doesn’t already use jQuery (boo, hiss) then you can import jQuery from jquery.com.

Joen Piedra has example code and a script showing how to do this.

view plaincopy to clipboardprint?
  1. // Example from http://www.joanpiedra.com/jquery/greasemonkey/
  2. // Add jQuery
  3.     var GM_JQ = document.createElement(‘script’);
  4.     GM_JQ.src = ’http://jquery.com/src/jquery-latest.js’;
  5.     GM_JQ.type = ’text/javascript’;
  6.     document.getElementsByTagName(‘head’)[0].appendChild(GM_JQ);
  7. // Check if jQuery’s loaded
  8.     function GM_wait() {
  9.         if(typeof unsafeWindow.jQuery == ’undefined’) { window.setTimeout(GM_wait,100); }
  10.     else { $ = unsafeWindow.jQuery; letsJQuery(); }
  11.     }
  12.     GM_wait();
  13. // All your GM code must be inside this function
  14.     function letsJQuery() {
  15.         alert($); // check if the dollar (jquery) function works
  16.     }

It’s a similar technique to the jQuerify bookmarklet that lets you add jQuery to any site in one click so that you can play around in the Firebug console.

Technique #3: Embed in Your Script

This is my preferred method because it reduces the number of external dependencies of your script. You can put all of the code for jQuery directly into your script so the user only has to download it once. This will reduce the load time of the page you’re Greasemonkeying since it is always faster to load local files than to load a Javascript library over the internet.

  1. Copy the packed version of jQuery into your script
    • Direct link to the packed version of jQuery 1.2.3
  2. Use jQuery :)

Here’s an example of one of my scripts where I use the embedded packed jQuery as well as an embedded image file. That script runs on Soundamus (a very cool site if you’re a Last.FM listener, check it out) and adds links to search for the artist/album on an different site.