The Blog

Update: ATC callsign bookmarklet for fr24

In my last post I spoke of my Javascript bookmarklet which takes callsigns from flightradar24 and figures out the callsign they'd likely use on air traffic control radio. This included looking up a company's chosen radio callsign, converting letters into the NATO phonetic alphabet, and adding HEAVY (or SUPER) to the planes big enough to require such a designator.

flightradar24 screenshot

Well today, flightradar24 decided to push a long-awaited update, which promptly broke my bookmarklet. I'm actually not mad, because the update makes the site significantly better. The overall style is nicer (big-up to Roboto), and there's the inclusion of a much-teased 3D view, which is beyond the scope of this post.

I immediately took to updating my bookmarklet for the site, but as I did, I realised just how bad my old code was. It was somewhat of a 'throw it together and when it works, leave it' type of job, so I have ended up re-writing quite a bit of it. The code's probably still pretty comical to anyone who cares about Javascript, but that group does not exactly include me for the time being.

flightradar24 screenshot

Here's the bookmarklet, drag to your bookmarks bar: fr24.js*

I have moved the display to the top of the sidebar, and re-styled it to fit the new theme, lots of in-line styles because I was testing it, and it worked, so I left it. I have also been able to remove the most dodgy code which involved trying a variety of places to grab the callsign. I've now found the callsign in a data-callsign attribute on one of the buttons, and am stealing it from there. The process to decide what to do currently looks like this:

  • If the callsign is the same as the aircraft type, then it isn't a callsign, so it gets disregarded and nothing is shown
  • Else, if the callsign is entirely letters, or is 'N' followed by some numbers, and maybe some letters (said more definitely with Regex, thank you Americans) then the entire callsign is simply phoneticised (replacing 'A' with 'ALPHA' for example).
  • Else, if the callsign is three letters followed by one or more characters, look-up the three letters in the table to see what they like to call it on the radio (i.e. converting 'BAW' to 'SPEEDBIRD') and phoneticise the rest of the code.
  • If none of those patterns are met, for now, drop it.

Then, if somethings been found, look the aircraft type up as well to see if it needs 'HEAVY' or 'SUPER' appended. Then put the callsign into the box.

Last post: Script: Tesselating hexagons of random shades for a background