experiment: acquire bc number from account
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
"use strict;"
|
||||
function luhnValidate(cardNumber) {
|
||||
cardNumber = String(cardNumber).replace(/[\s]/g, "");
|
||||
let odd = false;
|
||||
@@ -37,7 +38,7 @@ async function saveOptions(ev) {
|
||||
clearError();
|
||||
ev.preventDefault();
|
||||
let bcNum = this.querySelector("#bcnum").value;
|
||||
if (!bcNum.length == 16 || !bcNum.startsWith("70814") || !luhnValidate(bcNum)) {
|
||||
if (bcNum.length !== 16 || !bcNum.startsWith("70814") || !luhnValidate(bcNum)) {
|
||||
putError("Your BahnCard number is not valid. Please make sure you haven't made any typos.");
|
||||
return;
|
||||
}
|
||||
@@ -75,5 +76,15 @@ async function restoreOptions() {
|
||||
document.querySelector("#autocontinue").checked = settings.autocontinue || false;
|
||||
}
|
||||
|
||||
function startBcnumAcquisition(ev) {
|
||||
browser.storage.sync.set({"acquireBahncard":true}).then(() => {
|
||||
win = window.open("https://www.bahn.de/buchung/kundenkonto/bahncard", "_blank", "popup")
|
||||
if (win instanceof Window){
|
||||
win.postMessage("__WINDOW_OPENED_FOR_BC_ACQUISITION__");
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', restoreOptions);
|
||||
document.querySelector("form").addEventListener("submit", saveOptions);
|
||||
document.querySelector("form").addEventListener("submit", saveOptions);
|
||||
document.querySelector("#bcnum-get-from-profile").addEventListener("click", startBcnumAcquisition)
|
Reference in New Issue
Block a user