./uzbl --uri http://www.uzbl.org --verbose
test-config: uzbl
- ./uzbl --uri http://www.uzbl.org --config examples/configs/sampleconfig-dev --verbose
+ ./uzbl --uri http://www.uzbl.org --verbose
+
+test-config-dev: uzbl
+ XDG_DATA_HOME=./examples/data XDG_CONFIG_HOME=./examples/config ./uzbl --uri http://www.uzbl.org --config $XDG_CONFIG_HOME/uzbl/sampleconfig --verbose
+
+test-config-share: uzbl
+ XDG_DATA_HOME=/usr/share/uzbl/examples/data XDG_CONFIG_HOME=/usr/share/uzbl/examples/config ./uzbl --uri http://www.uzbl.org --config $XDG_CONFIG_HOME/uzbl/sampleconfig --verbose
-test-config-real: uzbl
- ./uzbl --uri http://www.uzbl.org --config /usr/share/uzbl/examples/configs/sampleconfig --verbose
clean:
rm -f uzbl
cp -ax docs $(PREFIX)/share/uzbl/
cp -ax config.h $(PREFIX)/share/uzbl/docs/
cp -ax examples $(PREFIX)/share/uzbl/
- cp -ax uzbl.png $(PREFIX)/share/uzbl/
install -D -m644 AUTHORS $(PREFIX)/share/uzbl/docs
install -D -m644 README $(PREFIX)/share/uzbl/docs
--- /dev/null
+# This file demonstrates how one *could* manage his cookies. this file is used by the example cookie handler script.
+# stick to this format.
+# trusted -> always store what we get, send what we have (TODO: by default, or when requested?)
+# deny -> deny storing + sending
+
+# if you don't like to edit this file manually, you could even write a script that adds/removes entries using sed, and call the script from uzbl with a keybind...
+
+
+TRUSTED
+bbs.archlinux.org
+archlinux.org
+linux.com
+
+
+
+
+DENY
+www.icanhascheezburger.com
+
+
+
+# rest -> ask
\ No newline at end of file
--- /dev/null
+
+# example uzbl config. in a real config, we should obey the xdg spec
+# all settings are optional. you can use uzbl without any config at all (but it won't do much)
+
+# keyboard behavior is vimstyle by default (all commands -> 1 key). set
+# always_insert_mode to always be in insert mode and disable going out of it.
+# if you do this, make sure you've set a modkey so you can reach the commands
+# from insert mode by combining them with the modkey
+
+# TODO: ability to attach misc things (spawn <foo>, script <bar>,.. to internal events)
+# Usually you want to spawn a script to handle things, but any command (such as sh) can be used
+set history_handler = spawn $XDG_DATA_HOME/scripts/history.sh
+set download_handler = spawn $XDG_DATA_HOME/scripts/download.sh
+set cookie_handler = spawn $XDG_DATA_HOME/scripts/cookies.py
+
+set minimum_font_size = 6
+set font_size = 11
+## monospace_size defaults to font_size, but you can alter it independently
+#set monospace_size = 10
+
+## Display or supress images within html sites
+#set autoload_images = 0
+
+## Shrink images to window size
+#set autoshrink_images = 0
+
+## Spellchecker
+#set enable_spellcheck = 1
+
+## Private browsing
+#set enbale_private = 0
+
+## The URI of a stylesheet that is applied to every page
+#set stylesheet_uri = http://www.user.com/mystylelesheet.css
+
+## enable/disable JavaScript
+#set disbale_scripts = 1
+
+## Whether text areas are resizable
+#set resizeable_text_areas = 1
+
+## The default encoding used to display text
+#set default_encoding = iso-8859-1
+
+## Whether background images should be printed
+#set print_background = 0
+
+## Enforce a resolution of 96 DPI. This is meant for compatibility with
+## web pages which cope badly with different screen resolutions
+#set enforce_96_dpi = 1
+
+
+#
+# use with bind ... = sh <shell-oneliner>
+set shell_cmd = sh -c
+
+
+
+# Behaviour and appearance
+set show_status = 1
+# you can optionally use this setting to override the background color of the statusbar from your GTK theme.
+set status_background = #303030
+set status_format = <span font_family="monospace"><span background="khaki" foreground="black">[MODE]</span> [<span weight="bold" foreground="red">KEYCMD</span>] <span foreground="#606060"> LOAD_PROGRESSBAR </span><span foreground="#99FF66">URI</span> <span foreground="khaki">NAME</span> <span foreground="orange">MSG</span><span foreground="#606060">SELECTED_URI</span></span>
+set status_top = 0
+# define how your titlebar should look like. (short = statusbar is also shown, long = show everything you must see if statusbar is off)
+set title_format_short = TITLE - Uzbl browser <NAME>
+set title_format_long = KEYCMD MODE TITLE - Uzbl browser <NAME> > SELECTED_URI
+# set the characters to use for, and the width of the progress bar
+set status_pbar_done = *
+set status_pbar_pending = -
+set status_pbar_width = 12
+set insert_indicator = I
+set command_indicator = C
+set modkey = Mod1
+# reset to command mode when new page is loaded
+set reset_command_mode = 1
+# this var has precedence over reset_command_mode
+set always_insert_mode = 0
+
+# to start a local socks server, do : ssh -fND localhost:8118 localhost
+#set proxy_url = http://127.0.0.1:8118
+#values 0-3
+#set http_debug = 0
+#set useragent = uzbl (Webkit WEBKIT_MAJOR.WEBKIT_MINOR.WEBKIT_MICRO)
+# Example user agent containing everything:
+set useragent = Uzbl (Webkit WEBKIT_MAJOR.WEBKIT_MINOR.WEBKIT_MICRO) (SYSNAME NODENAME KERNREL KERNVER ARCH_SYSTEM [ARCH_UZBL]) (Commit COMMIT)
+#set max_conns = 0
+#set max_conns_host = 0
+
+set fifo_dir = /tmp
+set socket_dir = /tmp
+
+# Key bindings
+bind j = scroll_vert 20
+bind k = scroll_vert -20
+bind h = scroll_horz -20
+bind l = scroll_horz 20
+bind << = scroll_begin
+bind >> = scroll_end
+bind b = back
+bind m = forward
+bind s = stop
+bind r = reload
+bind R = reload_ign_cache
+bind + = zoom_in
+bind - = zoom_out
+bind 1 = sh "echo set zoom_level = 1.0 > $4"
+bind 2 = sh "echo set zoom_level = 2.0 > $4"
+bind t = toggle_status
+# Hilight matches. Notice the * after the slash - it makes the command incremental, i.e. gets called
+# on every character you type. You can do `bind /_ = search %s' if you want it less interactive.
+bind /* = search %s
+bind ?* = search_reverse %s
+#jump to next
+bind n = search
+bind N = search_reverse
+bind gh = uri http://www.uzbl.org
+#TODO: set uri?
+bind o _ = uri %s
+bind :wiki _ = uri http://wiki.archlinux.org/index.php/Special:Search?search=%s&go=Go
+bind gg _ = uri http://www.google.com/search?q=%s
+bind i = toggle_insert_mode
+# disable insert mode (1 to enable). note that Esc works to disable, regardless of this setting
+bind I = toggle_insert_mode 0
+# Enclose the executable in quotes if it has spaces. Any additional parameters you use will
+# appear AFTER the default parameters
+bind B = spawn $XDG_DATA_HOME/scripts/insert_bookmark.sh
+bind U = spawn $XDG_DATA_HOME/scripts/load_url_from_history.sh
+bind u = spawn $XDG_DATA_HOME/scripts/load_url_from_bookmarks.sh
+# with the sample yank script, you can yank one of the arguments into clipboard/selection
+bind yurl = spawn $XDG_DATA_HOME/scripts/yank.sh 6 primary
+bind ytitle = spawn $XDG_DATA_HOME/scripts/yank.sh 7 clipboard
+# does the same as yurl but without needing a script
+bind y2url = sh 'echo -n $6 | xclip'
+# go the page from primary selection
+bind p = sh "echo uri `xclip -selection primary -o` > $4"
+# go to the page in clipboard
+bind P = sh "echo uri `xclip -selection clipboard -o` > $4"
+bind ZZ = exit
+bind S = js alert("hi");
+# example showing how to use sh
+# it sends a command to the fifo, whose path is told via a positional param
+# if fifo_dir is not set, it'll echo to a file named (null) somewhere >:) remember to delete it
+# The body of the shell command should be one parameter, so if it has spaces like here,
+# you must enclose it in quotes. Remember to escape (and double-escape) quotes and backslashes
+# in the body. Any additional parameters you use will appear AFTER the default parameters (cfg file
+# path, fifo & socket dirs, etc.)
+bind XS = sh 'echo "js alert (\\"This is sent by the shell via a fifo\\")" > "$4"'
+bind dump = sh "echo dump_config > $4"
+# this script allows you to configure (per domain) values to fill in form fields (eg login information) and to fill in these values automatically
+bind za = spawn $XDG_DATA_HOME/scripts/formfiller.sh
+bind ze = spawn $XDG_DATA_HOME/scripts/formfiller.sh edit
+bind zn = spawn $XDG_DATA_HOME/scripts/formfiller.sh new
+bind zl = spawn $XDG_DATA_HOME/scripts/formfiller.sh load
+
+# other - more advanced - implementation using perl: (could not get this to run - Dieter )
+bind LL = spawn $XDG_DATA_HOME/scripts/formfiller.pl load
+bind LN = spawn $XDG_DATA_HOME/scripts/formfiller.pl new
+bind LE = spawn $XDG_DATA_HOME/scripts/formfiller.pl edit
+
+# we ship some javascripts to do keyboard based link hinting/following. (webkit does not have C DOM bindings yet)
+# this is similar to how it works in vimperator (and konqueror)
+# TODO: did we resolve: "no click() event for hyperlinks so no referrer set" ?
+#hit F to toggle the Hints (now in form of link numbering)
+bind F = script $XDG_DATA_HOME/scripts/hint.js
+# the most stable version:
+bind fl* = script $XDG_DATA_HOME/scripts/follow_Numbers.js %s
+# using strings, not polished yet:
+bind fL* = script $XDG_DATA_HOME/scripts/follow_Numbers_Strings.js %s
+
+# you can use this to disable all plugins
+set disable_plugins = 0
+
+set icon = ./uzbl.png
+
+# "home" page if you will
+set uri = uzbl.org
+++ /dev/null
-# This file demonstrates how one *could* manage his cookies. this file is used by the example cookie handler script.
-# stick to this format.
-# trusted -> always store what we get, send what we have (TODO: by default, or when requested?)
-# deny -> deny storing + sending
-
-# if you don't like to edit this file manually, you could even write a script that adds/removes entries using sed, and call the script from uzbl with a keybind...
-
-
-TRUSTED
-bbs.archlinux.org
-archlinux.org
-linux.com
-
-
-
-
-DENY
-www.icanhascheezburger.com
-
-
-
-# rest -> ask
\ No newline at end of file
+++ /dev/null
-
-# example uzbl config. in a real config, we should obey the xdg spec
-# all settings are optional. you can use uzbl without any config at all (but it won't do much)
-
-# keyboard behavior is vimstyle by default (all commands -> 1 key). set
-# always_insert_mode to always be in insert mode and disable going out of it.
-# if you do this, make sure you've set a modkey so you can reach the commands
-# from insert mode by combining them with the modkey
-
-# TODO: ability to attach misc things (spawn <foo>, script <bar>,.. to internal events)
-# You can use any command in place of spawn
-set history_handler = spawn /usr/share/uzbl/examples/scripts/history.sh
-set download_handler = spawn /usr/share/uzbl/examples/scripts/download.sh
-set cookie_handler = spawn /usr/share/uzbl/examples/scripts/cookies.py
-
-set minimum_font_size = 6
-set font_size = 11
-# monospace_size defaults to font_size, but you can alter it independently
-#set monospace_size = 10
-
-# use with bind ... = sh <shell-oneliner>
-set shell_cmd = sh -c
-
-
-
-# Behaviour and appearance
-set show_status = 1
-# you can optionally use this setting to override the background color of the statusbar from your GTK theme.
-set status_background = #303030
-set status_format = <span font_family="monospace"><span background="khaki" foreground="black">MODE</span> [<span weight="bold" foreground="red">KEYCMD</span>] <span foreground="#606060"> LOAD_PROGRESSBAR </span><span foreground="#99FF66">URI</span> <span foreground="khaki">NAME</span> <span foreground="orange">MSG</span><span foreground="#606060">SELECTED_URI</span></span>
-set status_top = 0
-# define how your titlebar should look like. (short = statusbar is also shown, long = show everything you must see if statusbar is off)
-set title_format_short = TITLE - Uzbl browser <NAME>
-set title_format_long = KEYCMD MODE TITLE - Uzbl browser <NAME> > SELECTED_URI
-# set the characters to use for, and the width of the progress bar
-set status_pbar_done = *
-set status_pbar_pending = -
-set status_pbar_width = 12
-
-set modkey = Mod1
-# reset to command mode when new page is loaded
-set reset_command_mode = 1
-# this var has precedence over reset_command_mode
-set always_insert_mode = 0
-# to start a local socks server, do : ssh -fND localhost:8118 localhost
-#set proxy_url = http://127.0.0.1:8118
-#values 0-3
-#set http_debug = 0
-#set useragent = uzbl (Webkit WEBKIT_MAJOR.WEBKIT_MINOR.WEBKIT_MICRO)
-# Example user agent containing everything:
-set useragent = Uzbl (Webkit WEBKIT_MAJOR.WEBKIT_MINOR.WEBKIT_MICRO) (SYSNAME NODENAME KERNREL KERNVER ARCH_SYSTEM [ARCH_UZBL]) (Commit COMMIT)
-#set max_conns = 0
-#set max_conns_host = 0
-
-set fifo_dir = /tmp
-set socket_dir = /tmp
-
-# Key bindings
-bind j = scroll_vert 20
-bind k = scroll_vert -20
-bind h = scroll_horz -20
-bind l = scroll_horz 20
-bind << = scroll_begin
-bind >> = scroll_end
-bind b = back
-bind m = forward
-bind s = stop
-bind r = reload
-bind R = reload_ign_cache
-bind + = zoom_in
-bind - = zoom_out
-bind 1 = sh "echo set zoom_level = 1.0 > $4"
-bind 2 = sh "echo set zoom_level = 2.0 > $4"
-bind t = toggle_status
-# Hilight matches. Notice the * after the slash - it makes the command incremental, i.e. gets called
-# on every character you type. You can do `bind /_ = search %s' if you want it less interactive.
-bind /* = search %s
-bind ?* = search_reverse %s
-#jump to next
-bind n = search
-bind N = search_reverse
-bind gh = uri http://www.uzbl.org
-#TODO: set uri?
-bind o _ = uri %s
-bind :wiki _ = uri http://wiki.archlinux.org/index.php/Special:Search?search=%s&go=Go
-bind gg _ = uri http://www.google.com/search?q=%s
-bind i = toggle_insert_mode
-# disable insert mode (1 to enable). note that Esc works to disable, regardless of this setting
-bind I = toggle_insert_mode 0
-bind B = spawn /usr/share/uzbl/examples/scripts/insert_bookmark.sh
-bind U = spawn /usr/share/uzbl/examples/scripts/load_url_from_history.sh
-bind u = spawn /usr/share/uzbl/examples/scripts/load_url_from_bookmarks.sh
-# with the sample yank script, you can yank one of the arguments into clipboard/selection
-bind yurl = spawn /usr/share/uzbl/examples/scripts/yank.sh 6 primary
-bind ytitle = spawn /usr/share/uzbl/examples/scripts/yank.sh 7 clipboard
-# does the same as yurl but without needing a script
-bind y2url = sh "echo -n $6 | xclip"
-# go the page from primary selection
-bind p = sh "echo uri `xclip -selection primary -o` > $4"
-# go to the page in clipboard
-bind P = sh "echo uri `xclip -selection clipboard -o` > $4"
-bind ZZ = exit
-bind S = js alert("hi");
-# example showing how to use sh
-# it sends a command to the fifo, whose path is told via a positional param
-# if fifo_dir is not set, it'll echo to a file named (null) somewhere >:) remember to delete it
-# Parameters are separated by spaces and the script body must be one parameter, so enclose it in
-# quotes and escape any inner quotes using backslashes
-bind XS = sh 'echo "js alert (\'This is sent by the shell via a fifo\')" > "$4"'
-bind dump = sh "echo dump_config > $4"
-
-# we ship some javascripts to do keyboard based link hinting/following. (webkit does not have C DOM bindings yet)
-# this is similar to how it works in vimperator (and konqueror)
-# TODO: did we resolve: "no click() event for hyperlinks so no referrer set" ?
-#hit F to toggle the Hints (now in form of link numbering)
-bind F = script /usr/share/uzbl/examples/scripts/hint.js
-# the most stable version:
-bind fl* = script /usr/share/uzbl/examples/scripts/follow_Numbers.js %s
-# using strings, not polished yet:
-bind fL* = script /usr/share/uzbl/examples/scripts/follow_Numbers_Strings.js %s
-
-set icon = /usr/share/uzbl/uzbl.png
-
-# "home" page if you will
-set uri = uzbl.org
+++ /dev/null
-
-# example uzbl config. in a real config, we should obey the xdg spec
-# all settings are optional. you can use uzbl without any config at all (but it won't do much)
-
-# keyboard behavior is vimstyle by default (all commands -> 1 key). set
-# always_insert_mode to always be in insert mode and disable going out of it.
-# if you do this, make sure you've set a modkey so you can reach the commands
-# from insert mode by combining them with the modkey
-
-# TODO: ability to attach misc things (spawn <foo>, script <bar>,.. to internal events)
-# Usually you want to spawn a script to handle things, but any command (such as sh) can be used
-set history_handler = spawn ./examples/scripts/history.sh
-set download_handler = spawn ./examples/scripts/download.sh
-set cookie_handler = spawn ./examples/scripts/cookies.py
-
-set minimum_font_size = 6
-set font_size = 11
-## monospace_size defaults to font_size, but you can alter it independently
-#set monospace_size = 10
-
-## Display or supress images within html sites
-#set autoload_images = 0
-
-## Shrink images to window size
-#set autoshrink_images = 0
-
-## Spellchecker
-#set enable_spellcheck = 1
-
-## Private browsing
-#set enbale_private = 0
-
-## The URI of a stylesheet that is applied to every page
-#set stylesheet_uri = http://www.user.com/mystylelesheet.css
-
-## enable/disable JavaScript
-#set disbale_scripts = 1
-
-## Whether text areas are resizable
-#set resizeable_text_areas = 1
-
-## The default encoding used to display text
-#set default_encoding = iso-8859-1
-
-## Whether background images should be printed
-#set print_background = 0
-
-## Enforce a resolution of 96 DPI. This is meant for compatibility with
-## web pages which cope badly with different screen resolutions
-#set enforce_96_dpi = 1
-
-
-#
-# use with bind ... = sh <shell-oneliner>
-set shell_cmd = sh -c
-
-
-
-# Behaviour and appearance
-set show_status = 1
-# you can optionally use this setting to override the background color of the statusbar from your GTK theme.
-set status_background = #303030
-set status_format = <span font_family="monospace"><span background="khaki" foreground="black">[MODE]</span> [<span weight="bold" foreground="red">KEYCMD</span>] <span foreground="#606060"> LOAD_PROGRESSBAR </span><span foreground="#99FF66">URI</span> <span foreground="khaki">NAME</span> <span foreground="orange">MSG</span><span foreground="#606060">SELECTED_URI</span></span>
-set status_top = 0
-# define how your titlebar should look like. (short = statusbar is also shown, long = show everything you must see if statusbar is off)
-set title_format_short = TITLE - Uzbl browser <NAME>
-set title_format_long = KEYCMD MODE TITLE - Uzbl browser <NAME> > SELECTED_URI
-# set the characters to use for, and the width of the progress bar
-set status_pbar_done = *
-set status_pbar_pending = -
-set status_pbar_width = 12
-set insert_indicator = I
-set command_indicator = C
-set modkey = Mod1
-# reset to command mode when new page is loaded
-set reset_command_mode = 1
-# this var has precedence over reset_command_mode
-set always_insert_mode = 0
-
-# to start a local socks server, do : ssh -fND localhost:8118 localhost
-#set proxy_url = http://127.0.0.1:8118
-#values 0-3
-#set http_debug = 0
-#set useragent = uzbl (Webkit WEBKIT_MAJOR.WEBKIT_MINOR.WEBKIT_MICRO)
-# Example user agent containing everything:
-set useragent = Uzbl (Webkit WEBKIT_MAJOR.WEBKIT_MINOR.WEBKIT_MICRO) (SYSNAME NODENAME KERNREL KERNVER ARCH_SYSTEM [ARCH_UZBL]) (Commit COMMIT)
-#set max_conns = 0
-#set max_conns_host = 0
-
-set fifo_dir = /tmp
-set socket_dir = /tmp
-
-# Key bindings
-bind j = scroll_vert 20
-bind k = scroll_vert -20
-bind h = scroll_horz -20
-bind l = scroll_horz 20
-bind << = scroll_begin
-bind >> = scroll_end
-bind b = back
-bind m = forward
-bind s = stop
-bind r = reload
-bind R = reload_ign_cache
-bind + = zoom_in
-bind - = zoom_out
-bind 1 = sh "echo set zoom_level = 1.0 > $4"
-bind 2 = sh "echo set zoom_level = 2.0 > $4"
-bind t = toggle_status
-# Hilight matches. Notice the * after the slash - it makes the command incremental, i.e. gets called
-# on every character you type. You can do `bind /_ = search %s' if you want it less interactive.
-bind /* = search %s
-bind ?* = search_reverse %s
-#jump to next
-bind n = search
-bind N = search_reverse
-bind gh = uri http://www.uzbl.org
-#TODO: set uri?
-bind o _ = uri %s
-bind :wiki _ = uri http://wiki.archlinux.org/index.php/Special:Search?search=%s&go=Go
-bind gg _ = uri http://www.google.com/search?q=%s
-bind i = toggle_insert_mode
-# disable insert mode (1 to enable). note that Esc works to disable, regardless of this setting
-bind I = toggle_insert_mode 0
-# Enclose the executable in quotes if it has spaces. Any additional parameters you use will
-# appear AFTER the default parameters
-bind B = spawn ./examples/scripts/insert_bookmark.sh
-bind U = spawn ./examples/scripts/load_url_from_history.sh
-bind u = spawn ./examples/scripts/load_url_from_bookmarks.sh
-# with the sample yank script, you can yank one of the arguments into clipboard/selection
-bind yurl = spawn ./examples/scripts/yank.sh 6 primary
-bind ytitle = spawn ./examples/scripts/yank.sh 7 clipboard
-# does the same as yurl but without needing a script
-bind y2url = sh 'echo -n $6 | xclip'
-# go the page from primary selection
-bind p = sh "echo uri `xclip -selection primary -o` > $4"
-# go to the page in clipboard
-bind P = sh "echo uri `xclip -selection clipboard -o` > $4"
-bind ZZ = exit
-bind S = js alert("hi");
-# example showing how to use sh
-# it sends a command to the fifo, whose path is told via a positional param
-# if fifo_dir is not set, it'll echo to a file named (null) somewhere >:) remember to delete it
-# The body of the shell command should be one parameter, so if it has spaces like here,
-# you must enclose it in quotes. Remember to escape (and double-escape) quotes and backslashes
-# in the body. Any additional parameters you use will appear AFTER the default parameters (cfg file
-# path, fifo & socket dirs, etc.)
-bind XS = sh 'echo "js alert (\\"This is sent by the shell via a fifo\\")" > "$4"'
-bind dump = sh "echo dump_config > $4"
-# this script allows you to configure (per domain) values to fill in form fields (eg login information) and to fill in these values automatically
-bind za = spawn ./examples/scripts/formfiller.sh
-bind ze = spawn ./examples/scripts/formfiller.sh edit
-bind zn = spawn ./examples/scripts/formfiller.sh new
-bind zl = spawn ./examples/scripts/formfiller.sh load
-
-# other - more advanced - implementation using perl: (could not get this to run - Dieter )
-bind LL = spawn ./examples/scripts/formfiller.pl load
-bind LN = spawn ./examples/scripts/formfiller.pl new
-bind LE = spawn ./examples/scripts/formfiller.pl edit
-
-# we ship some javascripts to do keyboard based link hinting/following. (webkit does not have C DOM bindings yet)
-# this is similar to how it works in vimperator (and konqueror)
-# TODO: did we resolve: "no click() event for hyperlinks so no referrer set" ?
-#hit F to toggle the Hints (now in form of link numbering)
-bind F = script ./examples/scripts/hint.js
-# the most stable version:
-bind fl* = script ./examples/scripts/follow_Numbers.js %s
-# using strings, not polished yet:
-bind fL* = script ./examples/scripts/follow_Numbers_Strings.js %s
-
-# you can use this to disable all plugins
-set disable_plugins = 0
-
-set icon = ./uzbl.png
-
-# "home" page if you will
-set uri = uzbl.org
+++ /dev/null
-http://www.archlinux.org linux arch
-http://www.uzbl.org uzbl browser
-http://dieter.plaetinck.be uzbl
-http://www.icanhascheezburger.com lolcats fun
+++ /dev/null
-form_sent:
-redirect_url:
-req_username: <your username>
-req_password: <password>
-login:
+++ /dev/null
-.uzbl_highlight { background-color: yellow;}
-.uzbl_h_first { background-color: lightgreen;}
-
-.uzbl_follow { border-style: dotted;
- border-width: thin;
-}
-
-#uzbl_hint > div {
- display: inline;
- border: 2px solid #4a6600;
- background-color: #b9ff00;
- color: black;
- font-size: 9px;
- font-weight: bold;
- line-height: 9px;
- margin: 0px;
- padding: 0px;
- position: absolute;
- z-index: 1000;
- -webkit-border-radius: 6px;
- text-decoration: none;
- -wekit-transform: scale(1) rotate(0deg) translate(-6px,-5px);
-}
-
-/* vim:set et ts=4: */
-
--- /dev/null
+http://www.archlinux.org linux arch
+http://www.uzbl.org uzbl browser
+http://dieter.plaetinck.be uzbl
+http://www.icanhascheezburger.com lolcats fun
--- /dev/null
+form_sent:
+redirect_url:
+req_username: <your username>
+req_password: <password>
+login:
--- /dev/null
+#!/bin/bash
+
+# with this script you can store the current url in the clipboard, or go to the url which is stored in the clipboard.
+
+fifo="$5"
+action="$1"
+url="$7"
+selection=$(xclip -o)
+
+case $action in
+ "yank" ) echo -n "$url" | xclip;;
+ "goto" ) echo "uri $selection" > "$fifo";;
+ * ) echo "clipboard.sh: invalid action";;
+esac
+
--- /dev/null
+#!/usr/bin/env python
+
+import cookielib, sys, os, urllib2
+
+class FakeRequest:
+ def __init__(self, argv):
+ self.argv = argv
+ self.cookies = None
+ if len(self.argv) == 12:
+ self.cookies = self.argv[11]
+ def get_full_url(self):
+ #TODO: this is a hack, fix in uzbl.c!
+ u = self.get_host()+self.argv[10]
+ if self.argv[6].startswith('https'):
+ u = 'https://'+u
+ else:
+ u = 'http://'+u
+ return u
+ def get_host(self):
+ return self.argv[9]
+ def get_type(self):
+ return self.get_full_url().split(':')[0]
+ def is_unverifiable(self):
+ return False
+ def get_origin_req_host(self):
+ return self.argv[9]
+ def has_header(self, header):
+ if header == 'Cookie':
+ return self.cookies!=None
+ def get_header(self, header_name, default=None):
+ if header_name == 'Cookie' and self.cookies:
+ return self.cookies
+ else:
+ return default
+ def header_items(self):
+ if self.cookies:
+ return [('Cookie',self.cookies)]
+ else:
+ return []
+ def add_unredirected_header(self, key, header):
+ if key == 'Cookie':
+ self.cookies = header
+
+class FakeHeaders:
+ def __init__(self, argv):
+ self.argv = argv
+ def getallmatchingheaders(self, header):
+ if header == 'Set-Cookie' and len(self.argv) == 12:
+ return ['Set-Cookie: '+self.argv[11]]
+ else:
+ return []
+ def getheaders(self, header):
+ if header == 'Set-Cookie' and len(self.argv) == 12:
+ return [self.argv[11]]
+ else:
+ return []
+class FakeResponse:
+ def __init__(self, argv):
+ self.argv = argv
+ def info(self):
+ return FakeHeaders(self.argv)
+
+if __name__ == '__main__':
+ jar = cookielib.MozillaCookieJar(os.environ['XDG_DATA_HOME']+'/uzbl/cookies.txt')
+ try:
+ jar.load()
+ except:
+ pass
+
+ req = FakeRequest(sys.argv)
+
+ action = sys.argv[8]
+
+ if action == 'GET':
+ jar.add_cookie_header(req)
+ if req.cookies:
+ print req.cookies
+ elif action == 'PUT':
+ res = FakeResponse(sys.argv)
+ jar.extract_cookies(res,req)
+ jar.save(ignore_discard=True) # save session cookies too
+ #jar.save() # save everything but session cookies
\ No newline at end of file
--- /dev/null
+#!/bin/bash
+
+# THIS IS EXPERIMENTAL AND COULD BE INSECURE !!!!!!
+
+# this is an example bash script of how you could manage your cookies. it is very raw and basic and not as good as cookies.py
+# we use the cookies.txt format (See http://kb.mozillazine.org/Cookies.txt)
+# This is one textfile with entries like this:
+# kb.mozillazine.org FALSE / FALSE 1146030396 wikiUserID 16993
+# domain alow-read-other-subdomains path http-required expiration name value
+# you probably want your cookies config file in your $XDG_CONFIG_HOME ( eg $HOME/.config/uzbl/cookies)
+# Note. in uzbl there is no strict definition on what a session is. it's YOUR job to clear cookies marked as end_session if you want to keep cookies only valid during a "session"
+# MAYBE TODO: allow user to edit cookie before saving. this cannot be done with zenity :(
+# TODO: different cookie paths per config (eg per group of uzbl instances)
+
+# TODO: correct implementation.
+# see http://curl.haxx.se/rfc/cookie_spec.html
+# http://en.wikipedia.org/wiki/HTTP_cookie
+
+# TODO : check expires= before sending.
+# write sample script that cleans up cookies dir based on expires attribute.
+# TODO: check uri against domain attribute. and path also.
+# implement secure attribute.
+# support blocking or not for 3rd parties
+# http://kb.mozillazine.org/Cookies.txt
+# don't always append cookies, sometimes we need to overwrite
+
+cookie_config=$XDG_CONFIG_HOME/uzbl/cookies
+[ -z "$cookie_config" ] && exit 1
+[ -d "$XDG_DATA_HOME/uzbl" ] || exit 1
+[ -d $XDG_DATA_HOME/uzbl/ ] && cookie_data=$XDG_DATA_HOME/uzbl/cookies.txt
+
+
+notifier=
+#notifier=notify-send
+#notify_wrapper () {
+# echo "$@" >> $HOME/cookielog
+#}
+#notifier=notifier_wrapper
+
+# if this variable is set, we will use it to inform you when and which cookies we store, and when/which we send.
+# it's primarily used for debugging
+notifier=
+which zenity &>/dev/null || exit 2
+
+# Example cookie:
+# test_cookie=CheckForPermission; expires=Thu, 07-May-2009 19:17:55 GMT; path=/; domain=.doubleclick.net
+
+# uri=$6
+# uri=${uri/http:\/\/} # strip 'http://' part
+# host=${uri/\/*/}
+action=$8 # GET/PUT
+host=$9
+shift
+path=$9
+shift
+cookie=$9
+
+field_domain=$host
+field_path=$path
+field_name=
+field_value=
+field_exp='end_session'
+
+function notify () {
+ [ -n "$notifier" ] && $notifier "$@"
+}
+
+
+# FOR NOW LETS KEEP IT SIMPLE AND JUST ALWAYS PUT AND ALWAYS GET
+function parse_cookie () {
+ IFS=$';'
+ first_pair=1
+ for pair in $cookie
+ do
+ if [ "$first_pair" == 1 ]
+ then
+ field_name=${pair%%=*}
+ field_value=${pair#*=}
+ first_pair=0
+ else
+ read -r pair <<< "$pair" #strip leading/trailing wite space
+ key=${pair%%=*}
+ val=${pair#*=}
+ [ "$key" == expires ] && field_exp=`date -u -d "$val" +'%s'`
+ # TODO: domain
+ [ "$key" == path ] && field_path=$val
+ fi
+ done
+ unset IFS
+}
+
+# match cookies in cookies.txt against hostname and path
+function get_cookie () {
+ path_esc=${path//\//\\/}
+ search="^[^\t]*$host\t[^\t]*\t$path_esc"
+ cookie=`awk "/$search/" $cookie_data 2>/dev/null | tail -n 1`
+ if [ -z "$cookie" ]
+ then
+ notify "Get_cookie: search: $search in $cookie_data -> no result"
+ false
+ else
+ notify "Get_cookie: search: $search in $cookie_data -> result: $cookie"
+ read domain alow_read_other_subdomains path http_required expiration name value <<< "$cookie"
+ cookie="$name=$value"
+ true
+ fi
+}
+
+function save_cookie () {
+ if parse_cookie
+ then
+ data="$field_domain\tFALSE\t$field_path\tFALSE\t$field_exp\t$field_name\t$field_value"
+ notify "save_cookie: adding $data to $cookie_data"
+ echo -e "$data" >> $cookie_data
+ else
+ notify "not saving a cookie. since we don't have policies yet, parse_cookie must have returned false. this is a bug"
+ fi
+}
+
+[ $action == PUT ] && save_cookie
+[ $action == GET ] && get_cookie && echo "$cookie"
+
+exit
+
+
+# TODO: implement this later.
+# $1 = section (TRUSTED or DENY)
+# $2 =url
+function match () {
+ sed -n "/$1/,/^\$/p" $cookie_config 2>/dev/null | grep -q "^$host"
+}
+
+function fetch_cookie () {
+ cookie=`cat $cookie_data`
+}
+
+function store_cookie () {
+ echo $cookie > $cookie_data
+}
+
+if match TRUSTED $host
+then
+ [ $action == PUT ] && store_cookie $host
+ [ $action == GET ] && fetch_cookie && echo "$cookie"
+elif ! match DENY $host
+then
+ [ $action == PUT ] && cookie=`zenity --entry --title 'Uzbl Cookie handler' --text "Accept this cookie from $host ?" --entry-text="$cookie"` && store_cookie $host
+ [ $action == GET ] && fetch_cookie && cookie=`zenity --entry --title 'Uzbl Cookie handler' --text "Submit this cookie to $host ?" --entry-text="$cookie"` && echo $cookie
+fi
+exit 0
--- /dev/null
+#!/bin/bash
+# just an example of how you could handle your downloads
+# try some pattern matching on the uri to determine what we should do
+
+# Some sites block the default wget --user-agent...
+WGET="wget --user-agent=Firefox"
+
+if [[ $8 =~ .*(.torrent) ]]
+then
+ cd $HOME
+ $WGET $8
+else
+ cd $HOME
+ $WGET $8
+fi
--- /dev/null
+/* This is the basic linkfollowing script.
+ * Its pretty stable, only using numbers to navigate.
+ *
+ * TODO: Some pages mess around a lot with the zIndex which
+ * lets some hints in the background.
+ * TODO: Some positions are not calculated correctly (mostly
+ * because of uber-fancy-designed-webpages. Basic HTML and CSS
+ * works good
+ * TODO: Still some links can't be followed/unexpected things
+ * happen. Blame some freaky webdesigners ;)
+ */
+
+//Just some shortcuts and globals
+var uzblid = 'uzbl_link_hint';
+var uzbldivid = uzblid + '_div_container';
+var doc = document;
+var win = window;
+var links = document.links;
+var forms = document.forms;
+//Make onlick-links "clickable"
+try {
+ HTMLElement.prototype.click = function() {
+ if (typeof this.onclick == 'function') {
+ this.onclick({
+ type: 'click'
+ });
+ }
+ };
+} catch(e) {}
+//Catch the ESC keypress to stop linkfollowing
+function keyPressHandler(e) {
+ var kC = window.event ? event.keyCode: e.keyCode;
+ var Esc = window.event ? 27 : e.DOM_VK_ESCAPE;
+ if (kC == Esc) {
+ removeAllHints();
+ }
+}
+//Calculate element position to draw the hint
+//Pretty accurate but on fails in some very fancy cases
+function elementPosition(el) {
+ var up = el.offsetTop;
+ var left = el.offsetLeft;
+ var width = el.offsetWidth;
+ var height = el.offsetHeight;
+ while (el.offsetParent) {
+ el = el.offsetParent;
+ up += el.offsetTop;
+ left += el.offsetLeft;
+ }
+ return [up, left, width, height];
+}
+//Calculate if an element is visible
+function isVisible(el) {
+ if (el == doc) {
+ return true;
+ }
+ if (!el) {
+ return false;
+ }
+ if (!el.parentNode) {
+ return false;
+ }
+ if (el.style) {
+ if (el.style.display == 'none') {
+ return false;
+ }
+ if (el.style.visibility == 'hidden') {
+ return false;
+ }
+ }
+ return isVisible(el.parentNode);
+}
+//Calculate if an element is on the viewport.
+function elementInViewport(el) {
+ offset = elementPosition(el);
+ var up = offset[0];
+ var left = offset[1];
+ var width = offset[2];
+ var height = offset[3];
+ return up < window.pageYOffset + window.innerHeight && left < window.pageXOffset + window.innerWidth && (up + height) > window.pageYOffset && (left + width) > window.pageXOffset;
+}
+//Removes all hints/leftovers that might be generated
+//by this script.
+function removeAllHints() {
+ var elements = doc.getElementById(uzbldivid);
+ if (elements) {
+ elements.parentNode.removeChild(elements);
+ }
+}
+//Generate a hint for an element with the given label
+//Here you can play around with the style of the hints!
+function generateHint(el, label) {
+ var pos = elementPosition(el);
+ var hint = doc.createElement('div');
+ hint.setAttribute('name', uzblid);
+ hint.innerText = label;
+ hint.style.display = 'inline';
+ hint.style.backgroundColor = '#B9FF00';
+ hint.style.border = '2px solid #4A6600';
+ hint.style.color = 'black';
+ hint.style.fontSize = '9px';
+ hint.style.fontWeight = 'bold';
+ hint.style.lineHeight = '9px';
+ hint.style.margin = '0px';
+ hint.style.padding = '1px';
+ hint.style.position = 'absolute';
+ hint.style.zIndex = '1000';
+ hint.style.left = pos[1] + 'px';
+ hint.style.top = pos[0] + 'px';
+ var img = el.getElementsByTagName('img');
+ if (img.length > 0) {
+ hint.style.left = pos[1] + img[0].width / 2 + 'px';
+ }
+ hint.style.textDecoration = 'none';
+ hint.style.webkitBorderRadius = '6px';
+ // Play around with this, pretty funny things to do :)
+ hint.style.webkitTransform = 'scale(1) rotate(0deg) translate(-6px,-5px)';
+ return hint;
+}
+//Here we choose what to do with an element if we
+//want to "follow" it. On form elements we "select"
+//or pass the focus, on links we try to perform a click,
+//but at least set the href of the link. (needs some improvements)
+function clickElem(item) {
+ removeAllHints();
+ if (item) {
+ var name = item.tagName;
+ if (name == 'A') {
+ item.click();
+ window.location = item.href;
+ } else if (name == 'INPUT') {
+ var type = item.getAttribute('type').toUpperCase();
+ if (type == 'TEXT' || type == 'FILE' || type == 'PASSWORD') {
+ item.focus();
+ item.select();
+ } else {
+ item.click();
+ }
+ } else if (name == 'TEXTAREA' || name == 'SELECT') {
+ item.focus();
+ item.select();
+ } else {
+ item.click();
+ window.location = item.href;
+ }
+ }
+}
+//Returns a list of all links (in this version
+//just the elements itself, but in other versions, we
+//add the label here.
+function addLinks() {
+ res = [[], []];
+ for (var l = 0; l < links.length; l++) {
+ var li = links[l];
+ if (isVisible(li) && elementInViewport(li)) {
+ res[0].push(li);
+ }
+ }
+ return res;
+}
+//Same as above, just for the form elements
+function addFormElems() {
+ res = [[], []];
+ for (var f = 0; f < forms.length; f++) {
+ for (var e = 0; e < forms[f].elements.length; e++) {
+ var el = forms[f].elements[e];
+ if (el && ['INPUT', 'TEXTAREA', 'SELECT'].indexOf(el.tagName) + 1 && isVisible(el) && elementInViewport(el)) {
+ res[0].push(el);
+ }
+ }
+ }
+ return res;
+}
+//Draw all hints for all elements passed. "len" is for
+//the number of chars we should use to avoid collisions
+function reDrawHints(elems, chars) {
+ removeAllHints();
+ var hintdiv = doc.createElement('div');
+ hintdiv.setAttribute('id', uzbldivid);
+ for (var i = 0; i < elems[0].length; i++) {
+ if (elems[0][i]) {
+ var label = elems[1][i].substring(chars);
+ var h = generateHint(elems[0][i], label);
+ hintdiv.appendChild(h);
+ }
+ }
+ if (document.body) {
+ document.body.appendChild(hintdiv);
+ }
+}
+//Put it all together
+function followLinks(follow) {
+ var s = follow.split('');
+ var linknr = parseInt(follow, 10);
+ if (document.body) document.body.setAttribute('onkeyup', 'keyPressHandler(event)');
+ var linkelems = addLinks();
+ var formelems = addFormElems();
+ var elems = [linkelems[0].concat(formelems[0]), linkelems[1].concat(formelems[1])];
+ var len = (elems[0].length + '').length;
+ var oldDiv = doc.getElementById(uzbldivid);
+ var leftover = [[], []];
+ if (linknr + 1 && s.length == len && linknr < elems[0].length && linknr >= 0) {
+ clickElem(elems[0][linknr]);
+ } else {
+ for (var j = 0; j < elems[0].length; j++) {
+ var b = true;
+ var label = j + '';
+ var n = label.length;
+ for (n; n < len; n++) {
+ label = '0' + label;
+ }
+ for (var k = 0; k < s.length; k++) {
+ b = b && label.charAt(k) == s[k];
+ }
+ if (b) {
+ leftover[0].push(elems[0][j]);
+ leftover[1].push(label);
+ }
+ }
+ reDrawHints(leftover, s.length);
+ }
+}
+followLinks('%s');
--- /dev/null
+var uzblid = 'uzbl_link_hint';
+var uzbldivid = uzblid + '_div_container';
+var doc = document;
+var win = window;
+var links = document.links;
+var forms = document.forms;
+try {
+ HTMLElement.prototype.click = function() {
+ if (typeof this.onclick == 'function') {
+ this.onclick({
+ type: 'click'
+ });
+ }
+ };
+} catch(e) {}
+function keyPressHandler(e) {
+ var kC = window.event ? event.keyCode: e.keyCode;
+ var Esc = window.event ? 27 : e.DOM_VK_ESCAPE;
+ if (kC == Esc) {
+ removeAllHints();
+ }
+}
+function elementPosition(el) {
+ var up = el.offsetTop;
+ var left = el.offsetLeft;
+ var width = el.offsetWidth;
+ var height = el.offsetHeight;
+ while (el.offsetParent) {
+ el = el.offsetParent;
+ up += el.offsetTop;
+ left += el.offsetLeft;
+ }
+ return [up, left, width, height];
+}
+function isVisible(el) {
+ if (el == doc) {
+ return true;
+ }
+ if (!el) {
+ return false;
+ }
+ if (!el.parentNode) {
+ return false;
+ }
+ if (el.style) {
+ if (el.style.display == 'none') {
+ return false;
+ }
+ if (el.style.visibility == 'hidden') {
+ return false;
+ }
+ }
+ return isVisible(el.parentNode);
+}
+function elementInViewport(el) {
+ offset = elementPosition(el);
+ var up = offset[0];
+ var left = offset[1];
+ var width = offset[2];
+ var height = offset[3];
+ return up < window.pageYOffset + window.innerHeight && left < window.pageXOffset + window.innerWidth && (up + height) > window.pageYOffset && (left + width) > window.pageXOffset;
+}
+function removeAllHints() {
+ var elements = doc.getElementById(uzbldivid);
+ if (elements) {
+ elements.parentNode.removeChild(elements);
+ }
+}
+function generateHint(el, label) {
+ var pos = elementPosition(el);
+ var hint = doc.createElement('div');
+ hint.setAttribute('name', uzblid);
+ hint.innerText = label;
+ hint.style.display = 'inline';
+ hint.style.backgroundColor = '#B9FF00';
+ hint.style.border = '2px solid #4A6600';
+ hint.style.color = 'black';
+ hint.style.zIndex = '1000';
+ hint.style.fontSize = '9px';
+ hint.style.fontWeight = 'bold';
+ hint.style.lineHeight = '9px';
+ hint.style.margin = '0px';
+ hint.style.padding = '1px';
+ hint.style.position = 'absolute';
+ hint.style.left = pos[1] + 'px';
+ hint.style.top = pos[0] + 'px';
+ var img = el.getElementsByTagName('img');
+ if (img.length > 0) {
+ hint.style.left = pos[1] + img[0].width / 2 + 'px';
+ }
+ hint.style.textDecoration = 'none';
+ hint.style.webkitBorderRadius = '6px';
+ hint.style.webkitTransform = 'scale(1) rotate(0deg) translate(-6px,-5px)';
+ return hint;
+}
+function clickElem(item) {
+ removeAllHints();
+ if (item) {
+ var name = item.tagName;
+ if (name == 'A') {
+ item.click();
+ window.location = item.href;
+ } else if (name == 'INPUT') {
+ var type = item.getAttribute('type').toUpperCase();
+ if (type == 'TEXT' || type == 'FILE' || type == 'PASSWORD') {
+ item.focus();
+ item.select();
+ } else {
+ item.click();
+ }
+ } else if (name == 'TEXTAREA' || name == 'SELECT') {
+ item.focus();
+ item.select();
+ } else {
+ item.click();
+ window.location = item.href;
+ }
+ }
+}
+function addLinks() {
+ res = [[], []];
+ for (var l = 0; l < links.length; l++) {
+ var li = links[l];
+ if (isVisible(li) && elementInViewport(li)) {
+ res[0].push(li);
+ res[1].push(li.innerText.toLowerCase());
+ }
+ }
+ return res;
+}
+function addFormElems() {
+ res = [[], []];
+ for (var f = 0; f < forms.length; f++) {
+ for (var e = 0; e < forms[f].elements.length; e++) {
+ var el = forms[f].elements[e];
+ if (el && ['INPUT', 'TEXTAREA', 'SELECT'].indexOf(el.tagName) + 1 && isVisible(el) && elementInViewport(el)) {
+ res[0].push(el);
+ if (el.getAttribute('value')) {
+ res[1].push(el.getAttribute('value').toLowerCase());
+ } else {
+ res[1].push(el.getAttribute('name').toLowerCase());
+ }
+ }
+ }
+ }
+ return res;
+}
+function reDrawHints(elems, len) {
+ var hintdiv = doc.createElement('div');
+ hintdiv.setAttribute('id', uzbldivid);
+ hintdiv.style.opacity = '0.0';
+ for (var i = 0; i < elems[0].length; i++) {
+ var label = i + '';
+ var n = label.length;
+ for (n; n < len; n++) {
+ label = '0' + label;
+ }
+ if (elems[0][i]) {
+ var h = generateHint(elems[0][i], label);
+ hintdiv.appendChild(h);
+ }
+ }
+ if (document.body) {
+ document.body.appendChild(hintdiv);
+ hintdiv.style.opacity = '0.7'
+ }
+}
+function followLinks(follow) {
+ var s = follow.split('');
+ var linknr = parseInt(follow, 10);
+ if (document.body) document.body.setAttribute('onkeyup', 'keyPressHandler(event)');
+ var linkelems = addLinks();
+ var formelems = addFormElems();
+ var elems = [linkelems[0].concat(formelems[0]), linkelems[1].concat(formelems[1])];
+ var len = (elems[0].length + '').length;
+ var oldDiv = doc.getElementById(uzbldivid);
+ var leftover = [[], []];
+ if (linknr + 1 && s.length == len && linknr < elems[0].length && linknr >= 0) {
+ clickElem(elems[0][linknr]);
+ } else {
+ for (var j = 0; j < elems[0].length; j++) {
+ var b = true;
+ for (var k = 0; k < s.length; k++) {
+ b = b && elems[1][j].charAt(k) == s[k];
+ }
+ if (!b) {
+ elems[0][j] = null;
+ elems[1][j] = null;
+ } else {
+ leftover[0].push(elems[0][j]);
+ leftover[1].push(elems[1][j]);
+ }
+ }
+ if (leftover[0].length == 1) {
+ clickElem(leftover[0][0]);
+ } else if (!oldDiv) {
+ if (linknr + 1 || s.length == 0) {
+ reDrawHints(elems, len);
+ } else {
+ reDrawHints(leftover, len);
+ }
+ }
+ }
+}
+followLinks('%s');
--- /dev/null
+#!/usr/bin/perl
+
+# a slightly more advanced form filler
+#
+# uses settings file like: $keydir/<domain>
+
+# user arg 1:
+# edit: force editing of the file (fetches if file is missing)
+# load: fill forms from file (fetches if file is missing)
+# new: fetch new file
+
+# usage example:
+# bind LL = spawn /usr/share/uzbl/examples/scripts/formfiller.pl load
+# bind LN = spawn /usr/share/uzbl/examples/scripts/formfiller.pl new
+# bind LE = spawn /usr/share/uzbl/examples/scripts/formfiller.pl edit
+
+use strict;
+use warnings;
+
+my $keydir = $ENV{XDG_CONFIG_HOME} . "/uzbl/forms";
+my ($config,$pid,$xid,$fifoname,$socket,$url,$title,$cmd) = @ARGV;
+if (!defined $fifoname || $fifoname eq "") { die "No fifo"; }
+
+sub domain {
+ my ($url) = @_;
+ $url =~ s#http(s)?://([A-Za-z0-9\.-]+)(/.*)?#$2#;
+ return $url;
+};
+
+my $editor = "xterm -e vim";
+#my $editor = "gvim";
+
+# ideally, there would be some way to ask uzbl for the html content instead of having to redownload it with
+# Also, you may need to fake the user-agent on some sites (like facebook)
+ my $downloader = "curl -A 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.10) Gecko/2009042810 GranParadiso/3.0.10' ";
+#my $downloader = "curl -s";
+
+my @fields = ("type","name","value");
+
+my %command;
+
+$command{load} = sub {
+ my ($domain) = @_;
+ my $filename = "$keydir/$domain";
+ if (-e $filename){
+ open(my $file, $filename) or die "Failed to open $filename: $!";
+ my (@lines) = <$file>;
+ close($file);
+ $|++;
+ open(my $fifo, ">>", $fifoname) or die "Failed to open $fifoname: $!";
+ foreach my $line (@lines) {
+ next if ($line =~ m/^#/);
+ my ($type,$name,$value) = ($line =~ /^\s*(\w+)\s*\|\s*(.*?)\s*\|\s*(.*?)\s*$/);
+ if ($type eq "checkbox")
+ {
+ printf $fifo 'js document.getElementsByName("%s")[0].checked = %s;', $name, $value;
+ } elsif ($type eq "submit")
+ {
+ printf $fifo 'js function fs (n) {try{n.submit()} catch (e){fs(n.parentNode)}}; fs(document.getElementsByName("%s")[0]);', $name;
+ } elsif ($type ne "")
+ {
+ printf $fifo 'js document.getElementsByName("%s")[0].value = "%s";', $name, $value;
+ }
+ print $fifo "\n";
+ }
+ $|--;
+ } else {
+ $command{new}->($domain);
+ $command{edit}->($domain);
+ }
+};
+$command{edit} = sub {
+ my ($domain) = @_;
+ my $file = "$keydir/$domain";
+ if(-e $file){
+ system ($editor, $file);
+ } else {
+ $command{new}->($domain);
+ }
+};
+$command{new} = sub {
+ my ($domain) = @_;
+ my $filename = "$keydir/$domain";
+ open (my $file,">>", $filename) or die "Failed to open $filename: $!";
+ $|++;
+ print $file "# Make sure that there are no extra submits, since it may trigger the wrong one.\n";
+ printf $file "#%-10s | %-10s | %s\n", @fields;
+ print $file "#------------------------------\n";
+ my @data = `$downloader $url`;
+ foreach my $line (@data){
+ if($line =~ m/<input ([^>].*?)>/i){
+ $line =~ s/.*(<input ([^>].*?)>).*/$1/;
+ printf $file " %-10s | %-10s | %s\n", map { my ($r) = $line =~ /.*$_=["'](.*?)["']/;$r } @fields;
+ };
+ };
+ $|--;
+};
+
+$command{$cmd}->(domain($url));
--- /dev/null
+#!/bin/bash
+
+# simple html form (eg for logins) filler (and manager) for uzbl.
+# uses settings files like: $keydir/<domain>
+# files contain lines like: <fieldname>: <value>
+
+
+# user arg 1:
+# edit: force editing the file (falls back to new if not found)
+# new: start with a new file.
+# load: try to load from file into form
+
+# something else (or empty): if file not available: new, otherwise load.
+
+keydir=$XDG_DATA_HOME/uzbl/forms
+[ -z "$keydir" ] && exit 1
+
+#editor=gvim
+editor='urxvt -e vim'
+
+config=$1; shift
+pid=$1; shift
+xid=$1; shift
+fifo=$1; shift
+socket=$1; shift
+url=$1; shift
+title=$1; shift
+action=$1
+
+[ -d $keydir ] || mkdir $keydir || exit 1
+
+if [ "$action" != 'edit' -a "$action" != 'new' -a "$action" != 'load' ]
+then
+ action=new
+ [[ -e $keydir/$domain ]] && action=load
+elif [ "$action" == 'edit' ] && [[ ! -e $keydir/$domain ]]
+then
+ action=new
+fi
+domain=$(echo $url | sed -re 's|(http\|https)+://([A-Za-z0-9\.]+)/.*|\2|')
+
+
+#regex='s|.*<input.*?name="([[:graph:]]+)".*?/>.*|\1: |p' # sscj's first version, does not work on http://wiki.archlinux.org/index.php?title=Special:UserLogin&returnto=Main_Page
+ regex='s|.*<input.*?name="([^"]*)".*|\1: |p' #works on arch wiki, but not on http://lists.uzbl.org/listinfo.cgi/uzbl-dev-uzbl.org TODO: improve
+
+
+if [ "$action" = 'load' ]
+then
+ [[ -e $keydir/$domain ]] || exit 2
+ gawk -F': ' '{ print "js document.getElementsByName(\"" $1 "\")[0].value = \"" $2 "\";"}' $keydir/$domain >> $fifo
+else
+ if [ "$action" == 'new' ]
+ then
+ curl "$url" | grep '<input' | sed -nre "$regex" > $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
--- /dev/null
+for (var i=0; i < document.links.length; i++) {
+ var uzblid = 'uzbl_link_hint_';
+ var li = document.links[i];
+ var pre = document.getElementById(uzblid+i);
+
+ if (pre) {
+ li.removeChild(pre);
+ } else {
+ var hint = document.createElement('div');
+ hint.setAttribute('id',uzblid+i);
+ hint.innerHTML = i;
+ hint.style.display='inline';
+ hint.style.lineHeight='90%';
+ hint.style.backgroundColor='red';
+ hint.style.color='white';
+ hint.style.fontSize='small-xx';
+ hint.style.fontWeight='light';
+ hint.style.margin='0px';
+ hint.style.padding='2px';
+ hint.style.position='absolute';
+ hint.style.textDecoration='none';
+ hint.style.left=li.style.left;
+ hint.style.top=li.style.top;
+ li.insertAdjacentElement('afterBegin',hint);
+ }
+}
--- /dev/null
+#!/bin/bash
+#TODO: strip 'http://' part
+echo "$8 $6 $7" >> $XDG_DATA_HOME/uzbl/history
--- /dev/null
+#!/bin/bash
+# you probably want your bookmarks file in your $XDG_DATA_HOME ( eg $HOME/.local/share/uzbl/bookmarks)
+
+[ -d "$XDG_DATA_HOME/uzbl" ] || exit 1
+file=$XDG_DATA_HOME/uzbl/bookmarks
+
+which zenity &>/dev/null || exit 2
+
+entry=`zenity --entry --text="Add bookmark. add tags after the '\t', separated by spaces" --entry-text="$6 $7\t"`
+url=`awk '{print $1}' <<< $entry`
+# TODO: check if already exists, if so, and tags are different: ask if you want to replace tags
+echo "$entry" >/dev/null #for some reason we need this.. don't ask me why
+echo -e "$entry" >> $file
+true
--- /dev/null
+// link follower for uzbl
+// requires http://github.com/DuClare/uzbl/commit/6c11777067bdb8aac09bba78d54caea04f85e059
+//
+// first, it needs to be loaded before every time it is used.
+// One way would be to use the load_commit_handler:
+// set load_commit_handler = sh 'echo "script /usr/share/uzbl/examples/scripts/linkfollow.js" > "$4"'
+//
+// when script is loaded, it can be invoked with
+// bind f* = js hints.set("%s", hints.open)
+// bind f_ = js hints.follow("%s",hints.open)
+//
+// At the moment, it may be useful to have way of forcing uzbl to load the script
+// bind :lf = script /usr/share/uzbl/examples/scripts/linkfollow.js
+//
+// The default style for the hints are pretty ugly, so it is recommended to add the following
+// to config file
+// set stylesheet_uri = /usr/share/uzbl/examples/data/style.css
+//
+// based on follow_Numbers.js
+//
+// TODO: fix styling for the first element
+// TODO: emulate mouseover events when visiting some elements
+// TODO: rewrite the element->action handling
+
+
+function Hints(){
+
+ // Settings
+ ////////////////////////////////////////////////////////////////////////////
+
+ // if set to true, you must explicitly call hints.follow(), otherwise it will
+ // follow the link if there is only one matching result
+ var requireReturn = true;
+
+ // Case sensitivity flag
+ var matchCase = "i";
+
+ // For case sensitive matching, uncomment:
+ // var matchCase = "";
+
+
+ var uzblid = 'uzbl_hint';
+ var uzblclass = 'uzbl_highlight';
+ var uzblclassfirst = 'uzbl_h_first';
+ var doc = document;
+ var visible = [];
+ var hintdiv;
+
+ this.set = hint;
+ this.follow = follow;
+ this.keyPressHandler = keyPressHandler;
+
+ function elementPosition(el) {
+ var up = el.offsetTop;
+ var left = el.offsetLeft; var width = el.offsetWidth;
+ var height = el.offsetHeight;
+
+ while (el.offsetParent) {
+ el = el.offsetParent;
+ up += el.offsetTop;
+ left += el.offsetLeft;
+ }
+ return {up: up, left: left, width: width, height: height};
+ }
+
+ function elementInViewport(p) {
+ return (p.up < window.pageYOffset + window.innerHeight &&
+ p.left < window.pageXOffset + window.innerWidth &&
+ (p.up + p.height) > window.pageYOffset &&
+ (p.left + p.width) > window.pageXOffset);
+ }
+
+ function isVisible(el) {
+ if (el == doc) { return true; }
+ if (!el) { return false; }
+ if (!el.parentNode) { return false; }
+ if (el.style) {
+ if (el.style.display == 'none') {
+ return false;
+ }
+ if (el.style.visibility == 'hidden') {
+ return false;
+ }
+ }
+ return isVisible(el.parentNode);
+ }
+
+ // the vimperator defaults minus the xhtml elements, since it gave DOM errors
+ var hintable = " //*[@onclick or @onmouseover or @onmousedown or @onmouseup or @oncommand or @class='lk' or @role='link' or @href] | //input[not(@type='hidden')] | //a | //area | //iframe | //textarea | //button | //select";
+
+ function Matcher(str){
+ var numbers = str.replace(/[^\d]/g,"");
+ var words = str.replace(/\d/g,"").split(/\s+/).map(function (n) { return new RegExp(n,matchCase)});
+ this.test = test;
+ this.toString = toString;
+ this.numbers = numbers;
+ function matchAgainst(element){
+ if(element.node.nodeName == "INPUT"){
+ return element.node.value;
+ } else {
+ return element.node.textContent;
+ }
+ }
+ function test(element) {
+ // test all the regexp
+ var item = matchAgainst(element);
+ return words.every(function (regex) { return item.match(regex)});
+ }
+ }
+
+ function HintElement(node,pos){
+
+ this.node = node;
+ this.isHinted = false;
+ this.position = pos;
+ this.num = 0;
+
+ this.addHint = function (labelNum) {
+ // TODO: fix uzblclassfirst
+ if(!this.isHinted){
+ this.node.className += " " + uzblclass;
+ }
+ this.isHinted = true;
+
+ // create hint
+ var hintNode = doc.createElement('div');
+ hintNode.name = uzblid;
+ hintNode.innerText = labelNum;
+ hintNode.style.left = this.position.left + 'px';
+ hintNode.style.top = this.position.up + 'px';
+ hintNode.style.position = "absolute";
+ doc.body.firstChild.appendChild(hintNode);
+
+ }
+ this.removeHint = function(){
+ if(this.isHinted){
+ var s = (this.num)?uzblclassfirst:uzblclass;
+ this.node.className = this.node.className.replace(new RegExp(" "+s,"g"),"");
+ this.isHinted = false;
+ }
+ }
+ }
+
+ function createHintDiv(){
+ var hintdiv = doc.getElementById(uzblid);
+ if(hintdiv){
+ hintdiv.parentNode.removeChild(hintdiv);
+ }
+ hintdiv = doc.createElement("div");
+ hintdiv.setAttribute('id',uzblid);
+ doc.body.insertBefore(hintdiv,doc.body.firstChild);
+ return hintdiv;
+ }
+
+ function init(){
+ // WHAT?
+ doc.body.setAttribute("onkeyup","hints.keyPressHandler(event)");
+ hintdiv = createHintDiv();
+ visible = [];
+
+ var items = doc.evaluate(hintable,doc,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);
+ for (var i = 0;i<items.snapshotLength;i++){
+ var item = items.snapshotItem(i);
+ var pos = elementPosition(item);
+ if(isVisible && elementInViewport(elementPosition(item))){
+ visible.push(new HintElement(item,pos));
+ }
+ }
+ }
+
+ function clear(){
+
+ visible.forEach(function (n) { n.removeHint(); } );
+ hintdiv = doc.getElementById(uzblid);
+ while(hintdiv){
+ hintdiv.parentNode.removeChild(hintdiv);
+ hintdiv = doc.getElementById(uzblid);
+ }
+ }
+
+ function update(str,openFun) {
+ var match = new Matcher(str);
+ hintdiv = createHintDiv();
+ var i = 1;
+ visible.forEach(function (n) {
+ if(match.test(n)) {
+ n.addHint(i);
+ i++;
+ } else {
+ n.removeHint();
+ }});
+ if(!requireReturn){
+ if(i==2){ //only been incremented once
+ follow(str,openFun);
+ }
+ }
+ }
+
+ function hint(str,openFun){
+ if(str.length == 0) init();
+ update(str,openFun);
+ }
+
+ function keyPressHandler(e) {
+ var kC = window.event ? event.keyCode: e.keyCode;
+ var Esc = window.event ? 27 : e.DOM_VK_ESCAPE;
+ if (kC == Esc) {
+ clear();
+ doc.body.removeAttribute("onkeyup");
+ }
+ }
+
+ this.openNewWindow = function(item){
+ // TODO: this doesn't work yet
+ item.className += " uzbl_follow";
+ window.open(item.href,"uzblnew","");
+ }
+ this.open = function(item){
+ simulateMouseOver(item);
+ item.className += " uzbl_follow";
+ window.location = item.href;
+ }
+
+ function simulateMouseOver(item){
+ var evt = doc.createEvent("MouseEvents");
+ evt.initMouseEvent("MouseOver",true,true,
+ doc.defaultView,1,0,0,0,0,
+ false,false,false,false,0,null);
+ return item.dispatchEvent(evt);
+ }
+
+
+ function follow(str,openFunction){
+ var m = new Matcher(str);
+ var items = visible.filter(function (n) { return n.isHinted });
+ clear();
+ var num = parseInt(m.numbers,10);
+ if(num){
+ var item = items[num-1].node;
+ } else {
+ var item = items[0].node;
+ }
+ if (item) {
+ var name = item.tagName;
+ if (name == 'A') {
+ if(item.click) {item.click()};
+ openFunction(item);
+ } else if (name == 'INPUT') {
+ var type = item.getAttribute('type').toUpperCase();
+ if (type == 'TEXT' || type == 'FILE' || type == 'PASSWORD') {
+ item.focus();
+ item.select();
+ } else {
+ item.click();
+ }
+ } else if (name == 'TEXTAREA' || name == 'SELECT') {
+ item.focus();
+ item.select();
+ } else {
+ item.click();
+ openFunction(item);
+ }
+ }
+ }
+}
+
+var hints = new Hints();
+
+// vim:set et sw=2:
+
+
--- /dev/null
+#!/bin/bash
+
+#NOTE: it's the job of the script that inserts bookmarks to make sure there are no dupes.
+
+file=$XDG_DATA_HOME/uzbl/bookmarks
+[ -z "$file" ] && exit
+COLORS=" -nb #303030 -nf khaki -sb #CCFFAA -sf #303030"
+if dmenu --help 2>&1 | grep -q '\[-rs\] \[-ni\] \[-nl\] \[-xs\]'
+then
+ DMENU="dmenu -i -xs -rs -l 10" # vertical patch
+ # show tags as well
+ goto=`$DMENU $COLORS < $file | awk '{print $1}'`
+else
+ DMENU="dmenu -i"
+ # because they are all after each other, just show the url, not their tags.
+ goto=`awk '{print $1}' $file | $DMENU $COLORS`
+fi
+
+#[ -n "$goto" ] && echo "uri $goto" > $4
+[ -n "$goto" ] && uzblctrl -s $5 -c "uri $goto"
--- /dev/null
+#!/bin/bash
+history_file=$XDG_DATA_HOME/uzbl/history
+
+# choose from all entries, sorted and uniqued
+# goto=`awk '{print $3}' $history_file | sort -u | dmenu -i`
+COLORS=" -nb #303030 -nf khaki -sb #CCFFAA -sf #303030"
+if dmenu --help 2>&1 | grep -q '\[-rs\] \[-ni\] \[-nl\] \[-xs\]'
+then
+ DMENU="dmenu -i -xs -rs -l 10" # vertical patch
+ # choose an item in reverse order, showing also the date and page titles
+ # pick the last field from the first 3 fields. this way you can pick a url (prefixed with date & time) or type just a new url.
+ goto=`tac $history_file | $DMENU $COLORS | cut -d ' ' -f -3 | awk '{print $NF}'`
+else
+ DMENU="dmenu -i"
+ # choose from all entries (no date or title), the first one being current url, and after that all others, sorted and uniqued, in ascending order
+ current=`tail -n 1 $history_file | awk '{print $3}'`; goto=`(echo $current; awk '{print $3}' $history_file | grep -v "^$current\$" | sort -u) | $DMENU $COLORS`
+fi
+
+[ -n "$goto" ] && echo "uri $goto" > $4
+#[ -n "$goto" ] && uzblctrl -s $5 -c "uri $goto"
--- /dev/null
+#!/bin/bash
+
+# Very simple session manager for uzbl. When called with "endsession" as the
+# argument, it'll backup $sessionfile, look for fifos in $fifodir and
+# instruct each of them to store their current url in $sessionfile and
+# terminate themselves. Run with "launch" as the argument and an instance of
+# uzbl will be launched for each stored url. "endinstance" is used internally
+# and doesn't need to be called manually at any point.
+# Add a line like 'bind quit = /path/to/session.sh endsession' to your config
+
+scriptfile=$0 # this script
+sessionfile=$XDG_DATA_HOME/uzbl/session # the file in which the "session" (i.e. urls) are stored
+configfile=$XDG_DATA_HOME/uzbl/config # uzbl configuration file
+UZBL="uzbl -c $configfile" # add custom flags and whatever here.
+
+fifodir=/tmp # remember to change this if you instructed uzbl to put its fifos elsewhere
+thisfifo="$4"
+act="$8"
+url="$6"
+
+if [ "$act." = "." ]; then
+ act="$1"
+fi
+
+
+case $act in
+ "launch" )
+ urls=$(cat $sessionfile)
+ if [ "$urls." = "." ]; then
+ $UZBL
+ else
+ for url in $urls; do
+ $UZBL --uri "$url" &
+ done
+ fi
+ exit 0
+ ;;
+
+ "endinstance" )
+ if [ "$url" != "(null)" ]; then
+ echo "$url" >> $sessionfile;
+ fi
+ echo "exit" > "$thisfifo"
+ ;;
+
+ "endsession" )
+ mv "$sessionfile" "$sessionfile~"
+ for fifo in $fifodir/uzbl_fifo_*; do
+ if [ "$fifo" != "$thisfifo" ]; then
+ echo "spawn $scriptfile endinstance" > "$fifo"
+ fi
+ done
+ echo "spawn $scriptfile endinstance" > "$thisfifo"
+ ;;
+
+ * ) echo "session manager: bad action"
+ echo "Usage: $scriptfile [COMMAND] where commands are:"
+ echo " launch - Restore a saved session or start a new one"
+ echo " endsession - Quit the running session. Must be called from uzbl"
+ ;;
+esac
+
--- /dev/null
+#!/usr/bin/env perl
+# uzblcat - safely push html to uzbl
+# See http://www.uzbl.org/wiki/html-mode
+use strict; use warnings;
+
+my $html;
+local $/; # slurp files
+# automagically choose to read from stdin/files/...
+$html .= $_ for <>;
+
+my $endmarker = rand;
+$endmarker .= rand() while $html =~ /^\Q$endmarker\E$/m;
+
+print "set base_url = $ENV{BASE_URL}\n" if $ENV{BASE_URL};
+print << "EOS";
+set html_endmarker = $endmarker
+set mode = 1
+$html
+$endmarker
+EOS
--- /dev/null
+# use this script to pipe any variable to xclip, so you have it in your clipboard
+# in your uzbl config, make the first argument the number of the (later) argument you want to use (see README for list of args)
+# make the 2nd argument one of : primary, secondary, clipboard.
+# examples:
+# bind yurl = spawn ./examples/scripts/yank.sh 6 primary
+# bind ytitle = spawn ./examples/scripts/yank.sh 7 clipboard
+
+which xclip &>/dev/null || exit 1
+[ "$9" == primary -o "$9" == secondary -o "$9" == clipboard ] || exit 2
+
+echo echo -n "${!8}" '|' xclip -selection $9
+echo -n "${!8}" | xclip -selection $9
--- /dev/null
+.uzbl_highlight { background-color: yellow;}
+.uzbl_h_first { background-color: lightgreen;}
+
+.uzbl_follow { border-style: dotted;
+ border-width: thin;
+}
+
+#uzbl_hint > div {
+ display: inline;
+ border: 2px solid #4a6600;
+ background-color: #b9ff00;
+ color: black;
+ font-size: 9px;
+ font-weight: bold;
+ line-height: 9px;
+ margin: 0px;
+ padding: 0px;
+ position: absolute;
+ z-index: 1000;
+ -webkit-border-radius: 6px;
+ text-decoration: none;
+ -wekit-transform: scale(1) rotate(0deg) translate(-6px,-5px);
+}
+
+/* vim:set et ts=4: */
+
+++ /dev/null
-#!/bin/bash
-
-# with this script you can store the current url in the clipboard, or go to the url which is stored in the clipboard.
-
-fifo="$5"
-action="$1"
-url="$7"
-selection=$(xclip -o)
-
-case $action in
- "yank" ) echo -n "$url" | xclip;;
- "goto" ) echo "uri $selection" > "$fifo";;
- * ) echo "clipboard.sh: invalid action";;
-esac
-
+++ /dev/null
-#!/usr/bin/env python
-
-import cookielib, sys, os, urllib2
-
-class FakeRequest:
- def __init__(self, argv):
- self.argv = argv
- self.cookies = None
- if len(self.argv) == 12:
- self.cookies = self.argv[11]
- def get_full_url(self):
- #TODO: this is a hack, fix in uzbl.c!
- u = self.get_host()+self.argv[10]
- if self.argv[6].startswith('https'):
- u = 'https://'+u
- else:
- u = 'http://'+u
- return u
- def get_host(self):
- return self.argv[9]
- def get_type(self):
- return self.get_full_url().split(':')[0]
- def is_unverifiable(self):
- return False
- def get_origin_req_host(self):
- return self.argv[9]
- def has_header(self, header):
- if header == 'Cookie':
- return self.cookies!=None
- def get_header(self, header_name, default=None):
- if header_name == 'Cookie' and self.cookies:
- return self.cookies
- else:
- return default
- def header_items(self):
- if self.cookies:
- return [('Cookie',self.cookies)]
- else:
- return []
- def add_unredirected_header(self, key, header):
- if key == 'Cookie':
- self.cookies = header
-
-class FakeHeaders:
- def __init__(self, argv):
- self.argv = argv
- def getallmatchingheaders(self, header):
- if header == 'Set-Cookie' and len(self.argv) == 12:
- return ['Set-Cookie: '+self.argv[11]]
- else:
- return []
- def getheaders(self, header):
- if header == 'Set-Cookie' and len(self.argv) == 12:
- return [self.argv[11]]
- else:
- return []
-class FakeResponse:
- def __init__(self, argv):
- self.argv = argv
- def info(self):
- return FakeHeaders(self.argv)
-
-if __name__ == '__main__':
- search = ['/usr/share/uzbl/examples/data',
- os.environ['XDG_DATA_HOME']+'/uzbl',
- './examples/data']
- for dir in search:
- if os.path.isdir(dir):
- cookie_file = dir+'/cookies.txt'
-
- jar = cookielib.MozillaCookieJar(os.environ['XDG_DATA_HOME']+'/uzbl/cookies.txt')
- try:
- jar.load()
- except:
- pass
-
- req = FakeRequest(sys.argv)
-
- action = sys.argv[8]
-
- if action == 'GET':
- jar.add_cookie_header(req)
- if req.cookies:
- print req.cookies
- elif action == 'PUT':
- res = FakeResponse(sys.argv)
- jar.extract_cookies(res,req)
- jar.save(ignore_discard=True) # save session cookies too
- #jar.save() # save everything but session cookies
\ No newline at end of file
+++ /dev/null
-#!/bin/bash
-
-# THIS IS EXPERIMENTAL AND COULD BE INSECURE !!!!!!
-
-# this is an example bash script of how you could manage your cookies. it is very raw and basic and not as good as cookies.py
-# we use the cookies.txt format (See http://kb.mozillazine.org/Cookies.txt)
-# This is one textfile with entries like this:
-# kb.mozillazine.org FALSE / FALSE 1146030396 wikiUserID 16993
-# domain alow-read-other-subdomains path http-required expiration name value
-# you probably want your cookies config file in your $XDG_CONFIG_HOME ( eg $HOME/.config/uzbl/cookies)
-# Note. in uzbl there is no strict definition on what a session is. it's YOUR job to clear cookies marked as end_session if you want to keep cookies only valid during a "session"
-# MAYBE TODO: allow user to edit cookie before saving. this cannot be done with zenity :(
-# TODO: different cookie paths per config (eg per group of uzbl instances)
-
-# TODO: correct implementation.
-# see http://curl.haxx.se/rfc/cookie_spec.html
-# http://en.wikipedia.org/wiki/HTTP_cookie
-
-# TODO : check expires= before sending.
-# write sample script that cleans up cookies dir based on expires attribute.
-# TODO: check uri against domain attribute. and path also.
-# implement secure attribute.
-# support blocking or not for 3rd parties
-# http://kb.mozillazine.org/Cookies.txt
-# don't always append cookies, sometimes we need to overwrite
-
-[ -f /usr/share/uzbl/examples/configs/cookies ] && cookie_config=/usr/share/uzbl/examples/configs/cookies
-[ -f $XDG_CONFIG_HOME/uzbl/cookies ] && cookie_config=$XDG_CONFIG_HOME/uzbl/cookies
-[ -f ./examples/configs/cookies ] && cookie_config=./examples/configs/cookies #useful when developing
-[ -z "$cookie_config" ] && exit 1
-
-[ -d /usr/share/uzbl/examples/data ] && cookie_data=/usr/share/uzbl/examples/data/cookies.txt
-[ -d $XDG_DATA_HOME/uzbl/ ] && cookie_data=$XDG_DATA_HOME/uzbl/cookies.txt
-[ -d ./examples/data/ ] && cookie_data=./examples/data/cookies.txt #useful when developing
-[ -z "$cookie_data" ] && exit 1
-
-
-notifier=
-#notifier=notify-send
-#notify_wrapper () {
-# echo "$@" >> $HOME/cookielog
-#}
-#notifier=notifier_wrapper
-
-# if this variable is set, we will use it to inform you when and which cookies we store, and when/which we send.
-# it's primarily used for debugging
-notifier=
-which zenity &>/dev/null || exit 2
-
-# Example cookie:
-# test_cookie=CheckForPermission; expires=Thu, 07-May-2009 19:17:55 GMT; path=/; domain=.doubleclick.net
-
-# uri=$6
-# uri=${uri/http:\/\/} # strip 'http://' part
-# host=${uri/\/*/}
-action=$8 # GET/PUT
-host=$9
-shift
-path=$9
-shift
-cookie=$9
-
-field_domain=$host
-field_path=$path
-field_name=
-field_value=
-field_exp='end_session'
-
-function notify () {
- [ -n "$notifier" ] && $notifier "$@"
-}
-
-
-# FOR NOW LETS KEEP IT SIMPLE AND JUST ALWAYS PUT AND ALWAYS GET
-function parse_cookie () {
- IFS=$';'
- first_pair=1
- for pair in $cookie
- do
- if [ "$first_pair" == 1 ]
- then
- field_name=${pair%%=*}
- field_value=${pair#*=}
- first_pair=0
- else
- read -r pair <<< "$pair" #strip leading/trailing wite space
- key=${pair%%=*}
- val=${pair#*=}
- [ "$key" == expires ] && field_exp=`date -u -d "$val" +'%s'`
- # TODO: domain
- [ "$key" == path ] && field_path=$val
- fi
- done
- unset IFS
-}
-
-# match cookies in cookies.txt against hostname and path
-function get_cookie () {
- path_esc=${path//\//\\/}
- search="^[^\t]*$host\t[^\t]*\t$path_esc"
- cookie=`awk "/$search/" $cookie_data 2>/dev/null | tail -n 1`
- if [ -z "$cookie" ]
- then
- notify "Get_cookie: search: $search in $cookie_data -> no result"
- false
- else
- notify "Get_cookie: search: $search in $cookie_data -> result: $cookie"
- read domain alow_read_other_subdomains path http_required expiration name value <<< "$cookie"
- cookie="$name=$value"
- true
- fi
-}
-
-function save_cookie () {
- if parse_cookie
- then
- data="$field_domain\tFALSE\t$field_path\tFALSE\t$field_exp\t$field_name\t$field_value"
- notify "save_cookie: adding $data to $cookie_data"
- echo -e "$data" >> $cookie_data
- else
- notify "not saving a cookie. since we don't have policies yet, parse_cookie must have returned false. this is a bug"
- fi
-}
-
-[ $action == PUT ] && save_cookie
-[ $action == GET ] && get_cookie && echo "$cookie"
-
-exit
-
-
-# TODO: implement this later.
-# $1 = section (TRUSTED or DENY)
-# $2 =url
-function match () {
- sed -n "/$1/,/^\$/p" $cookie_config 2>/dev/null | grep -q "^$host"
-}
-
-function fetch_cookie () {
- cookie=`cat $cookie_data`
-}
-
-function store_cookie () {
- echo $cookie > $cookie_data
-}
-
-if match TRUSTED $host
-then
- [ $action == PUT ] && store_cookie $host
- [ $action == GET ] && fetch_cookie && echo "$cookie"
-elif ! match DENY $host
-then
- [ $action == PUT ] && cookie=`zenity --entry --title 'Uzbl Cookie handler' --text "Accept this cookie from $host ?" --entry-text="$cookie"` && store_cookie $host
- [ $action == GET ] && fetch_cookie && cookie=`zenity --entry --title 'Uzbl Cookie handler' --text "Submit this cookie to $host ?" --entry-text="$cookie"` && echo $cookie
-fi
-exit 0
+++ /dev/null
-#!/bin/bash
-# just an example of how you could handle your downloads
-# try some pattern matching on the uri to determine what we should do
-
-# Some sites block the default wget --user-agent...
-WGET="wget --user-agent=Firefox"
-
-if [[ $8 =~ .*(.torrent) ]]
-then
- cd $HOME
- $WGET $8
-else
- cd $HOME
- $WGET $8
-fi
+++ /dev/null
-/* This is the basic linkfollowing script.
- * Its pretty stable, only using numbers to navigate.
- *
- * TODO: Some pages mess around a lot with the zIndex which
- * lets some hints in the background.
- * TODO: Some positions are not calculated correctly (mostly
- * because of uber-fancy-designed-webpages. Basic HTML and CSS
- * works good
- * TODO: Still some links can't be followed/unexpected things
- * happen. Blame some freaky webdesigners ;)
- */
-
-//Just some shortcuts and globals
-var uzblid = 'uzbl_link_hint';
-var uzbldivid = uzblid + '_div_container';
-var doc = document;
-var win = window;
-var links = document.links;
-var forms = document.forms;
-//Make onlick-links "clickable"
-try {
- HTMLElement.prototype.click = function() {
- if (typeof this.onclick == 'function') {
- this.onclick({
- type: 'click'
- });
- }
- };
-} catch(e) {}
-//Catch the ESC keypress to stop linkfollowing
-function keyPressHandler(e) {
- var kC = window.event ? event.keyCode: e.keyCode;
- var Esc = window.event ? 27 : e.DOM_VK_ESCAPE;
- if (kC == Esc) {
- removeAllHints();
- }
-}
-//Calculate element position to draw the hint
-//Pretty accurate but on fails in some very fancy cases
-function elementPosition(el) {
- var up = el.offsetTop;
- var left = el.offsetLeft;
- var width = el.offsetWidth;
- var height = el.offsetHeight;
- while (el.offsetParent) {
- el = el.offsetParent;
- up += el.offsetTop;
- left += el.offsetLeft;
- }
- return [up, left, width, height];
-}
-//Calculate if an element is visible
-function isVisible(el) {
- if (el == doc) {
- return true;
- }
- if (!el) {
- return false;
- }
- if (!el.parentNode) {
- return false;
- }
- if (el.style) {
- if (el.style.display == 'none') {
- return false;
- }
- if (el.style.visibility == 'hidden') {
- return false;
- }
- }
- return isVisible(el.parentNode);
-}
-//Calculate if an element is on the viewport.
-function elementInViewport(el) {
- offset = elementPosition(el);
- var up = offset[0];
- var left = offset[1];
- var width = offset[2];
- var height = offset[3];
- return up < window.pageYOffset + window.innerHeight && left < window.pageXOffset + window.innerWidth && (up + height) > window.pageYOffset && (left + width) > window.pageXOffset;
-}
-//Removes all hints/leftovers that might be generated
-//by this script.
-function removeAllHints() {
- var elements = doc.getElementById(uzbldivid);
- if (elements) {
- elements.parentNode.removeChild(elements);
- }
-}
-//Generate a hint for an element with the given label
-//Here you can play around with the style of the hints!
-function generateHint(el, label) {
- var pos = elementPosition(el);
- var hint = doc.createElement('div');
- hint.setAttribute('name', uzblid);
- hint.innerText = label;
- hint.style.display = 'inline';
- hint.style.backgroundColor = '#B9FF00';
- hint.style.border = '2px solid #4A6600';
- hint.style.color = 'black';
- hint.style.fontSize = '9px';
- hint.style.fontWeight = 'bold';
- hint.style.lineHeight = '9px';
- hint.style.margin = '0px';
- hint.style.padding = '1px';
- hint.style.position = 'absolute';
- hint.style.zIndex = '1000';
- hint.style.left = pos[1] + 'px';
- hint.style.top = pos[0] + 'px';
- var img = el.getElementsByTagName('img');
- if (img.length > 0) {
- hint.style.left = pos[1] + img[0].width / 2 + 'px';
- }
- hint.style.textDecoration = 'none';
- hint.style.webkitBorderRadius = '6px';
- // Play around with this, pretty funny things to do :)
- hint.style.webkitTransform = 'scale(1) rotate(0deg) translate(-6px,-5px)';
- return hint;
-}
-//Here we choose what to do with an element if we
-//want to "follow" it. On form elements we "select"
-//or pass the focus, on links we try to perform a click,
-//but at least set the href of the link. (needs some improvements)
-function clickElem(item) {
- removeAllHints();
- if (item) {
- var name = item.tagName;
- if (name == 'A') {
- item.click();
- window.location = item.href;
- } else if (name == 'INPUT') {
- var type = item.getAttribute('type').toUpperCase();
- if (type == 'TEXT' || type == 'FILE' || type == 'PASSWORD') {
- item.focus();
- item.select();
- } else {
- item.click();
- }
- } else if (name == 'TEXTAREA' || name == 'SELECT') {
- item.focus();
- item.select();
- } else {
- item.click();
- window.location = item.href;
- }
- }
-}
-//Returns a list of all links (in this version
-//just the elements itself, but in other versions, we
-//add the label here.
-function addLinks() {
- res = [[], []];
- for (var l = 0; l < links.length; l++) {
- var li = links[l];
- if (isVisible(li) && elementInViewport(li)) {
- res[0].push(li);
- }
- }
- return res;
-}
-//Same as above, just for the form elements
-function addFormElems() {
- res = [[], []];
- for (var f = 0; f < forms.length; f++) {
- for (var e = 0; e < forms[f].elements.length; e++) {
- var el = forms[f].elements[e];
- if (el && ['INPUT', 'TEXTAREA', 'SELECT'].indexOf(el.tagName) + 1 && isVisible(el) && elementInViewport(el)) {
- res[0].push(el);
- }
- }
- }
- return res;
-}
-//Draw all hints for all elements passed. "len" is for
-//the number of chars we should use to avoid collisions
-function reDrawHints(elems, chars) {
- removeAllHints();
- var hintdiv = doc.createElement('div');
- hintdiv.setAttribute('id', uzbldivid);
- for (var i = 0; i < elems[0].length; i++) {
- if (elems[0][i]) {
- var label = elems[1][i].substring(chars);
- var h = generateHint(elems[0][i], label);
- hintdiv.appendChild(h);
- }
- }
- if (document.body) {
- document.body.appendChild(hintdiv);
- }
-}
-//Put it all together
-function followLinks(follow) {
- var s = follow.split('');
- var linknr = parseInt(follow, 10);
- if (document.body) document.body.setAttribute('onkeyup', 'keyPressHandler(event)');
- var linkelems = addLinks();
- var formelems = addFormElems();
- var elems = [linkelems[0].concat(formelems[0]), linkelems[1].concat(formelems[1])];
- var len = (elems[0].length + '').length;
- var oldDiv = doc.getElementById(uzbldivid);
- var leftover = [[], []];
- if (linknr + 1 && s.length == len && linknr < elems[0].length && linknr >= 0) {
- clickElem(elems[0][linknr]);
- } else {
- for (var j = 0; j < elems[0].length; j++) {
- var b = true;
- var label = j + '';
- var n = label.length;
- for (n; n < len; n++) {
- label = '0' + label;
- }
- for (var k = 0; k < s.length; k++) {
- b = b && label.charAt(k) == s[k];
- }
- if (b) {
- leftover[0].push(elems[0][j]);
- leftover[1].push(label);
- }
- }
- reDrawHints(leftover, s.length);
- }
-}
-followLinks('%s');
+++ /dev/null
-var uzblid = 'uzbl_link_hint';
-var uzbldivid = uzblid + '_div_container';
-var doc = document;
-var win = window;
-var links = document.links;
-var forms = document.forms;
-try {
- HTMLElement.prototype.click = function() {
- if (typeof this.onclick == 'function') {
- this.onclick({
- type: 'click'
- });
- }
- };
-} catch(e) {}
-function keyPressHandler(e) {
- var kC = window.event ? event.keyCode: e.keyCode;
- var Esc = window.event ? 27 : e.DOM_VK_ESCAPE;
- if (kC == Esc) {
- removeAllHints();
- }
-}
-function elementPosition(el) {
- var up = el.offsetTop;
- var left = el.offsetLeft;
- var width = el.offsetWidth;
- var height = el.offsetHeight;
- while (el.offsetParent) {
- el = el.offsetParent;
- up += el.offsetTop;
- left += el.offsetLeft;
- }
- return [up, left, width, height];
-}
-function isVisible(el) {
- if (el == doc) {
- return true;
- }
- if (!el) {
- return false;
- }
- if (!el.parentNode) {
- return false;
- }
- if (el.style) {
- if (el.style.display == 'none') {
- return false;
- }
- if (el.style.visibility == 'hidden') {
- return false;
- }
- }
- return isVisible(el.parentNode);
-}
-function elementInViewport(el) {
- offset = elementPosition(el);
- var up = offset[0];
- var left = offset[1];
- var width = offset[2];
- var height = offset[3];
- return up < window.pageYOffset + window.innerHeight && left < window.pageXOffset + window.innerWidth && (up + height) > window.pageYOffset && (left + width) > window.pageXOffset;
-}
-function removeAllHints() {
- var elements = doc.getElementById(uzbldivid);
- if (elements) {
- elements.parentNode.removeChild(elements);
- }
-}
-function generateHint(el, label) {
- var pos = elementPosition(el);
- var hint = doc.createElement('div');
- hint.setAttribute('name', uzblid);
- hint.innerText = label;
- hint.style.display = 'inline';
- hint.style.backgroundColor = '#B9FF00';
- hint.style.border = '2px solid #4A6600';
- hint.style.color = 'black';
- hint.style.zIndex = '1000';
- hint.style.fontSize = '9px';
- hint.style.fontWeight = 'bold';
- hint.style.lineHeight = '9px';
- hint.style.margin = '0px';
- hint.style.padding = '1px';
- hint.style.position = 'absolute';
- hint.style.left = pos[1] + 'px';
- hint.style.top = pos[0] + 'px';
- var img = el.getElementsByTagName('img');
- if (img.length > 0) {
- hint.style.left = pos[1] + img[0].width / 2 + 'px';
- }
- hint.style.textDecoration = 'none';
- hint.style.webkitBorderRadius = '6px';
- hint.style.webkitTransform = 'scale(1) rotate(0deg) translate(-6px,-5px)';
- return hint;
-}
-function clickElem(item) {
- removeAllHints();
- if (item) {
- var name = item.tagName;
- if (name == 'A') {
- item.click();
- window.location = item.href;
- } else if (name == 'INPUT') {
- var type = item.getAttribute('type').toUpperCase();
- if (type == 'TEXT' || type == 'FILE' || type == 'PASSWORD') {
- item.focus();
- item.select();
- } else {
- item.click();
- }
- } else if (name == 'TEXTAREA' || name == 'SELECT') {
- item.focus();
- item.select();
- } else {
- item.click();
- window.location = item.href;
- }
- }
-}
-function addLinks() {
- res = [[], []];
- for (var l = 0; l < links.length; l++) {
- var li = links[l];
- if (isVisible(li) && elementInViewport(li)) {
- res[0].push(li);
- res[1].push(li.innerText.toLowerCase());
- }
- }
- return res;
-}
-function addFormElems() {
- res = [[], []];
- for (var f = 0; f < forms.length; f++) {
- for (var e = 0; e < forms[f].elements.length; e++) {
- var el = forms[f].elements[e];
- if (el && ['INPUT', 'TEXTAREA', 'SELECT'].indexOf(el.tagName) + 1 && isVisible(el) && elementInViewport(el)) {
- res[0].push(el);
- if (el.getAttribute('value')) {
- res[1].push(el.getAttribute('value').toLowerCase());
- } else {
- res[1].push(el.getAttribute('name').toLowerCase());
- }
- }
- }
- }
- return res;
-}
-function reDrawHints(elems, len) {
- var hintdiv = doc.createElement('div');
- hintdiv.setAttribute('id', uzbldivid);
- hintdiv.style.opacity = '0.0';
- for (var i = 0; i < elems[0].length; i++) {
- var label = i + '';
- var n = label.length;
- for (n; n < len; n++) {
- label = '0' + label;
- }
- if (elems[0][i]) {
- var h = generateHint(elems[0][i], label);
- hintdiv.appendChild(h);
- }
- }
- if (document.body) {
- document.body.appendChild(hintdiv);
- hintdiv.style.opacity = '0.7'
- }
-}
-function followLinks(follow) {
- var s = follow.split('');
- var linknr = parseInt(follow, 10);
- if (document.body) document.body.setAttribute('onkeyup', 'keyPressHandler(event)');
- var linkelems = addLinks();
- var formelems = addFormElems();
- var elems = [linkelems[0].concat(formelems[0]), linkelems[1].concat(formelems[1])];
- var len = (elems[0].length + '').length;
- var oldDiv = doc.getElementById(uzbldivid);
- var leftover = [[], []];
- if (linknr + 1 && s.length == len && linknr < elems[0].length && linknr >= 0) {
- clickElem(elems[0][linknr]);
- } else {
- for (var j = 0; j < elems[0].length; j++) {
- var b = true;
- for (var k = 0; k < s.length; k++) {
- b = b && elems[1][j].charAt(k) == s[k];
- }
- if (!b) {
- elems[0][j] = null;
- elems[1][j] = null;
- } else {
- leftover[0].push(elems[0][j]);
- leftover[1].push(elems[1][j]);
- }
- }
- if (leftover[0].length == 1) {
- clickElem(leftover[0][0]);
- } else if (!oldDiv) {
- if (linknr + 1 || s.length == 0) {
- reDrawHints(elems, len);
- } else {
- reDrawHints(leftover, len);
- }
- }
- }
-}
-followLinks('%s');
+++ /dev/null
-#!/usr/bin/perl
-
-# a slightly more advanced form filler
-#
-# uses settings file like: $keydir/<domain>
-
-# user arg 1:
-# edit: force editing of the file (fetches if file is missing)
-# load: fill forms from file (fetches if file is missing)
-# new: fetch new file
-
-# usage example:
-# bind LL = spawn /usr/share/uzbl/examples/scripts/formfiller.pl load
-# bind LN = spawn /usr/share/uzbl/examples/scripts/formfiller.pl new
-# bind LE = spawn /usr/share/uzbl/examples/scripts/formfiller.pl edit
-
-use strict;
-use warnings;
-
-my $keydir = $ENV{XDG_CONFIG_HOME} . "/uzbl/forms";
-my ($config,$pid,$xid,$fifoname,$socket,$url,$title,$cmd) = @ARGV;
-if (!defined $fifoname || $fifoname eq "") { die "No fifo"; }
-
-sub domain {
- my ($url) = @_;
- $url =~ s#http(s)?://([A-Za-z0-9\.-]+)(/.*)?#$2#;
- return $url;
-};
-
-my $editor = "xterm -e vim";
-#my $editor = "gvim";
-
-# ideally, there would be some way to ask uzbl for the html content instead of having to redownload it with
-# Also, you may need to fake the user-agent on some sites (like facebook)
- my $downloader = "curl -A 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.10) Gecko/2009042810 GranParadiso/3.0.10' ";
-#my $downloader = "curl -s";
-
-my @fields = ("type","name","value");
-
-my %command;
-
-$command{load} = sub {
- my ($domain) = @_;
- my $filename = "$keydir/$domain";
- if (-e $filename){
- open(my $file, $filename) or die "Failed to open $filename: $!";
- my (@lines) = <$file>;
- close($file);
- $|++;
- open(my $fifo, ">>", $fifoname) or die "Failed to open $fifoname: $!";
- foreach my $line (@lines) {
- next if ($line =~ m/^#/);
- my ($type,$name,$value) = ($line =~ /^\s*(\w+)\s*\|\s*(.*?)\s*\|\s*(.*?)\s*$/);
- if ($type eq "checkbox")
- {
- printf $fifo 'js document.getElementsByName("%s")[0].checked = %s;', $name, $value;
- } elsif ($type eq "submit")
- {
- printf $fifo 'js function fs (n) {try{n.submit()} catch (e){fs(n.parentNode)}}; fs(document.getElementsByName("%s")[0]);', $name;
- } elsif ($type ne "")
- {
- printf $fifo 'js document.getElementsByName("%s")[0].value = "%s";', $name, $value;
- }
- print $fifo "\n";
- }
- $|--;
- } else {
- $command{new}->($domain);
- $command{edit}->($domain);
- }
-};
-$command{edit} = sub {
- my ($domain) = @_;
- my $file = "$keydir/$domain";
- if(-e $file){
- system ($editor, $file);
- } else {
- $command{new}->($domain);
- }
-};
-$command{new} = sub {
- my ($domain) = @_;
- my $filename = "$keydir/$domain";
- open (my $file,">>", $filename) or die "Failed to open $filename: $!";
- $|++;
- print $file "# Make sure that there are no extra submits, since it may trigger the wrong one.\n";
- printf $file "#%-10s | %-10s | %s\n", @fields;
- print $file "#------------------------------\n";
- my @data = `$downloader $url`;
- foreach my $line (@data){
- if($line =~ m/<input ([^>].*?)>/i){
- $line =~ s/.*(<input ([^>].*?)>).*/$1/;
- printf $file " %-10s | %-10s | %s\n", map { my ($r) = $line =~ /.*$_=["'](.*?)["']/;$r } @fields;
- };
- };
- $|--;
-};
-
-$command{$cmd}->(domain($url));
+++ /dev/null
-#!/bin/bash
-
-# simple html form (eg for logins) filler (and manager) for uzbl.
-# uses settings files like: $keydir/<domain>
-# files contain lines like: <fieldname>: <value>
-
-
-# user arg 1:
-# edit: force editing the file (falls back to new if not found)
-# new: start with a new file.
-# load: try to load from file into form
-
-# something else (or empty): if file not available: new, otherwise load.
-
-[ -d /usr/share/uzbl/examples/data/forms ] && keydir=/usr/share/uzbl/examples/data/forms # you will probably get permission denied errors here.
-[ -d $XDG_DATA_HOME/uzbl/forms ] && keydir=$XDG_DATA_HOME/uzbl/forms
-[ -d ./examples/data/forms ] && keydir=./examples/data/forms #useful when developing
-[ -z "$keydir" ] && exit 1
-
-#editor=gvim
-editor='urxvt -e vim'
-
-config=$1; shift
-pid=$1; shift
-xid=$1; shift
-fifo=$1; shift
-socket=$1; shift
-url=$1; shift
-title=$1; shift
-action=$1
-
-[ -d $keydir ] || mkdir $keydir || exit 1
-
-if [ "$action" != 'edit' -a "$action" != 'new' -a "$action" != 'load' ]
-then
- action=new
- [[ -e $keydir/$domain ]] && action=load
-elif [ "$action" == 'edit' ] && [[ ! -e $keydir/$domain ]]
-then
- action=new
-fi
-domain=$(echo $url | sed -re 's|(http\|https)+://([A-Za-z0-9\.]+)/.*|\2|')
-
-
-#regex='s|.*<input.*?name="([[:graph:]]+)".*?/>.*|\1: |p' # sscj's first version, does not work on http://wiki.archlinux.org/index.php?title=Special:UserLogin&returnto=Main_Page
- regex='s|.*<input.*?name="([^"]*)".*|\1: |p' #works on arch wiki, but not on http://lists.uzbl.org/listinfo.cgi/uzbl-dev-uzbl.org TODO: improve
-
-
-if [ "$action" = 'load' ]
-then
- [[ -e $keydir/$domain ]] || exit 2
- gawk -F': ' '{ print "js document.getElementsByName(\"" $1 "\")[0].value = \"" $2 "\";"}' $keydir/$domain >> $fifo
-else
- if [ "$action" == 'new' ]
- then
- curl "$url" | grep '<input' | sed -nre "$regex" > $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
+++ /dev/null
-for (var i=0; i < document.links.length; i++) {
- var uzblid = 'uzbl_link_hint_';
- var li = document.links[i];
- var pre = document.getElementById(uzblid+i);
-
- if (pre) {
- li.removeChild(pre);
- } else {
- var hint = document.createElement('div');
- hint.setAttribute('id',uzblid+i);
- hint.innerHTML = i;
- hint.style.display='inline';
- hint.style.lineHeight='90%';
- hint.style.backgroundColor='red';
- hint.style.color='white';
- hint.style.fontSize='small-xx';
- hint.style.fontWeight='light';
- hint.style.margin='0px';
- hint.style.padding='2px';
- hint.style.position='absolute';
- hint.style.textDecoration='none';
- hint.style.left=li.style.left;
- hint.style.top=li.style.top;
- li.insertAdjacentElement('afterBegin',hint);
- }
-}
+++ /dev/null
-#!/bin/bash
-#TODO: strip 'http://' part
-# you probably really want this in your $XDG_DATA_HOME (eg $HOME/.local/share/uzbl/history)
-echo "$8 $6 $7" >> /tmp/uzbl.history
+++ /dev/null
-#!/bin/bash
-# you probably want your bookmarks file in your $XDG_DATA_HOME ( eg $HOME/.local/share/uzbl/bookmarks)
-
-
-[ -f /usr/share/uzbl/examples/data/bookmarks ] && file=/usr/share/uzbl/examples/data/bookmarks # you will probably get permission denied errors here.
-[ -f $XDG_DATA_HOME/uzbl/bookmarks ] && file=$XDG_DATA_HOME/uzbl/bookmarks
-[ -f ./examples/data/bookmarks ] && file=./examples/data/bookmarks #useful when developing
-[ -z "$file" ] && exit 1
-
-which zenity &>/dev/null || exit 2
-
-entry=`zenity --entry --text="Add bookmark. add tags after the '\t', separated by spaces" --entry-text="$6 $7\t"`
-url=`awk '{print $1}' <<< $entry`
-# TODO: check if already exists, if so, and tags are different: ask if you want to replace tags
-echo "$entry" >/dev/null #for some reason we need this.. don't ask me why
-echo -e "$entry" >> $file
-true
\ No newline at end of file
+++ /dev/null
-// link follower for uzbl
-// requires http://github.com/DuClare/uzbl/commit/6c11777067bdb8aac09bba78d54caea04f85e059
-//
-// first, it needs to be loaded before every time it is used.
-// One way would be to use the load_commit_handler:
-// set load_commit_handler = sh 'echo "script /usr/share/uzbl/examples/scripts/linkfollow.js" > "$4"'
-//
-// when script is loaded, it can be invoked with
-// bind f* = js hints.set("%s", hints.open)
-// bind f_ = js hints.follow("%s",hints.open)
-//
-// At the moment, it may be useful to have way of forcing uzbl to load the script
-// bind :lf = script /usr/share/uzbl/examples/scripts/linkfollow.js
-//
-// The default style for the hints are pretty ugly, so it is recommended to add the following
-// to config file
-// set stylesheet_uri = /usr/share/uzbl/examples/data/style.css
-//
-// based on follow_Numbers.js
-//
-// TODO: fix styling for the first element
-// TODO: emulate mouseover events when visiting some elements
-// TODO: rewrite the element->action handling
-
-
-function Hints(){
-
- // Settings
- ////////////////////////////////////////////////////////////////////////////
-
- // if set to true, you must explicitly call hints.follow(), otherwise it will
- // follow the link if there is only one matching result
- var requireReturn = true;
-
- // Case sensitivity flag
- var matchCase = "i";
-
- // For case sensitive matching, uncomment:
- // var matchCase = "";
-
-
- var uzblid = 'uzbl_hint';
- var uzblclass = 'uzbl_highlight';
- var uzblclassfirst = 'uzbl_h_first';
- var doc = document;
- var visible = [];
- var hintdiv;
-
- this.set = hint;
- this.follow = follow;
- this.keyPressHandler = keyPressHandler;
-
- function elementPosition(el) {
- var up = el.offsetTop;
- var left = el.offsetLeft; var width = el.offsetWidth;
- var height = el.offsetHeight;
-
- while (el.offsetParent) {
- el = el.offsetParent;
- up += el.offsetTop;
- left += el.offsetLeft;
- }
- return {up: up, left: left, width: width, height: height};
- }
-
- function elementInViewport(p) {
- return (p.up < window.pageYOffset + window.innerHeight &&
- p.left < window.pageXOffset + window.innerWidth &&
- (p.up + p.height) > window.pageYOffset &&
- (p.left + p.width) > window.pageXOffset);
- }
-
- function isVisible(el) {
- if (el == doc) { return true; }
- if (!el) { return false; }
- if (!el.parentNode) { return false; }
- if (el.style) {
- if (el.style.display == 'none') {
- return false;
- }
- if (el.style.visibility == 'hidden') {
- return false;
- }
- }
- return isVisible(el.parentNode);
- }
-
- // the vimperator defaults minus the xhtml elements, since it gave DOM errors
- var hintable = " //*[@onclick or @onmouseover or @onmousedown or @onmouseup or @oncommand or @class='lk' or @role='link' or @href] | //input[not(@type='hidden')] | //a | //area | //iframe | //textarea | //button | //select";
-
- function Matcher(str){
- var numbers = str.replace(/[^\d]/g,"");
- var words = str.replace(/\d/g,"").split(/\s+/).map(function (n) { return new RegExp(n,matchCase)});
- this.test = test;
- this.toString = toString;
- this.numbers = numbers;
- function matchAgainst(element){
- if(element.node.nodeName == "INPUT"){
- return element.node.value;
- } else {
- return element.node.textContent;
- }
- }
- function test(element) {
- // test all the regexp
- var item = matchAgainst(element);
- return words.every(function (regex) { return item.match(regex)});
- }
- }
-
- function HintElement(node,pos){
-
- this.node = node;
- this.isHinted = false;
- this.position = pos;
- this.num = 0;
-
- this.addHint = function (labelNum) {
- // TODO: fix uzblclassfirst
- if(!this.isHinted){
- this.node.className += " " + uzblclass;
- }
- this.isHinted = true;
-
- // create hint
- var hintNode = doc.createElement('div');
- hintNode.name = uzblid;
- hintNode.innerText = labelNum;
- hintNode.style.left = this.position.left + 'px';
- hintNode.style.top = this.position.up + 'px';
- hintNode.style.position = "absolute";
- doc.body.firstChild.appendChild(hintNode);
-
- }
- this.removeHint = function(){
- if(this.isHinted){
- var s = (this.num)?uzblclassfirst:uzblclass;
- this.node.className = this.node.className.replace(new RegExp(" "+s,"g"),"");
- this.isHinted = false;
- }
- }
- }
-
- function createHintDiv(){
- var hintdiv = doc.getElementById(uzblid);
- if(hintdiv){
- hintdiv.parentNode.removeChild(hintdiv);
- }
- hintdiv = doc.createElement("div");
- hintdiv.setAttribute('id',uzblid);
- doc.body.insertBefore(hintdiv,doc.body.firstChild);
- return hintdiv;
- }
-
- function init(){
- // WHAT?
- doc.body.setAttribute("onkeyup","hints.keyPressHandler(event)");
- hintdiv = createHintDiv();
- visible = [];
-
- var items = doc.evaluate(hintable,doc,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);
- for (var i = 0;i<items.snapshotLength;i++){
- var item = items.snapshotItem(i);
- var pos = elementPosition(item);
- if(isVisible && elementInViewport(elementPosition(item))){
- visible.push(new HintElement(item,pos));
- }
- }
- }
-
- function clear(){
-
- visible.forEach(function (n) { n.removeHint(); } );
- hintdiv = doc.getElementById(uzblid);
- while(hintdiv){
- hintdiv.parentNode.removeChild(hintdiv);
- hintdiv = doc.getElementById(uzblid);
- }
- }
-
- function update(str,openFun) {
- var match = new Matcher(str);
- hintdiv = createHintDiv();
- var i = 1;
- visible.forEach(function (n) {
- if(match.test(n)) {
- n.addHint(i);
- i++;
- } else {
- n.removeHint();
- }});
- if(!requireReturn){
- if(i==2){ //only been incremented once
- follow(str,openFun);
- }
- }
- }
-
- function hint(str,openFun){
- if(str.length == 0) init();
- update(str,openFun);
- }
-
- function keyPressHandler(e) {
- var kC = window.event ? event.keyCode: e.keyCode;
- var Esc = window.event ? 27 : e.DOM_VK_ESCAPE;
- if (kC == Esc) {
- clear();
- doc.body.removeAttribute("onkeyup");
- }
- }
-
- this.openNewWindow = function(item){
- // TODO: this doesn't work yet
- item.className += " uzbl_follow";
- window.open(item.href,"uzblnew","");
- }
- this.open = function(item){
- simulateMouseOver(item);
- item.className += " uzbl_follow";
- window.location = item.href;
- }
-
- function simulateMouseOver(item){
- var evt = doc.createEvent("MouseEvents");
- evt.initMouseEvent("MouseOver",true,true,
- doc.defaultView,1,0,0,0,0,
- false,false,false,false,0,null);
- return item.dispatchEvent(evt);
- }
-
-
- function follow(str,openFunction){
- var m = new Matcher(str);
- var items = visible.filter(function (n) { return n.isHinted });
- clear();
- var num = parseInt(m.numbers,10);
- if(num){
- var item = items[num-1].node;
- } else {
- var item = items[0].node;
- }
- if (item) {
- var name = item.tagName;
- if (name == 'A') {
- if(item.click) {item.click()};
- openFunction(item);
- } else if (name == 'INPUT') {
- var type = item.getAttribute('type').toUpperCase();
- if (type == 'TEXT' || type == 'FILE' || type == 'PASSWORD') {
- item.focus();
- item.select();
- } else {
- item.click();
- }
- } else if (name == 'TEXTAREA' || name == 'SELECT') {
- item.focus();
- item.select();
- } else {
- item.click();
- openFunction(item);
- }
- }
- }
-}
-
-var hints = new Hints();
-
-// vim:set et sw=2:
-
-
+++ /dev/null
-#!/bin/bash
-
-#NOTE: it's the job of the script that inserts bookmarks to make sure there are no dupes.
-
-[ -f /usr/share/uzbl/examples/data/bookmarks ] && file=/usr/share/uzbl/examples/data/bookmarks
-[ -f $XDG_DATA_HOME/uzbl/bookmarks ] && file=$XDG_DATA_HOME/uzbl/bookmarks
-[ -f ./examples/data/bookmarks ] && file=./examples/data/bookmarks #useful when developing
-[ -z "$file" ] && exit 1
-COLORS=" -nb #303030 -nf khaki -sb #CCFFAA -sf #303030"
-if dmenu --help 2>&1 | grep -q '\[-rs\] \[-ni\] \[-nl\] \[-xs\]'
-then
- DMENU="dmenu -i -xs -rs -l 10" # vertical patch
- # show tags as well
- goto=`$DMENU $COLORS < $file | awk '{print $1}'`
-else
- DMENU="dmenu -i"
- # because they are all after each other, just show the url, not their tags.
- goto=`awk '{print $1}' $file | $DMENU $COLORS`
-fi
-
-#[ -n "$goto" ] && echo "uri $goto" > $4
-[ -n "$goto" ] && uzblctrl -s $5 -c "uri $goto"
+++ /dev/null
-#!/bin/bash
-# you probably really want this in your $XDG_DATA_HOME (eg $HOME/.local/share/uzbl/history)
-history_file=/tmp/uzbl.history
-
-# choose from all entries, sorted and uniqued
-# goto=`awk '{print $3}' $history_file | sort -u | dmenu -i`
-COLORS=" -nb #303030 -nf khaki -sb #CCFFAA -sf #303030"
-if dmenu --help 2>&1 | grep -q '\[-rs\] \[-ni\] \[-nl\] \[-xs\]'
-then
- DMENU="dmenu -i -xs -rs -l 10" # vertical patch
- # choose an item in reverse order, showing also the date and page titles
- # pick the last field from the first 3 fields. this way you can pick a url (prefixed with date & time) or type just a new url.
- goto=`tac $history_file | $DMENU $COLORS | cut -d ' ' -f -3 | awk '{print $NF}'`
-else
- DMENU="dmenu -i"
- # choose from all entries (no date or title), the first one being current url, and after that all others, sorted and uniqued, in ascending order
- current=`tail -n 1 $history_file | awk '{print $3}'`; goto=`(echo $current; awk '{print $3}' $history_file | grep -v "^$current\$" | sort -u) | $DMENU $COLORS`
-fi
-
-[ -n "$goto" ] && echo "uri $goto" > $4
-#[ -n "$goto" ] && uzblctrl -s $5 -c "uri $goto"
+++ /dev/null
-#!/bin/bash
-
-# Very simple session manager for uzbl. When called with "endsession" as the
-# argument, it'll backup $sessionfile, look for fifos in $fifodir and
-# instruct each of them to store their current url in $sessionfile and
-# terminate themselves. Run with "launch" as the argument and an instance of
-# uzbl will be launched for each stored url. "endinstance" is used internally
-# and doesn't need to be called manually at any point.
-# Add a line like 'bind quit = /path/to/session.sh endsession' to your config
-
-scriptfile=$0 # this script
-sessionfile=$XDG_DATA_HOME/uzbl/session # the file in which the "session" (i.e. urls) are stored
-configfile=$XDG_DATA_HOME/uzbl/config # uzbl configuration file
-UZBL="uzbl -c $configfile" # add custom flags and whatever here.
-
-fifodir=/tmp # remember to change this if you instructed uzbl to put its fifos elsewhere
-thisfifo="$4"
-act="$8"
-url="$6"
-
-if [ "$act." = "." ]; then
- act="$1"
-fi
-
-
-case $act in
- "launch" )
- urls=$(cat $sessionfile)
- if [ "$urls." = "." ]; then
- $UZBL
- else
- for url in $urls; do
- $UZBL --uri "$url" &
- done
- fi
- exit 0
- ;;
-
- "endinstance" )
- if [ "$url" != "(null)" ]; then
- echo "$url" >> $sessionfile;
- fi
- echo "exit" > "$thisfifo"
- ;;
-
- "endsession" )
- mv "$sessionfile" "$sessionfile~"
- for fifo in $fifodir/uzbl_fifo_*; do
- if [ "$fifo" != "$thisfifo" ]; then
- echo "spawn $scriptfile endinstance" > "$fifo"
- fi
- done
- echo "spawn $scriptfile endinstance" > "$thisfifo"
- ;;
-
- * ) echo "session manager: bad action"
- echo "Usage: $scriptfile [COMMAND] where commands are:"
- echo " launch - Restore a saved session or start a new one"
- echo " endsession - Quit the running session. Must be called from uzbl"
- ;;
-esac
-
+++ /dev/null
-#!/usr/bin/env perl
-# uzblcat - safely push html to uzbl
-# See http://www.uzbl.org/wiki/html-mode
-use strict; use warnings;
-
-my $html;
-local $/; # slurp files
-# automagically choose to read from stdin/files/...
-$html .= $_ for <>;
-
-my $endmarker = rand;
-$endmarker .= rand() while $html =~ /^\Q$endmarker\E$/m;
-
-print "set base_url = $ENV{BASE_URL}\n" if $ENV{BASE_URL};
-print << "EOS";
-set html_endmarker = $endmarker
-set mode = 1
-$html
-$endmarker
-EOS
+++ /dev/null
-# use this script to pipe any variable to xclip, so you have it in your clipboard
-# in your uzbl config, make the first argument the number of the (later) argument you want to use (see README for list of args)
-# make the 2nd argument one of : primary, secondary, clipboard.
-# examples:
-# bind yurl = spawn ./examples/scripts/yank.sh 6 primary
-# bind ytitle = spawn ./examples/scripts/yank.sh 7 clipboard
-
-which xclip &>/dev/null || exit 1
-[ "$9" == primary -o "$9" == secondary -o "$9" == clipboard ] || exit 2
-
-echo echo -n "${!8}" '|' xclip -selection $9
-echo -n "${!8}" | xclip -selection $9