aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Dieter Plaetinck <dieter@plaetinck.be>2010-08-25 17:51:33 +0200
committerGravatar Dieter Plaetinck <dieter@plaetinck.be>2010-08-25 17:51:33 +0200
commit4c63d4620266ca5914587737e2af6e1b749b23f5 (patch)
tree51afc5262868a99c5bb1b19529be386ed6e6b963
parent86729383c1aa931b0793118eb5853955583e9391 (diff)
parent044b3722ec7c4f3e98739fa0f93a56b875b3db3b (diff)
Merge remote branch 'remotes/pawelz/follow.sh' into experimental
-rw-r--r--examples/config/config3
-rw-r--r--examples/data/scripts/follow.js15
-rwxr-xr-xexamples/data/scripts/follow.sh21
-rw-r--r--examples/data/scripts/go_input.js27
-rwxr-xr-xexamples/data/scripts/go_input.sh20
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