Skip to content

Instantly share code, notes, and snippets.

@shrayasr
Last active January 11, 2018 16:36
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save shrayasr/b317293e9ab5de3718bf to your computer and use it in GitHub Desktop.
Save shrayasr/b317293e9ab5de3718bf 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();
}, 5000);
}, 10000); // This will keep trigger clicks on the first booking every 5 seconds,
// helping to keep the session alive :)
// Step 5: At 9:59:55 ish, run the following to stop the clicks and take you to your booking (should be customized everytime)
clearInterval(window.IRCTCJS.intervalId);
$(jq("jpform:fromStation")).val("BANGALORE CY JN - SBC");
$(jq("jpform:toStation")).val("CHENNAI CENTRAL - MAS");
$(jq("jpform:journeyDateInputDate")).val("20-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!
@yashodhank
Copy link

Session Timeouted out, just tried it now, what might be the reason?
Thanks for sharing 👍

@shrayasr
Copy link
Author

shrayasr commented Aug 5, 2015

Timed out even when you were running this? The first transaction in your transaction history was being repeatedly clicked on, correct?

@shrayasr
Copy link
Author

@yashodhank: I tried this out today and it worked. Fiddled a little bit with the intervals. Do check it out again :)

@PrasathHpSp
Copy link

Help in using this code ...Which IDE should i have to use ......and how should I modify the code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment