Handy little command: copy-hint-image-title-text

I use this when, say, browsing through the excellent XKCD web comic, since a good portion of the humor is hidden in the title text aka the tooltip you see when you hover over certain images.

(define-command-global copy-hint-image-title-text ()
  "Prompt for image hints and save its title text to clipboard, if possible."
  (nyxt/hint-mode:query-hints "Select image"
                              (lambda (results)
                                (alex:if-let ((title (plump:get-attribute (first results) "title")))
                                  (trivial-clipboard:text title)
                                  (echo "No title text in selected image!")))
                              :multi-selection-p nil
                              :selector "img"))
2 Likes