West Midlands trains delay repay script

Published January 17, 2020

Anyone who has been through the Delay Repay system with a season ticket for West Midlands trains knows that the web site is not built with the user's convenience in mind. The site makes it very difficult to enter things like start and end dates that aren't close to the current date, and it does not remember details across multiple visits.

As such I have a simple block of JavaScript I paste into the console when going through the process to greatly speed it up. When you reach the page to enter your season ticket details, open the developer tools console in your browser and paste in the following (amended with your values, of course):

var validFrom = '15/1/2020';
var validTo = '14/1/2021';
var startStation = 'BIRMINGHAM MR ST';
var endStation = 'OLTON';
var ticketCost = '66.50';
var swiftCardNumber = '631591011781573301'

$('label[for=ticketduration7]').click();
$('label[for=5e07f3f9-bfcb-11e7-b959-0689534b0694]').click();
$('label[for=typeticket2]').click();
$('label[for=ticketPayType4]').click();

document.getElementById('ValidFrom').value = validFrom;
document.getElementById('ValidTo').value = validTo;

document.getElementById('startstation').value = startStation;
document.getElementById('endstation').value = endStation;

document.getElementById('costofticket').value = ticketCost;
document.getElementById('swiftcardNumber').value = swiftCardNumber;

$('label[for=classofticket-1]').click();
Filed under: javascript, trains

Talk is cheap

Leave a comment:

HTML is not valid. Use:
[url=http://www.google.com]Google[/url] [b]bold[/b] [i]italics[/i] [u]underline[/u] [code]code[/code]
'