Skip to content

Instantly share code, notes, and snippets.

@yashodhank
Forked from shrayasr/irctc.js
Last active August 29, 2015 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yashodhank/4d6de88924ad1a08fc69 to your computer and use it in GitHub Desktop.
Save yashodhank/4d6de88924ad1a08fc69 to your computer and use it in GitHub Desktop.
IRCTC Tatkal ticket Booking JS helpers
// To be used in conjunction with [Magic Autofill](http://ctrlq.org/irctc/)
/****************************
* TESTED ON CHROME ONLY.
****************************/
// Absolutely required function because of IRCTC's stupid ID naming scheme.
function jq( myid ) {
return "#" + myid.replace( /(:|\.|\[|\]|,)/g, "\\$1" );
}
// Step 1: Login
// Step 2: Go to the "Booked Ticket history (New)" page. This will work only if you have made
// at least 1 booking in the past via IRCTC
// Step 3: Open the developer console
// Step 4: Paste the following in
window.IRCTCJS = {};
window.IRCTCJS.intervalId = setInterval(function(){
$(jq("txnHistory:bookedTicketHistoryDataTable:0:txnid")).trigger("click");
setTimeout(function() {
RichFaces.$('txnHistory:txnDtlPopup').hide();
}, 2000);
}, 5000); // This will keep trigger clicks on the first booking every 5 seconds,
// helping to keep the session alive :)
// Step 5: At 9:58 ish, run the following to stop the clicks
clearInterval(window.IRCTCJS.intervalId);
// Step 6: Just at 10:00, run these to check for trains (should be customized everytime)
$(jq("jpform:fromStation")).val("JAIPUR - JP");
$(jq("jpform:toStation")).val("H SAHIB NANDED - NED");
$(jq("jpform:journeyDateInputDate")).val("25-07-2015");
$(jq("jpform:jpsubmit")).trigger("click");
// Step 7: Select the tatkal category and your train of choice
// Step 8: Use magic autofill from there on.
// Step 9: YOU BOOKED AN IRCTC TATKAL ticket, WOOHOO!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment