Christian Heilmann

Posts Tagged ‘greasemonkey’

Geo this! Geolocate WordPress posts with Greasemonkey and Yahoo Placemaker

Monday, June 22nd, 2009

Geolocating content on the web is a great idea. By embedding latitude and longitude and real place names in your document you allow data mining for location or easy display on a map.

The problem up to now was that it is quite a job to find out the correct geo information from a text or a document and it is quite a pain to enter the information by hand.

Yahoo Placemaker is a web service that helps you with that – you give it some text or a document URL and it returns you all the things it found in there that resemble a geographical location back. The issue with doing that on a live site is that you slow down your site immensely as you need to look up every time.

The more logical place to do the lookup with Placemaker is when you edit your document. I thought this would be cool to have for this WordPress install here and wrote a small GreaseMonkey script that injects a new “Geo this!” button in the main WP form:

Geo this - button by  you.

When I hit the button the script does an Ajax request using the Placemaker open YQL table to get the information for the currently edited text.

Once it found the information it adds it at the end of the document as a GEO microformat. Each found entry starts with a comment that tells you what Placemaker matched and considered a geographical location. As it is not infallible this makes it easy for you to delete wrong entries.

Geo this - added microformats by  you.

Try it out yourself:

This is pretty much rough and ready and I’d be happy for feedback how to improve it.

Sorry BBC, my pimped Firefox made me think you did wrong

Sunday, May 17th, 2009

Here’s an interesting example of me being a typical developer. This morning I checked a news piece of Danger Mouse sticking it to EMI by releasing their album as a blank CDR and got an alert() on the BBC site:

Failed to load Yahoo libraries cannot load menus by  you.

As you can see the alert clearly states that it comes from the BBC site – a nice anti-phishing feature that browsers added in the last few years.

I was confused, first and foremost because the BBC has their own library “Glow” which is yet to be released as open source and secondly as there are no menus on the page that are JavaScript or Yahoo dependent. Furthermore I was amazed to see the BBC to be as unprofessional as using an alert in a live site.

As BBC JavaScript overlord Jake Archibald rightly pointed out the alert did not come from their site or is anywhere in their code. I had looked through the numerous JavaScript includes (seriously, collate on the server, folks) in the page and couldn’t find it either.

Jake’s second comment made me aware what happened. Instead of seeking the error in my own setup I immediately thought the BBC messed up (this is the typical developer bit I was talking about). The solution to the problem was easy to remember once I was aware of it.

Friday before Hack Day we had the press in the office and wanted to show them some of the hacks previously built on hack days. One of them was Dharmafly’s HackHud which is a GreaseMonkey script that injects menus at interesting keywords into the BBC site. The script was broken and Premasgar tried to quickly fix it right on the spot leaving an alert in the GM script:

Sorry BBC, the alert() was my mistake by  you.

My lesson learned: don’t trust alerts, even when they tell you where they come from. Your pimped browser might give you a wrong message.

Flickr copy and paste embed – a GreaseMonkey script

Friday, May 1st, 2009

I love flickr to bits and I especially like the copy and paste boxes for embedding photos on my own photo stream when I check photos in different sizes.

What annoyed me is that this is not available on other people’s photos. That’s why I wrote a small GreaseMonkey script that embeds a text box with the a link and the medium sized image of the photo you’re currently checking out:

Copy and Paste photo greasemonkey script by  you.

If you want to have the same comfort, simple Install the GreaseMonkey script flickr embed and save yourself some annoying steps of copy and paste.

TTMMHTM: Good job news, extending browsers, TweetEffect and converting Wikipedia to JSON

Monday, January 19th, 2009

Things that made me happy this morning (and I tell you about in the afternoon):

Geekmeet Stockholm – Performance and Play

Friday, December 5th, 2008

I am just getting ready for my second day in Stockholm, Sweden to go to the bwin offices and talk about professional web development and the change of JavaScript. The professional thing is going to be interesting as I am still feeling the beers of the GeekMeet yesterday night.

Geekmeet SwedenGeekmeet Sweden

Talking of GeekMeet, except for the interesting choice of advertising keywords showing up when you look for it, it was a roaring success and if I had a hat it’d be off to the organizers at Creuna and Robert Nyman for pulling this out of their hats (ok, you killed that metaphor, now let it die in peace).

Over 150 geeks came to drink beer and pizza and had to wait for those by listening to my drivel about website performance and ethical hacking. Some seemed to have been inspired by it, so that’s good I guess.

What I have to say to the credit of the Swedish audience is that they have a great sense of humour and are very happy to get distracted by unexpected slides and side-stories. It was great fun presenting and chatting to people afterward.

Credit must also go to Robert Nyman for not being only a masterly “one, two” announcer but also finding a very nice way to introduce myself – playing hangman with my name using all the emails and messages I sent him over the years telling him off for doing things wrong. Thanks for making me sound like a picky bastard, but I understand that it came from the heart. I also explained that my connection with PPK started the same way – but with him being the picky one.

My first presentation revolved around things you can do to speed up your web sites, unashamedly based on the work done by Steve Souders, Nicole Sullivan, Stoyan Stefanov, Ed Eliot and Stuart Colville. You can get the slides on slideshare:

[slideshare id=819648&doc=shiftinggears-1228434047613720-9&w=425]

The second presentation was (re)introducing the concept of ethical hacking and an invitation for people to see the web as their playground using cURL and GreaseMonkey to remix and improve it:

Playing With The Web

Playing With The Web

My second talk at geekmeet sweden talking about the tools you can use to hack and remix the web.

Read “Playing With The Web” with Easy SlideShare

All in all I had a wonderful time and I was impressed how easy it was for me to deliver all of this in such a short amount of time (I just gave seven presentations and two interviews in three days in two countries, having written the presentations on airports and flights in between).

Sweden rocks! Now I am off to check out the ice bar in the hotel and tomorrow it is back to England.