diff --git a/content_script.js b/content_script.js index 2b10f28..b3b18f6 100644 --- a/content_script.js +++ b/content_script.js @@ -260,6 +260,42 @@ const iWasDelayed = { } } +const iDidntTravel = { + name: "iDidntTravel", + match: node => node.classList.contains("antrags-typ-auswahl"), + execute: node => { + const noTravel = $$(node, "input#antragstyp-nicht-angetreten"); + if (noTravel instanceof HTMLInputElement){ + noTravel.dispatchEvent(new Event("change")); + return true; + } + return false; + } +} + +const iWentBack = { + name: "iWentBack", + match: node => node.classList.contains("antrags-typ-auswahl"), + execute: node => { + const wentBack = $$(node, "input#antragstyp-abgebrochen"); + if (wentBack instanceof HTMLInputElement){ + wentBack.dispatchEvent(new Event("change")); + return true; + } + return false; + } +} + +const focusTurnaroundStationInput = { + name: "focusTurnaroundStationInput", + expects: "node", + match: node => node instanceof Element && Array.from(node.children).some(c => c.classList.contains("abbruchbahnhof")), + execute: node => { + $$(node, ".abbruchbahnhof .fahrgastrechte-bahnhof__halt-search input").focus(); + return true; + } +} + const moreThan60Minutes = { name: "moreThan60Minutes", match: node => node.classList.contains("verspaetungs-auswahl"), @@ -271,7 +307,10 @@ const moreThan60Minutes = { const continueToForm = { name: "continueToForm", match: node => node.classList.contains("verspaetung-bestaetigung"), - execute: node => $$(node, 'button.fahrgastrechte-continue-button').dispatchEvent(_clickEv()) + execute: node => { + $$(node, 'button.fahrgastrechte-continue-button').dispatchEvent(_clickEv()).focus(); + return true; + } } const focusDepartureInput = { @@ -445,7 +484,7 @@ const enterPaymentDetails = { const defaultStages = [ startClaim, fillData, clickContinue, {"delay": [iWasDelayed, moreThan60Minutes, continueToForm, - focusDepartureInput, jumpToTimeInput], "nodep": [], "abort": []}, + focusDepartureInput, jumpToTimeInput], "nodep": [iDidntTravel, focusDepartureInput], "abort": [iWentBack, focusDepartureInput, focusTurnaroundStationInput]}, activateAppellationDropdown, enterAppellationAndActivateTitleDropdown, enterTitleAndActivateCountryDropdown, enterCountry, enterTextPersonalData, /* continueToPayout, */ enterPaymentDetails