aboutsummaryrefslogtreecommitdiffhomepage
path: root/examples
diff options
context:
space:
mode:
authorGravatar Pawel Tomak <satherot@gmail.com>2010-02-27 07:34:55 +0100
committerGravatar Paweł Zuzelski <pawelz@pld-linux.org>2010-02-27 18:23:52 +0100
commit93f2aaf7ed0b00308db7d2f9374ea5519532825d (patch)
treef43d4c5e536d430770cac54d81f9667a0a0b639f /examples
parentbeed024a33bad3d4e73560320d099e7c99bee559 (diff)
Applied changes suggested by Dieter:
* Removed bash style * removed lincece stuff * $domain is set before it's use
Diffstat (limited to 'examples')
-rwxr-xr-xexamples/data/scripts/eFormFiller.sh121
1 files changed, 53 insertions, 68 deletions
diff --git a/examples/data/scripts/eFormFiller.sh b/examples/data/scripts/eFormFiller.sh
index 4c9c1b4..5081593 100755
--- a/examples/data/scripts/eFormFiller.sh
+++ b/examples/data/scripts/eFormFiller.sh
@@ -1,20 +1,4 @@
#!/bin/sh
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-#
-# Based on script from Uzbl examples (anonymous author)
-# Copyright (c) 2009 by Paweł Tomak <satherot (at) gmail (dot) com>
-#
#
# Enhanced html form (eg for logins) filler (and manager) for uzbl.
#
@@ -45,8 +29,8 @@ keydir=${XDG_DATA_HOME:-$HOME/.local/share}/uzbl/dforms
[ -d "$keydir" ] || mkdir "$keydir"
editor=${VISUAL}
-if [[ -z ${editor} ]]; then
- if [[ -z ${EDITOR} ]]; then
+if [ -z ${editor} ]; then
+ if [ -z ${EDITOR} ]; then
editor='xterm -e vim'
else
editor="xterm -e ${EDITOR}"
@@ -73,65 +57,66 @@ action=$1
[ -d $keydir ] || mkdir $keydir || exit 1
+domain=$(echo $url | sed 's/\(http\|https\):\/\/\([^\/]\+\)\/.*/\2/')
+
if [ "$action" != 'edit' -a "$action" != 'new' -a "$action" != 'load' -a "$action" != 'add' ]
then
- action=new
- [[ -e $keydir/$domain ]] && action=load
-elif [ "$action" == 'edit' ] && [[ ! -e $keydir/$domain ]]
+ action="new"
+ [ -e "$keydir/$domain" ] && action="load"
+elif [ "$action" == 'edit' ] && [ ! -e "$keydir/$domain" ]
then
- action=new
+ action="new"
fi
-domain=$(echo $url | sed 's/\(http\|https\):\/\/\([^\/]\+\)\/.*/\2/')
if [ "$action" = 'load' ]
then
- [[ -e $keydir/$domain ]] || exit 2
- if [[ `cat $keydir/$domain|grep "!profile"|wc -l` -gt 1 ]]
- then
- menu=`cat $keydir/$domain| \
- sed -n 's/^!profile=\([^[:blank:]]\+\)/\1/p'`
- option=`echo -e -n "$menu"| dmenu -nb "${NB}" -nf "${NF}" -sb "${SB}" -sf "${SF}" -p "${PROMPT}"`
- fi
+ [ -e $keydir/$domain ] || exit 2
+ if [ `cat $keydir/$domain|grep "!profile"|wc -l` -gt 1 ]
+ then
+ menu=`cat $keydir/$domain| \
+ sed -n 's/^!profile=\([^[:blank:]]\+\)/\1/p'`
+ option=`echo -e -n "$menu"| dmenu -nb "${NB}" -nf "${NF}" -sb "${SB}" -sf "${SF}" -p "${PROMPT}"`
+ fi
- cat $keydir/$domain | \
- sed -n -e "/^!profile=${option}/,/^!profile=/p" | \
- sed -n -e 's/\([^(]\+\)([^)]\+):[ ]*\([^[:blank:]]\+\)/js document.getElementsByName("\1")[0].value="\2";/p' | \
- sed -e 's/@/\\@/p' >> $fifo
+ cat $keydir/$domain | \
+ sed -n -e "/^!profile=${option}/,/^!profile=/p" | \
+ sed -n -e 's/\([^(]\+\)([^)]\+):[ ]*\([^[:blank:]]\+\)/js document.getElementsByName("\1")[0].value="\2";/p' | \
+ sed -e 's/@/\\@/p' >> $fifo
else
- if [[ "$action" == 'new' || "$action" == 'add' ]]
- then
- if [ "$action" == 'new' ]
- then
- echo "!profile=NAME_THIS_PROFILE$RANDOM" > $keydir/$domain
- else
- echo "!profile=NAME_THIS_PROFILE$RANDOM" >> $keydir/$domain
- fi
- #
- # 2. and 3. line (tr -d and sed) are because, on gmail login for example,
- # <input > tag is splited into lines
- # ex:
- # <input name="Email"
- # type="text"
- # value="">
- # So, tr removes all new lines, and sed inserts new line after each >
- # Next sed selects only <input> tags and only with type == "text" or == "password"
- # If type is first and name is second, then another sed will change their order
- # so the last sed will make output
- # text_from_the_name_attr(text or password):
- #
- # login(text):
- # passwd(password):
- #
- echo 'js document.documentElement.outerHTML' | \
- socat - unix-connect:$socket | \
- tr -d '\n' | \
- sed 's/>/>\n/g' | \
- sed -n 's/.*\(<input[^>]\+>\).*/\1/;/type="\(password\|text\)"/Ip' | \
- sed 's/\(.*\)\(type="[^"]\+"\)\(.*\)\(name="[^"]\+"\)\(.*\)/\1\4\3\2\5/I' | \
- sed 's/.*name="\([^"]\+\)".*type="\([^"]\+\)".*/\1(\2): /I' >> $keydir/$domain
- fi
- [[ -e $keydir/$domain ]] || exit 3 #this should never happen, but you never know.
- $editor $keydir/$domain #TODO: if user aborts save in editor, the file is already overwritten
+ if [ "$action" == 'new' -o "$action" == 'add' ]
+ then
+ if [ "$action" == 'new' ]
+ then
+ echo "!profile=NAME_THIS_PROFILE$RANDOM" > $keydir/$domain
+ else
+ echo "!profile=NAME_THIS_PROFILE$RANDOM" >> $keydir/$domain
+ fi
+ #
+ # 2. and 3. line (tr -d and sed) are because, on gmail login for example,
+ # <input > tag is splited into lines
+ # ex:
+ # <input name="Email"
+ # type="text"
+ # value="">
+ # So, tr removes all new lines, and sed inserts new line after each >
+ # Next sed selects only <input> tags and only with type == "text" or == "password"
+ # If type is first and name is second, then another sed will change their order
+ # so the last sed will make output
+ # text_from_the_name_attr(text or password):
+ #
+ # login(text):
+ # passwd(password):
+ #
+ echo 'js document.documentElement.outerHTML' | \
+ socat - unix-connect:$socket | \
+ tr -d '\n' | \
+ sed 's/>/>\n/g' | \
+ sed -n 's/.*\(<input[^>]\+>\).*/\1/;/type="\(password\|text\)"/Ip' | \
+ sed 's/\(.*\)\(type="[^"]\+"\)\(.*\)\(name="[^"]\+"\)\(.*\)/\1\4\3\2\5/I' | \
+ sed 's/.*name="\([^"]\+\)".*type="\([^"]\+\)".*/\1(\2): /I' >> $keydir/$domain
+ fi
+ [ -e "$keydir/$domain" ] || exit 3 #this should never happen, but you never know.
+ $editor "$keydir/$domain" #TODO: if user aborts save in editor, the file is already overwritten
fi
# vim:fileencoding=utf-8:sw=4