summaryrefslogtreecommitdiff
path: root/.uzbl/scripts
diff options
context:
space:
mode:
Diffstat (limited to '.uzbl/scripts')
-rwxr-xr-x.uzbl/scripts/adblock.js28
-rwxr-xr-x.uzbl/scripts/adblock.py86
-rwxr-xr-x.uzbl/scripts/downloadviewer.sh7
-rwxr-xr-x.uzbl/scripts/url_from_surfraw.sh17
4 files changed, 0 insertions, 138 deletions
diff --git a/.uzbl/scripts/adblock.js b/.uzbl/scripts/adblock.js
deleted file mode 100755
index b581f9b..0000000
--- a/.uzbl/scripts/adblock.js
+++ /dev/null
@@ -1,28 +0,0 @@
-var blocklist = new Array();
-blocklist["IMG"] = [["src", /.*doubleclick.net.*/],
- ["src", /.*last.fm\/adserver.*/]];
-
-blocklist["SCRIPT"] = [["src", /.*doubleclick.net.*/]];
-
-blocklist["IFRAME"] = [["name", /.*google_ads.*/],
- ["id", /.*ad-google.*/]];
-
-
-
-
-function adblock(event)
-{
- var tag = event.target.tagName;
- if (!blocklist[tag])
- return;
- for(var i = 0; i < blocklist[tag].length; i++) {
- if (event.target.getAttribute(blocklist[tag][i][0])) {
- if (event.target.getAttribute(blocklist[tag][i][0]).match(blocklist[tag][i][1])) {
- event.preventDefault();
- return;
- }
- }
- }
-}
-
-document.addEventListener("beforeload", adblock, true);
diff --git a/.uzbl/scripts/adblock.py b/.uzbl/scripts/adblock.py
deleted file mode 100755
index aae39f4..0000000
--- a/.uzbl/scripts/adblock.py
+++ /dev/null
@@ -1,86 +0,0 @@
-#!/usr/bin/python
-import os
-from sys import argv
-from urlparse import urlparse
-
-# This is the original adblock.py script from http://www.uzbl.org/wiki/adblock
-# Nothing was modified. This script is here just to have everything at one place.
-
-def xdghome(key, default):
- '''Attempts to use the environ XDG_*_HOME paths if they exist otherwise
- use $HOME and the default path.'''
-
- xdgkey = "XDG_%s_HOME" % key
- if xdgkey in os.environ.keys() and os.environ[xdgkey]:
- return os.environ[xdgkey]
-
- return os.path.join(os.environ['HOME'], default)
-
-# Setup xdg paths.
-DATA_DIR = os.path.join(xdghome('DATA', '.local/share/'), 'uzbl/')
-
-# Blockfile location.
-BLOCKFILE = os.path.join(DATA_DIR, 'adblock')
-
-JAVASCRIPT = ' '.join(filter(None, map(str.strip, '''
-var uzblAdBlock = function() {
- var toblock = %s;
- for(var n = 0; n < toblock.length; n++) {
- var items;
- while (1) {
- try {
- items = document.evaluate(toblock[n], document, null, XPathResult.ORDERED_NODE_ITERATOR_TYPE, null);
- if (items == null) { break; }
- var i = items.iterateNext();
- if (i == null) { break; }
- i.parentNode.removeChild(i);
- } catch (e) {
- break;
- }
- }
- }
-};
-'''.split('\n'))))
-
-
-def get_domain(url):
- '''Return domain segment of url.'''
-
- if not url.startswith('http'):
- url = "http://%s" % url
-
- loc = urlparse(url).netloc
- if loc.startswith('www.'):
- loc = loc[4:]
-
- return loc
-
-
-def adblock(url, fifo):
- fh = open(BLOCKFILE, 'r')
- lines = [line.strip() for line in fh.readlines()]
- fh.close()
-
- rules, capture = [], False
- for l in lines:
- if not l: # newline splits section
- capture = False
-
- elif l[0] == '#':
- continue
-
- elif capture:
- rules.append(l)
-
- elif l[-1] == ':':
- if get_domain(l[:-1]) == url or l[:-1] == "global":
- capture = True
-
- rulestr = repr(rules).replace("@", "\@")
- js = "js %s\n" % (JAVASCRIPT % rulestr)
- fh = open(fifo, "w")
- fh.write(js)
- fh.close()
-
-if __name__ == '__main__':
- adblock(get_domain(argv[6]), argv[4])
diff --git a/.uzbl/scripts/downloadviewer.sh b/.uzbl/scripts/downloadviewer.sh
deleted file mode 100755
index 306460d..0000000
--- a/.uzbl/scripts/downloadviewer.sh
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/bin/sh
-case "$1" in
-*.pdf*) zathura "$1" & ;;
-*.jpg*|*.png*|*.jpeg*) feh "$1" & ;;
-*.txt*|*README*|*.pl*|*.sh*|*.py*|*.hs*|*.hl*) urxvt -e vim "$1" & ;;
-*.mov*|*.avi*|*.mpeg*|*.mpg*|*.flv*|*.wmv*|*.mp4*) mplayer "$1" & ;;
-esac
diff --git a/.uzbl/scripts/url_from_surfraw.sh b/.uzbl/scripts/url_from_surfraw.sh
deleted file mode 100755
index bf3c501..0000000
--- a/.uzbl/scripts/url_from_surfraw.sh
+++ /dev/null
@@ -1,17 +0,0 @@
-#!/usr/bin/env bash
-DEFAULT_SEARCH=startpage
-string=$1
-cmd=$2
-set -- $string
-is_elvi=$(surfraw -elvi | grep -c "^$1\s")
-nbr_words=$(echo "$string" | wc -w)
-if [ "$nbr_words" -eq 1 ] && [ "$is_elvi" -eq 0 ] && ([[ "$string" == *.* ]] || [[ "$string" == *:* ]])
-then
- url="$1"
-elif [ $is_elvi -eq 1 ]
-then
- url="$(surfraw -print $string)"
-else
- url="$(surfraw -print $DEFAULT_SEARCH $string)"
-fi
-echo "$cmd $url" > $UZBL_FIFO