ususdei / qute-keepassxc

Qutebrowser userscript to fetch credentials from KeepassXC password database
MIT License
54 stars 10 forks source link

Trigger change events when filling forms #4

Closed aearil closed 3 years ago

aearil commented 4 years ago

After posting #3, I kept digging and apparently, keepassxc-browser's solution seems to work on the two examples I could test (discord and a company website)

https://github.com/keepassxreboot/keepassxc-browser/blob/develop/keepassxc-browser/content/keepassxc-browser.js#L1525

Hope that helps :)

ususdei commented 3 years ago

Ah, great find. I took that javascript snippet from another qutebrowser userscript: https://github.com/qutebrowser/qutebrowser/blob/master/misc/userscripts/password_fill

I looks like they also patched this a few month ago but only added the change event. My javascript isn't that great but from the docs it appears that input should be the even more important event here... So I guess your fix is even better then theirs ;-)

aearil commented 3 years ago

If it's good for Keepassxc, it should be good enough for us ^^

BTW, do you know of any command in qutebrowser to submit the current Form (manually would be best) ? Right now I've added a switch to insert mode after the autofill so that I can simply press enter, but that's not a great solution.

ususdei commented 3 years ago

Hmm, i guess the primary question here is, which form is the "current" form? Do you mean the one which was autofilled with keepass credentials?

I guess you could kind of tag it, by adding a special dummy class to the form after filling in the credentials during autofill. And then you could add a mapping which runs some javascript along the lines of:

document.querySeletor("qutespecialautofilltag").submit()

Maybe some login forms don't work with submit() because they do some extra js shenanigans... in that case it might be better to search for the submit button, and emit a click on that one... I might try some of these ideas next week... hopefully :-D