diff options
Diffstat (limited to '.uzbl')
-rw-r--r-- | .uzbl/config | 3 | ||||
-rwxr-xr-x | .uzbl/scripts/adblock.js | 28 |
2 files changed, 30 insertions, 1 deletions
diff --git a/.uzbl/config b/.uzbl/config index fd2cedf..2464ca7 100644 --- a/.uzbl/config +++ b/.uzbl/config @@ -453,5 +453,6 @@ set uri = uzbl.org/doesitwork/@COMMIT @bind o = sh 'uri=`$HOME/dotfiles/.uzbl/scripts/load_url_from_surfraw.sh` && echo "uri $uri" > "$UZBL_FIFO"' @on_event DOWNLOAD_COMPLETE spawn @scripts_dir/downloadviewer.sh %s -@on_event LOAD_COMMIT spawn @scripts_dir/adblock.py +# @on_event LOAD_COMMIT spawn @scripts_dir/adblock.py +# @on_event LOAD_COMMIT script @sdir/adblock.js # vim: set fdm=syntax: diff --git a/.uzbl/scripts/adblock.js b/.uzbl/scripts/adblock.js new file mode 100755 index 0000000..b581f9b --- /dev/null +++ b/.uzbl/scripts/adblock.js @@ -0,0 +1,28 @@ +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); |