Fix filling wrapped input fields (#2699)

Fix filling Reddit 2FA field
This commit is contained in:
Sami Vänttinen 2025-09-23 15:45:58 +03:00 committed by GitHub
parent a9a30e7625
commit 6fcd817e96
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 12 additions and 4 deletions

View file

@ -116,9 +116,9 @@ kpxcForm.getNewPassword = function(passwordInputs = []) {
}
// Choose the last three password fields. The first ones are almost always for something else
const current = passwordInputs[passwordInputs.length - 3].value;
const newPass = passwordInputs[passwordInputs.length - 2].value;
const repeatNew = passwordInputs[passwordInputs.length - 1].value;
const current = passwordInputs[passwordInputs.length - 3]?.value;
const newPass = passwordInputs[passwordInputs.length - 2]?.value;
const repeatNew = passwordInputs[passwordInputs.length - 1]?.value;
if ((newPass === repeatNew && current !== newPass && current !== repeatNew)
|| (current === newPass && repeatNew !== newPass && repeatNew !== current)) {

View file

@ -736,12 +736,20 @@ kpxc.setValue = function(field, value, forced = false) {
field.checked = true;
}
// Make sure the input is not wrapped inside another element (custom INPUT element)
if (field?.nodeName !== 'INPUT' && field?.nodeName?.includes('INPUT')) {
const childInput = field?.querySelector('input');
const fieldsFromShadowDOM = kpxcObserverHelper.findInputsFromShadowDOM(field);
field = childInput ?? fieldsFromShadowDOM[0];
}
kpxc.setValueWithChange(field, value, forced);
};
// Sets a new value to input field and triggers necessary events
kpxc.setValueWithChange = function(field, value, forced = false) {
if (!forced && field.readOnly) {
if (!field || (field?.readOnly && !forced)) {
return;
}