Yesterday I shared a browser extension script I wrote to integrate aircraft lookup details into the FlightMemory.com/FlugStatistik.de sites. It was clunky, popping up extra windows and that wasn’t ideal but it was what I thought was necessary to avoid cross-site scripting issues. Fortunately one of the comments on that post suggested I was doing things wrong and that integrating the data directly on to the page is, in fact, possible. Turns out – not surprisingly – that he is correct and that this could be done much more cleanly. Welcome to version 0.2.0 (direct download if not using Chrome).
Now every time you load the edit page for a flight the data will automatically be retrieved in the background. No need to click buttons or see that creepy icon on your page.
Once the data is populated you can copy/paste it from the same page over in to the text box if you want to update the entry for your flight. And, as an added bonus in version 0.2.1, the N-Number is now a clickable link. Click on it and the value automagically populates the text box so you can save and move on to the next flight.
I could have simply just inserted the data into the box but there will be cases where it returns an error or nothing and I don’t want to potentially overwrite what you’ve already put in that box without some interaction on your part.
And the copy/paste from within the same page is much easier. Sorry to everyone who spent extra time yesterday needing to switch tabs/windows, though I do appreciate the page views/ad impressions.
So, yeah, turns out this is better than last time around. And it only took me a few hours to figure it out once someone pointed me in the right direction. Thanks, Leith.
Never miss another post: Sign up for email alerts and get only the content you want direct to your inbox.
Nice job Seth!
You could even make the tail number a link, which when you click it, would replace the value in the text box. Just an idea. 🙂
Yeah, well….I tried that a couple different ways and it wasn’t working. Walked away for a couple hours, came back and now that’s part of the feature set, too. I hope you don’t have any more enhancements for this; I’ve got a few other things to get done today. 😉
Ha! No more enhancements. 😀
Didn’t think it would be complicated? Should just be a element.val = tailnumber; ?
But anyway, great job!
Not sure if it is me or the way the pages load but it wasn’t quite that simple. Part of it is that the input boxes don’t have an ID, just a name. Also, I get confused about when I can use a function hosted in the user.js file and when I have to insert it into the parent file and making that happen.
But I did get there eventually. 🙂
When there is no ID, document.querySelector() is your friend. To find the right CSS selector, in the chrome dev console, right click on the element you want and click “Copy CSS path” and paste that as the argument to querySelector.
Strange on the page loads, since I’m sure your script only executes after the DOM is constructed right? Even so, if you’re seeing stuff happen after that you can attach listeners to an element and act upon them.
Now, we just need browser support for a *modern* flight-tracking tool like OpenFlights… 😀
Though no rush at all, I already used wandr.me/bts manually to grab all my tail numbers for which data exists. Amazing how incomplete the data is at times (I cross-checked the BTS site itself where things were missing to confirm it was actually missing at the source too.)
Now all my older intl. flights are the ones with glaring tail number gaps. 🙁
I wish I could get it on to OpenFlights. The page layout for that site is much more challenging to work with and my initial inquiry to the guy who runs it was rebuffed. 🙁
Comments are closed.