Filling in login credentials

In fill-credentials.lisp, I have rudimentary filling in of login credentials which can be made semi-automatic from buffer-loaded-hook if you load it and do something like

(define-configuration web-buffer
  ((buffer-loaded-hook
    (reduce #'hooks:add-hook
	        (mapcar #'nyxt::make-handler-buffer (list #'nyxt::fill-credentials-if-login-present))
	        :initial-value %slot-default%))))

The entry-point is a command fill-credentials which offers a choice of credentials and tries to fill in a login on the current page. The hook calls this if it sees a login on the page.

Limitations:

  1. I have only implemented the unix password-store password-interface (though experts should be able to fill in the details for the other password-interfaces).
  2. The detection of logins is super-primitive and a work in progress. Any wisdom or prior art here would be gratefully received.
  3. The code is very clunky! In particular, I would appreciate a better way of detecting whether a page has an element with a given attribute (would the new dom stuff help here?).

In any case, maybe someone else will find this useful/amusing/a starting point for something better!

1 Like

Yes, new DOM could be of help there! You could find password field with (clss:select "input[type="password" (nyxt/web-mode:document-model (current-mode 'web))). The node you get this way you can recursively ascend to the plump:parent of. Then you can look for inputs that are not the password one, inside the parent elements.

Additionally, how about copying passwords instead of parsing them? This is portable across password interfaces and is reliable enough.

Thanks! I realised how to do this an hour after I made the original post. The clss:select approach is easier to reason about than my parenscript approach but runs 10 times slower (though maybe that doesn't matter: it is still fast). This may be the way forward.

Main reason is that I don't know how to get the username/password from the clipboard to the target element.

Related question: if I use the new DOM stuff to identify an input element, how do I then put text in that element?

trivial-clipboard:text should get you the contents of the clipboard. I’m not sure it’s password-friendly, though. Needs checking.

See element-hint.lisp for examples of function that act on our DOM. In short, define-parenscript that will look for a certain nyxt-identifier in JS DOM and act on it in JS world.

Yes, this works fine. Thank you. fill-credentials now works for any password-interface.

1 Like

Thanks for the, um, hint! I shall inspect element-hint.lisp.

1 Like