View Full Version : Greasemonkey script to tweak ITA


Johnath
Feb 13, 07, 4:39 pm
Hey folks,

So for a little while now I've been running a greasemonkey script for firefox which tweaks the ITA search and result pages to be a little more helpful. I got to thinking that maybe I'm not the only one who would find such things useful, so I'm putting it out here for anyone who wants to use it, and of course for any feedback/suggestions/pointers to better versions that already exist.

For those who are confused:

Firefox is a web browser. Okay, you probably already knew this part. :)
Greasemonkey is a firefox add-on that lets you inject custom scripts into web pages you visit.
I'll explain at the bottom how to set all this up, if you're interested, so sit tight.


So what does the script do? So far, not a whole hell of a lot, but enough to be useful to me. First of all, it remembers my preferred sales city and departure city, and sets them by default. If you install the script you can, of course, configure it to use any airport code (or for that matter, some more complicated string like "YYZ:: AC+") you like.

Second, it adds a little airplane icon after airport fields, which launches an airport code lookup chart in a popup, for those times when you can't remember that Analalava, Madagascar is HVA.

Snap of modified search page (http://www.johnath.com/~johnath/temp/itasearch.gif)

Third, on result pages, it adds a webflyer link for each result, to make calculating mileage a little easier. It wouldn't be too hard to edit the script if you wanted to use a different calculator, but really, why?

Snap of modified results page (http://www.johnath.com/~johnath/temp/itaresults.gif)

That's it so far. Nothing earth shattering, but it does make my interactions with ITA a little more pleasant. As I say, I'd be happy to get any feedback people want to offer, but mostly I just put it out there to save people precious seconds when building their next MR.

Now, for those who want to know how to get ahold of it:


If you don't have firefox, install it (http://www.mozilla.com/en-US/firefox/).
If you don't have the greasemonkey extension for firefox, install it (https://addons.mozilla.org/firefox/748/).
Install my script, found here (http://userscripts.org/scripts/show/7505).
If necessary, edit the script (Tools Menu->Greasemonkey->Manage user scripts, then press the Edit button) and fix your preferred airport code & sales city.


Edit: For those who don't read complete threads, the script is up to version 1.3, so before installing as described above, you might want to scan the comments and see if any of the improvements interest you.

TravellingMan
Feb 13, 07, 4:46 pm
That is a good addon to start with. Would really appreciate help on all the codes that one can type in ITA like::UA UA UA. I cannot remember all of them, but would find it really useful to have a cheat sheet or something.

hiyo
Feb 13, 07, 6:37 pm
That is a good addon to start with. Would really appreciate help on all the codes that one can type in ITA like::UA UA UA. I cannot remember all of them, but would find it really useful to have a cheat sheet or something.

This may help:

http://matrix.itasoftware.com/cvg/dispatch/help/advanced-topics

hiyo
Feb 13, 07, 6:46 pm
OP: Thanks for the script. Sweet.

TravellingMan
Feb 13, 07, 6:56 pm
This may help:

http://matrix.itasoftware.com/cvg/dispatch/help/advanced-topics

Thanks a ton.

MACH81
Feb 13, 07, 6:57 pm
Thanks a ton.

It would be nice if that popped up though. I have most of it copied and pasted on a word file but it takes time.

number5858
Feb 13, 07, 6:58 pm
What difference does the sales city make?

ja_user
Feb 13, 07, 7:00 pm
Where is the file to edit after all of that install? I go to manage and can see it, enable and disable it, but don't see a variables or anything to modify. Where is it stored?



This will be great for those searches where someone wants to search to or from
san|sfo|qla|oak|sjc|sea etc

MACH81
Feb 13, 07, 7:03 pm
What difference does the sales city make?

Pricing. BOS is in $, FRA in euros, YYZ, CAN$.

pltwannab
Feb 13, 07, 7:36 pm
Nice work there. love firefox for all this nifty addons

sadiqhassan
Feb 13, 07, 7:39 pm
Pricing. BOS is in $, FRA in euros, YYZ, CAN$.

and some fares have different availability due to point of sale

There are also tickets that have SITI requirements. (The ticket must be sold and ticketed in the country of origin.) So if you wanted to look up at SITI ticket ex KHI, you would have to enter KHI as your sales city. BOS wouldn't work.

Though uncommon in the west, SITI restrictions are quite common ex the middle east. Almost all the Dubai-Canada Air Canada fares have a SITI requirement.

Cheers

Johnath
Feb 13, 07, 7:43 pm
Where is the file to edit after all of that install? I go to manage and can see it, enable and disable it, but don't see a variables or anything to modify. Where is it stored?

There are two ways to get to the file. The first is to, as you say, go to the firefox Tools menu, Greasemonkey->Manage Scripts. From there you can select the script from the list of installed scripts, and click the edit button at the bottom to open that script in an editor.

The second way is to actually find the file in your firefox profile. I don't recommend this, but if you want, the file should be somewhere inside C:\Documents and Settings\<your username>\Application Data\Mozilla\Firefox\Profiles\<some random folder name>\gm_scripts.

Again, that second approach is pretty ugly, so I recommend going the Tools menu route. The file should be editable in anything, including notepad. The obvious variables to change are all clustered at the top, and hopefully have meaningful names.

TravellingMan/MACH81: I hadn't thought to add a quicklink to the query construction reference page, but it shouldn't be too tough - I'll have a look and update this thread if/when.

sadiqhassan
Feb 13, 07, 7:44 pm
cool...i never knew you could do this ^

MapleLeaf
Feb 13, 07, 7:48 pm
How do you install it? When I click on the link for the script, it opens in a new window... 7507.user.js, with all the code written out.

Should I be saving that file someplace? It doesn't give me an install option.

(I am using FF 2.0)

Johnath
Feb 13, 07, 7:52 pm
How do you install it? When I click on the link for the script, it opens in a new window... 7507.user.js, with all the code written out.

Should I be saving that file someplace? It doesn't give me an install option.

(I am using FF 2.0)

Do you have greasemonkey active? Straight firefox doesn't know what to do with a greasemonkey script, you need the greasemonkey add on as well. If you just installed it as a result of this post, is it possible you just need to restart your browser?

MapleLeaf
Feb 13, 07, 8:26 pm
Do you have greasemonkey active? Straight firefox doesn't know what to do with a greasemonkey script, you need the greasemonkey add on as well. If you just installed it as a result of this post, is it possible you just need to restart your browser?

That was the problem, thank you.

Johnath
Feb 13, 07, 9:28 pm
I have a new version (1.2) with support for a direct link to the advanced query help - I just inserted it into the action bar along the top right, beside the regular help link.

The problem is that userscripts.org is in some kind of maintenance mode right now, and won't let me update the code there. As soon as they get their act together, I'll update that version and post the link.

In the meantime, if people are dying to have that addition available, I've put a copy here (http://www.johnath.com/~johnath/temp/itapolish.v1.2.user.js), but please remember to uninstall your old version. You can do that from the Manage User Scripts dialog as well. If you keep both versions around they will likely duplicate all the UI modifications. This is probably not something you want. :)

nixande
Feb 15, 07, 7:06 am
WON-DER-FUL! :)

I would love to see more people do greasemonkey scripts it makes a brower so much more useful ;))

Something like this might also solve the dreaded problem of BA not remembering where I am from! ;)

Sam - DFW
Feb 15, 07, 9:34 am
next project:

aa.com "Dates Flexible" needs 0 days as an option

A guy can dream, right?

jabrams72
Feb 15, 07, 9:41 am
And ITA needs 0 days as well on the 30 day search; and I'd love to see, for vacation rather than MR purposes, broader ITA searches in the 10-20 day range., rather than only 10-11 days, 11-12 days, etc...

Johnath
Feb 15, 07, 10:09 am
And ITA needs 0 days as well on the 30 day search; and I'd love to see, for vacation rather than MR purposes, broader ITA searches in the 10-20 day range., rather than only 10-11 days, 11-12 days, etc...

Interesting! I never use that search but those things sound reasonable. So let me restate to make sure I'm understanding you here. You'd basically like to see the "staying" combo box on the 30-day search page expanded to include a couple more options, namely:


0 nights
And some more flexible options like the "about a week (6-8)" that they have already. Maybe "about two weeks (12-16)" and "about three weeks (18-24)"


Obviously when you grow the window, you create a larger search result, meaning that ITA's more likely to hit its 60 second timeout and cut off some valid results. But really, assuming these searches don't just cause the thing to crash, it couldn't hurt.

Let me know if I've got the request right, and I'll see about changing the script to support it.

jabrams72
Feb 15, 07, 10:21 am
Interesting! I never use that search but those things sound reasonable. So let me restate to make sure I'm understanding you here. You'd basically like to see the "staying" combo box on the 30-day search page expanded to include a couple more options, namely:


0 nights
And some more flexible options like the "about a week (6-8)" that they have already. Maybe "about two weeks (12-16)" and "about three weeks (18-24)"


Obviously when you grow the window, you create a larger search result, meaning that ITA's more likely to hit its 60 second timeout and cut off some valid results. But really, assuming these searches don't just cause the thing to crash, it couldn't hurt.

Let me know if I've got the request right, and I'll see about changing the script to support it.

Yes, that's exactly what I was thinking!

0 nights (for MRs)
about 2 weeks (10-14 days, maybe), although 12-16 would be good as well
maybe a variable option where the user could enter lower band and upper band and it would plug those in automatically; is such a thing even possible?


Thanks!

Johnath
Feb 15, 07, 10:34 am
next project:

aa.com "Dates Flexible" needs 0 days as an option

A guy can dream, right?

Sam - this isn't really part of the ITA script, and I can't promise it will get the same maintenance, but you were basically asking for a one-liner, so how could I say no? Give it a shot and let me know if it does what you need, it was really just 2 minutes of work, so I'm not beyond admitting it might be buggy. :)

http://www.johnath.com/~johnath/temp/aa.mileagerunner.user.js

Install that, then go to the aa dates flexible page, and while 1 night is still the default option, 0 nights should be there as well. Let me know.

jabrams72
Feb 15, 07, 10:41 am
Wow, you're good. That aa.com one is great.

Sam - DFW
Feb 15, 07, 11:20 am
Sam - this isn't really part of the ITA script, and I can't promise it will get the same maintenance, but you were basically asking for a one-liner, so how could I say no? Give it a shot and let me know if it does what you need, it was really just 2 minutes of work, so I'm not beyond admitting it might be buggy. :)

http://www.johnath.com/~johnath/temp/aa.mileagerunner.user.js

Install that, then go to the aa dates flexible page, and while 1 night is still the default option, 0 nights should be there as well. Let me know.

WOW!!!!!!!!!!!!!!!!!!!!!!

^ ^ ^ ^ ^ ^ ^ ^ ^ ^

that is AWESOME!!!

Thanks a million.

Works GREAT!

Johnath
Feb 15, 07, 4:55 pm
WOW!!!!!!!!!!!!!!!!!!!!!!

^ ^ ^ ^ ^ ^ ^ ^ ^ ^

that is AWESOME!!!

Thanks a million.

Works GREAT!

Happy to hear it. :)

IceTrojan
Feb 15, 07, 5:12 pm
next project:

aa.com "Dates Flexible" needs 0 days as an option


Sam - this isn't really part of the ITA script, and I can't promise it will get the same maintenance, but you were basically asking for a one-liner, so how could I say no?

http://www.johnath.com/~johnath/temp/aa.mileagerunner.user.js


Nice.... can I make a humble request? I've been racking my brain about what feature I'd like to see on ITA... and this is it... the 0-night stay as an option (and perhaps 0-1 nights). Any chance that could happen?

EDIT - OP... thanks for having ESP! :D

Many thanks to OP for all your work... it's been a while since we've had this much contribution of excellent information/work on MR (and FT in general, quite frankly) ^^

MACH81
Feb 15, 07, 5:22 pm
Nice.... can I make a humble request? I've been racking my brain about what feature I'd like to see on ITA... and this is it... the 0-night stay as an option (and perhaps 0-1 nights). Any chance that could happen?

Many thanks to OP for all your work... it's been a while since we've had this much contribution of excellent information/work on MR (and FT in general, quite frankly) ^^

Read the whole thread Ice!Request already made!:D

IceTrojan
Feb 15, 07, 5:27 pm
Read the whole thread Ice!Request already made!:D

D'oh! (PS - I hate it when ITA does that weird thing where it "logs" you in twice, so when you see new posts it really isn't since the last time you checked in....)

the_happiness_store
Feb 15, 07, 6:14 pm
Johnath may want to verify this but it seems that ITA does not play nice with 0 nights.

It will bring up a calendar of fares with stays of 1 to 29 days. A click on a day then gives an error.

Thanks for the script. I'm mucking with it a little.

By the way is there way for the script to save your choices instead of reverting to the default? My default origin is "ord::ua+" but if I search on just "ord" and I return I would like the page to say "ord" and not "ord::ua+". I will continue working at it.

Johnath
Feb 15, 07, 8:21 pm
Hey folks,

I've gone and updated it again to take into account jabrams' clever suggestions. The 30 day search now has a couple more options in its list, specifically:


about 2 weeks (13-15)
about 3 weeks (20-22)
0-1 nights. As pointed out by the_happiness_store, 0-0 nights doesn't work too well, but 0-1 nights seems to, and you can then uncheck "1 Night" on the results page if you want. Close as I can get, I'm afraid...
Custom. When you choose custom, it will prompt you for the lower and upper bounds and then use that as the search parameter.


I'm continuing to host the new versions myself, so you can find v1.3 (again, remember to remove the old one first) here:

http://www.johnath.com/greasemonkey/itapolish.v1.3.user.js

Holler if I've broken anything, or if there's other pieces that need to be added. Thanks for all the positivity - I'm glad I'm not the only one who finds these tweaks useful.

[And PS to any ITA folks that lurk here - I'm a software usability guy, so this is sort of what I do. I'm secretly hoping, though, that tomorrow you guys are going to steal my code and just build it into the site so that it's available to everyone. :) ]

IceTrojan
Feb 16, 07, 1:26 am
Ack... is there anyway to fix this? When I do a new search, instead of using previously used search terms, the fix replaces it with the new "default" ones.

I just tried to cut out this part:
const PREFERRED_SALES_CITY = "BOS";
const PREFERRED_DEPARTURE_CITY = "QLA:: AA+ "; // Usually a safe guess

...but it got rid of all the tweaks. D'oh!

Johnath
Feb 16, 07, 5:00 am
Ack... is there anyway to fix this? When I do a new search, instead of using previously used search terms, the fix replaces it with the new "default" ones.

I just tried to cut out this part:
const PREFERRED_SALES_CITY = "BOS";
const PREFERRED_DEPARTURE_CITY = "QLA:: AA+ "; // Usually a safe guess

...but it got rid of all the tweaks. D'oh!

Hmm - that could be annoying, couldn't it? Try making this change, and let me know if it works better...

Around line 55, change this:

if(departureCity) {

to this:

if(departureCity && departureCity.value == "") {

That should have the effect of only setting your preferred departure city when the form doesn't already have a value in there (e.g. from a previous search). Let me know if it helps and I'll roll it into the next version.

SmilingBoy
Feb 16, 07, 5:08 am
That is a good addon to start with. Would really appreciate help on all the codes that one can type in ITA like::UA UA UA. I cannot remember all of them, but would find it really useful to have a cheat sheet or something.Hidden advanced options described here (I've got this bookmarked):

http://www.flyertalk.com/forum/showthread.php?t=330932

I find the -overnight option especially useful.

SmilingBoy.

JCinNYC
Apr 15, 07, 12:18 am
This info is great!!! Dumb question (I'm new to firefox) how can I change YYZ to NYC? Haven't been able to figure it out by myself :confused:

Thanks!

AA Flyer
Apr 15, 07, 5:15 am
Will this work with Mozilla v1.7.12... or just FIREFOX?

pltwannab
Apr 16, 07, 7:53 am
This info is great!!! Dumb question (I'm new to firefox) how can I change YYZ to NYC? Haven't been able to figure it out by myself :confused:

Thanks!

the script is saved in

C:\Documents and Settings\<your username>\Application Data\Mozilla\Firefox\Profiles\<some random folder name>\gm_scripts


Edit Itapolishv13.user.js and search & replace YYZ

Explore SE Asia
Apr 16, 07, 8:30 am
Just wanted to thank you for a great script!!!

Oliver

JCinNYC
Apr 16, 07, 10:19 am
the script is saved in

C:\Documents and Settings\<your username>\Application Data\Mozilla\Firefox\Profiles\<some random folder name>\gm_scripts


Edit Itapolishv13.user.js and search & replace YYZ

Thanks for the help!!! I couldn't find the script in my PC though (there's no 'application data' folder), so dunno how it was saved and I did like 10k searches... Great tool though.

SmilingBoy
Apr 16, 07, 10:21 am
Thanks for the help!!! I couldn't find the script in my PC though (there's no 'application data' folder), so dunno how it was saved and I did like 10k searches... Great tool though.Folder is probably hidden. You need to set your Windows Explorer to show system and hidden files.

SmilingBoy.

canuck_in_pa
Apr 16, 07, 10:37 am
Whenever I hit 'edit' inside manage user scripts, it opens up the save file box. Any idea how to make it open a text editor for .js files? I couldn't figure it out under options.

JCinNYC
Apr 16, 07, 10:59 am
Folder is probably hidden. You need to set your Windows Explorer to show system and hidden files.

SmilingBoy.

That was the issue, it's unhidden now and it worked! Beautiful, thanks SmilingBoy ^




Whenever I hit 'edit' inside manage user scripts, it opens up the save file box. Any idea how to make it open a text editor for .js files? I couldn't figure it out under options.

Do a right click on the file itapolishv13.user, and click on the edit option, and the file will open like a word document, make the changes and click on save and you'll ready to go!

canuck_in_pa
Apr 16, 07, 12:41 pm
Do a right click on the file itapolishv13.user, and click on the edit option, and the file will open like a word document, make the changes and click on save and you'll ready to go!

No luck from within Firefox but I was able to edit it in the gm_scripts folder like you said. Thanks!

SQFAN
Apr 16, 07, 1:21 pm
Thanks Johnath ^

Johnath
Apr 17, 07, 7:40 pm
Howdy folks!

Thanks again for all the kind words, I'm glad I'm not the only one who finds it useful.

My buddy Dan recently griped that the webflyer links added by the script should account for the fact that most airline programs have a minimum mileage per segment. I've put version 1.4 up on userscripts.org which includes this calculation. You can get it here:

http://userscripts.org/scripts/show/7505

Remember to remove your old script first (Tools Menu->Greasemonkey->Manage User Scripts...->Select the script and click Uninstall).

This version also only overwrites your preferred departure city if there isn't already text in that field, as per IceTrojan's suggestion. So when you're doing repeat searches and ITA helpfully pre-populates the form data, I won't come along afterwards and wipe it out. :)

Incidentally, if you don't want the 500 mile minimum in your webflyer calcs, or if you want to add extra webflyer parameters (elite bonuses, ticket class bonuses, etc) it can all be done through this line:

const EXTRA_WEBFLYER_PARAMS = 'min=500';

To specify no minimum (and no extra params), make it look like this instead:

const EXTRA_WEBFLYER_PARAMS = '';

(That's two 's, not one "). To specify a 100% elite bonus and a 25% ticket class bonus, on top of the minimum mileage, make it look like this:

const EXTRA_WEBFLYER_PARAMS = 'min=500&bonus=1.00&class_bonus=0.25';

etc.

As for the questions about how to edit the scripts, thank you to those who have already provided assistance. Greasemonkey should allow you to edit the files using the edit button, but it can get confused about which text editor to use. If you are gutsy, and expect to be editing a lot of greasemonkey scripts, you can tell it which editor to use explicitly by opening a new tab in firefox, typing...

about:config

...in the location bar, finding the "greasemonkey.editor" setting, and specifying the full path to your text editor.

But that is a lot of technical work, so if that kind of thing frightens you, don't do it. It's not necessary to do any of that in order to use the script. In fact, forget you read that.

HNL
Apr 17, 07, 8:33 pm
Great stuff - thanks!

pltwannab
Apr 18, 07, 6:46 am
Howdy folks!


(That's two 's, not one "). To specify a 100% elite bonus and a 25% ticket class bonus, on top of the minimum mileage, make it look like this:

const EXTRA_WEBFLYER_PARAMS = 'min=500&bonus=1.00&class_bonus=0.25';

etc.


That is a nice addition for the min, bonus and the class of service. Is it possible to qualify the bonus with the airline. ie can I say if AA or CO or NW bonus=1.00

Thanks

MartinElk
May 20, 07, 2:57 pm
Hmm - that could be annoying, couldn't it? Try making this change, and let me know if it works better...

Around line 55, change this:

if(departureCity) {

to this:

if(departureCity && departureCity.value == "") {

That should have the effect of only setting your preferred departure city when the form doesn't already have a value in there (e.g. from a previous search). Let me know if it helps and I'll roll it into the next version.

Jonathan,

Please add this change to the next version. It works fine, but I'm using Version 1.4, and still had to edit the script to implement it.

Also, is it just me or do others get this response when using the WebFlyer mileage calculator link:

INPUT ERROR...

"nonstop " was not found in our database...

Please check spelling, be sure not to use city name abbreviations.
For more help, please see the help page

Thanks again for your work on this cool script! :cool:

aktchi
May 20, 07, 7:54 pm
...Deleted
...Installation problems solved

jabrams72
Jul 13, 07, 7:17 am
Help! For some reason this is no longer working, so I wanted to reinstall, but the link no longer seems to be working!

MartinElk
Jul 14, 07, 3:34 pm
Help! For some reason this is no longer working, so I wanted to reinstall, but the link no longer seems to be working!

Try this link:

http://userscripts.org/scripts/show/7505

FBKSan
Jul 14, 07, 3:50 pm
Try this link:

http://userscripts.org/scripts/show/7505

Thanks very much for the link! I stumbled upon this add-on when it got bumped, and it's really an excellent tool! Can't wait to try 1.4. Thanks, OP, too!

charly
Jul 16, 07, 12:07 pm
I just discovered this thread.
Thanks , very useful tool.
Carlos.

Explore SE Asia
Jul 24, 07, 3:26 am
Thanks for the great script! Looking forward to my upgrade from 1.3 to 1.4. :)

Explore SE Asia

Romelle
Jan 29, 08, 2:13 am
I'm late to the party and just discovered this thread. Truly impressive piece of work!!

And I hope all you happy new users realize how rare it is to find a computer pro (the OP) that speaks such clear and understandable English, and is so cheerfully responsive!

Romelle

Jaimito Cartero
Mar 12, 08, 6:59 pm
I remembered about reading about this last year, and am finally just installing it. Now, I just have to change the default city, and I'll be all set. Nice work, Johnath!