diff options
-rw-r--r-- | examples/config/config | 3 | ||||
-rw-r--r-- | examples/data/scripts/follow.js | 15 | ||||
-rwxr-xr-x | examples/data/scripts/follow.sh | 21 | ||||
-rw-r--r-- | examples/data/scripts/go_input.js | 27 | ||||
-rwxr-xr-x | examples/data/scripts/go_input.sh | 20 |
5 files changed, 82 insertions, 4 deletions
diff --git a/examples/config/config b/examples/config/config index cad9f92..622f859 100644 --- a/examples/config/config +++ b/examples/config/config @@ -282,7 +282,8 @@ set follow_hint_keys = 0123456789 #set follow_hint_keys = qwerty #set follow_hint_keys = asdfghjkl; #set follow_hint_keys = thsnd-rcgmvwb/;789aefijkopquxyz234 -@cbind fl* = script @scripts_dir/follow.js '@follow_hint_keys %s' +@cbind fl* = spawn @scripts_dir/follow.sh "%s" +@cbind gi = spawn @scripts_dir/go_input.sh # Form filler binds # This script allows you to configure (per domain) values to fill in form diff --git a/examples/data/scripts/follow.js b/examples/data/scripts/follow.js index a42447c..77c40cd 100644 --- a/examples/data/scripts/follow.js +++ b/examples/data/scripts/follow.js @@ -130,17 +130,26 @@ function clickElem(item) { if (name == 'A') { item.click(); window.location = item.href; + return "XXXRESET_MODEXXX"; } else if (name == 'INPUT') { - var type = item.getAttribute('type').toUpperCase(); - if (type == 'TEXT' || type == 'FILE' || type == 'PASSWORD') { + var type; + try { + type = item.getAttribute('type').toUpperCase(); + } catch(err) { + type = 'TEXT'; + } + if (type == 'TEXT' || type == 'SEARCH' || type == 'PASSWORD') { item.focus(); item.select(); + return "XXXEMIT_FORM_ACTIVEXXX"; } else { item.click(); + return "XXXRESET_MODEXXX"; } } else if (name == 'TEXTAREA' || name == 'SELECT') { item.focus(); item.select(); + return "XXXEMIT_FORM_ACTIVEXXX"; } else { item.click(); window.location = item.href; @@ -242,7 +251,7 @@ function followLinks(follow) { var oldDiv = doc.getElementById(uzbldivid); var leftover = [[], []]; if (s.length == len && linknr < elems[0].length && linknr >= 0) { - clickElem(elems[0][linknr]); + return clickElem(elems[0][linknr]); } else { for (var j = 0; j < elems[0].length; j++) { var b = true; diff --git a/examples/data/scripts/follow.sh b/examples/data/scripts/follow.sh new file mode 100755 index 0000000..ba59575 --- /dev/null +++ b/examples/data/scripts/follow.sh @@ -0,0 +1,21 @@ +#!/bin/sh + +config=$1; +shift +pid=$1; +shift +xid=$1; +shift +fifo=$1; +shift +socket=$1; +shift +url=$1; +shift +title=$1; +shift + +case $(echo 'script @scripts_dir/follow.js "@{follow_hint_keys} '$1'"' | socat - unix-connect:$socket) in + *XXXEMIT_FORM_ACTIVEXXX*) echo 'event FORM_ACTIVE' | socat - unix-connect:$socket ;; + *XXXRESET_MODEXXX*) echo 'set mode=' | socat - unix-connect:$socket ;; +esac diff --git a/examples/data/scripts/go_input.js b/examples/data/scripts/go_input.js new file mode 100644 index 0000000..557671f --- /dev/null +++ b/examples/data/scripts/go_input.js @@ -0,0 +1,27 @@ +var elements = document.querySelectorAll("textarea, input" + [ + ":not([type='button'])", + ":not([type='checkbox'])", + ":not([type='hidden'])", + ":not([type='image'])", + ":not([type='radio'])", + ":not([type='reset'])", + ":not([type='submit'])"].join("")); +function gi() { + if (elements) { + var el, i = 0; + while((el = elements[i++])) { + var style=getComputedStyle(el, null); + if (style.display !== 'none' && style.visibility === 'visible') { + if (el.type === "file") { + el.click(); + } + else { + el.focus(); + } + return "XXXEMIT_FORM_ACTIVEXXX"; + } + } + } +} + +gi(); diff --git a/examples/data/scripts/go_input.sh b/examples/data/scripts/go_input.sh new file mode 100755 index 0000000..c873dd8 --- /dev/null +++ b/examples/data/scripts/go_input.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +config=$1; +shift +pid=$1; +shift +xid=$1; +shift +fifo=$1; +shift +socket=$1; +shift +url=$1; +shift +title=$1; +shift + +case $(echo 'script @scripts_dir/go_input.js' | socat - unix-connect:$socket) in + *XXXEMIT_FORM_ACTIVEXXX*) echo 'event FORM_ACTIVE' | socat - unix-connect:$socket ;; +esac |