Skip to content

Instantly share code, notes, and snippets.

@shrayasr
Last active July 28, 2024 14:33
Show Gist options
  • Select an option

  • Save shrayasr/b317293e9ab5de3718bf to your computer and use it in GitHub Desktop.

Select an option

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
Copy Markdown

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

@shrayasr
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown

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