diff --git a/content_script.js b/content_script.js index 2d0b7c2..f6bf202 100644 --- a/content_script.js +++ b/content_script.js @@ -30,9 +30,13 @@ let disruption = ""; * @param {function} noExistCallback */ const ensureSettingsProp = (prop, existCallback, noExistCallback) => { - settings.get(prop).then(foundKeys => { + return settings.get(prop).then(foundKeys => { console.debug("storage returned", foundKeys); - return (prop in foundKeys ? existCallback(foundKeys[prop]) : noExistCallback()); + if (prop in foundKeys){ + return existCallback(foundKeys[prop]); + } else { + return noExistCallback(); + } }); } @@ -64,13 +68,16 @@ const bankDetailConfigKeys = ["pymt__iban", "pymt__bic"]; function processSingleAddedNode(n) { if (currentStage.match(n)) { console.info(currentStage.name, "matched: ", n); - const success = currentStage.execute(n) - if (success) { - console.info(currentStage.name, "executed successfully"); - } else { - console.error(currentStage.name, "failed"); - } - nextStage(); + const success = currentStage.execute(n); + Promise.resolve(success).then((result => { + if (result === true) { + console.info(currentStage.name, "executed successfully"); + } else { + console.error(currentStage.name, "failed"); + } + nextStage(); + })); + } else { console.debug(currentStage.name, "did not match: ", n); } @@ -103,7 +110,7 @@ function processMutations(mutationList, observer) { if (currentStage.expects == 'mutation') { if (currentStage.match(mutation)) { console.info(currentStage.name, "matched: ", mutation); - success = currentStage.execute(mutation); + let success = currentStage.execute(mutation); if (success){ console.info(currentStage.name, "executed successfully"); } else { @@ -349,14 +356,15 @@ const jumpToTimeInput = { return true; } } - +/** @type Stage */ const activateAppellationDropdown = { name: "activateAppellationDropdown", match: node => node.classList.contains("persoenlicheangaben") && hasConfiguredPersonalData, execute: node => { return ensureSettingsProp("addr__appellation", () => { - const selectList = node.querySelector('.test-name-anrede.db-web-select'); - selectList.querySelector('button').dispatchEvent(_clickEv()); + const button = node.querySelector('.test-name-anrede.db-web-select button'); + button.dispatchEvent(_clickEv()); + return true; }, () => true); } }