Skip to content

Instantly share code, notes, and snippets.

@Ingvix
Last active March 10, 2021 14:43
Show Gist options
  • Save Ingvix/5d0f1eb14a99b6ee8af6a89c0c734f23 to your computer and use it in GitHub Desktop.
Save Ingvix/5d0f1eb14a99b6ee8af6a89c0c734f23 to your computer and use it in GitHub Desktop.
#!/bin/sh
# qutebrowser userscript
# Helper script to open external editor automatically for text input selected via hint.
# :hint inputs userscript auto-editor
# Best used with generate_ids_4_inputs.js to get every text field an id on which this script depends on.
case "$QUTE_SELECTED_HTML" in
*id=*)
tmp="${QUTE_SELECTED_HTML#*id=\"}"
tmp="${tmp%% *}"
id="${tmp%%>*}"
echo "click-element id $id" >> "$QUTE_FIFO"
sleep 0.05 # Just so element has time to get focused before trying to open editor
echo "open-editor" >> "$QUTE_FIFO"
;;
*)
echo "message-error \"Element does not have an id. Cannot continue.\"" >> "$QUTE_FIFO"
;;
esac
// ==UserScript==
// @name Generate IDs for text inputs and areas that don't already have one. To be used with auto-editor userscript.
// @author Ingvix
// @include *
// ==/UserScript==
var inputs = document.querySelectorAll("input[type=text]:not([id]),textarea:not([id])")
inputs.forEach( function ( input, i) { input.id = "pretty-long-script-generated-id-number-" + i })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment