diff --git a/src/inject.js b/src/inject.js index 2e9aedb..0a14e96 100644 --- a/src/inject.js +++ b/src/inject.js @@ -409,6 +409,7 @@ } // Set the field value + let initialValue = el.value || el.getAttribute("value"); el.setAttribute("value", value); el.value = value; @@ -417,6 +418,13 @@ el.dispatchEvent(new Event(eventName, { bubbles: true })); } + // re-set value if unchanged after firing post-fill events + // (in case of sabotage by the site's own event handlers) + if ((el.value || el.getAttribute("value")) === initialValue) { + el.setAttribute("value", value); + el.value = value; + } + // Finally unfocus the element el.dispatchEvent(new Event("blur", { bubbles: true })); return true;