===== Use custom stylesheets ===== ==== Description ==== This is a simple script that enables the use of custom stylesheets (similar to the Stylish extension for Firefox). * All custom stylesheets should be in a single folder. * For every web site for which you want to have a custom stylesheet, you put it in that folder. * Every custom stylesheet must be named web_address.css (e.g. www.reddit.com.css) * If you want to use the script, you should add it to the commit_handler, example.. @on_event LOAD_COMMIT spawn @scripts_dir/change_style.sh * To use custom stylesheets from userstyles.org one should first remove the leading @namespace url(http://www.w3.org/1999/xhtml); @-moz-document domain("webaddress.com") { and the tailing } * If you use styles that have dark backgrounds, and want to avoid flashes of white between pages create an about:blank.css with the following (change color as desired) * { background: #262626 !important; } ==== Script ==== #/bin/bash # Author: Jurica Bradaric # A simple script to use custom stylesheets for websites. # Similar to the Stylish extension for Firefox. # I hope someone finds it useful. All comments and suggestions # are welcome. XDG_DATA_HOME=${XDG_DATA_HOME:-"$HOME/.local/share/"} # Set the path to the .css files # Every custom css style must be in a file named web_address.css # e.g. reddit.com.css STYLE_PATH=$XDG_DATA_HOME/uzbl/userstyles STYLESHEET_SET=0 for i in $STYLE_PATH/*.css; do stylesheet=$(basename $i '.css') if [[ "$UZBL_URI" =~ "${stylesheet}" ]]; then echo "set stylesheet_uri = file://${STYLE_PATH}/${stylesheet}.css" > "$UZBL_FIFO" STYLESHEET_SET=1 break fi done if [ $STYLESHEET_SET -eq 0 ]; then echo "set stylesheet_uri = file://${STYLE_PATH}/default.css" > "$UZBL_FIFO" fi exit 0 === Alternative method === Instead of extenal script one can use setting in uzbl config file, e.g.: set conf.d = $XDG_CONFIG_HOME/uzbl @on_event LOAD_COMMIT set stylesheet_uri = file://@conf.d/css/\@(s=\@\@.css; [ -e @conf.d/css/$s ] || s=default.css; echo $s)\@ in this example styles are located in ./css under uzbl config path