From b9958389b8c43c400cb32439326eb9cf322c68a4 Mon Sep 17 00:00:00 2001 From: iw0 Date: Wed, 10 Apr 2024 23:28:20 +0200 Subject: [PATCH] make all the dropdowns & the country select work again --- content_script.js | 33 +++++++++++++++++++-------------- options/index.html | 2 +- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/content_script.js b/content_script.js index d2a5077..7eedbdb 100644 --- a/content_script.js +++ b/content_script.js @@ -293,33 +293,38 @@ const activateAppellationDropdown = { /**@type Stage */ const enterAppellationAndActivateTitleDropdown = { name: "enterAppellationAndActivateTitleDropdown", - match: node => node.classList.contains("db-web-dropdown-outer-container") && node.querySelector(".db-web-select-list") !== null, - execute: node => { + expects: "mutation", + match: mut => matchDropdown(mut, "test-name-anrede", "open"), + /**@param {MutationRecord} mut */ + execute: mut => { ensureSettingsProp("addr__appellation", v => { - const selectList = $$(node, "ul"); - selectList.querySelector(`[data-value=${foundKeys.addr__appellation}]`).dispatchEvent(_clickEv()); + getDropdownList(mut).querySelector(`[data-value=${v}]`).dispatchEvent(_clickEv()); + $('.test-name-titel.db-web-select button').dispatchEvent(_clickEv()); }, () => { - node.parentElement.parentElement.parentElement.querySelector("button").dispatchEvent(_clickEv()); + getDropdownCloseButton(mut).dispatchEvent(_clickEv()); + $('.test-name-titel.db-web-select button').dispatchEvent(_clickEv()); }); - $('.test-name-titel.db-web-select button').dispatchEvent(_clickEv()); return true; } } +/**@type Stage */ const enterTitleAndActivateCountryDropdown = { name: "enterTitle", - /**@param {Element} node */ - match: node => node.classList.contains("db-web-dropdown-outer-container") && node.querySelector(".db-web-select-list") !== null, - /**@param {Element} node */ - execute: node => { + expects: "mutation", + /**@param {MutationRecord} mut */ + match: mut => matchDropdown(mut, "test-name-titel", "open"), + /**@param {MutationCallback} mut */ + execute: mut => { ensureSettingsProp("addr__title", v => { - const selectList = $$(node, "ul"); - selectList.querySelector(`[data-value=${foundKeys.addr__title}]`).dispatchEvent(_clickEv()); + const selectList = getDropdownList(mut); + selectList.querySelector(`[data-value=${v}]`).dispatchEvent(_clickEv()); + $(".test-adresse-land.db-web-select button").dispatchEvent(_clickEv()); }, () => { - node.parentElement.parentElement.parentElement.querySelector("button").dispatchEvent(_clickEv()); + getDropdownCloseButton(mut).dispatchEvent(_clickEv()); + $(".test-adresse-land.db-web-select button").dispatchEvent(_clickEv()); } ); - document.querySelector(".test-adresse-land.db-web-select button").dispatchEvent(_clickEv()); return true; } } diff --git a/options/index.html b/options/index.html index caf0565..061db95 100644 --- a/options/index.html +++ b/options/index.html @@ -90,7 +90,7 @@ - Open form on "Personal details" section - Open country select dropdown - Execute: - d="";document.querySelectorAll(".test-adresse-land ul li").forEach(e=>d=d.concat('\n')); + d="";document.querySelectorAll(".test-adresse-land ul li").forEach(e=>d=d.concat('\n')); -->