// ==UserScript==
// @name Block unwanted scripts
// @author Albu Emil 
// @namespace http://userjs.org/ 
// @version 1.0.1
// @description  Selectively blocks scripts that cause problems on
//			specific Web pages.
// @ujs:category general: enhancements
// @ujs:published 2005-09-04 20:07
// @ujs:modified 2005-09-19 09:19
// @ujs:documentation http://userjs.org/scripts/general/enhancements/block-unwanted-scripts 
// @ujs:download http://userjs.org/scripts/download/general/enhancements/block-unwanted-scripts.js 
//
// add here the sites where you DO want the ads to show up (use this
// to override the "include"s below)
// @exclude http://good.example.com/*
// @exclude http://*.good.example.com/*
// @exclude http://bad.example.com/specialPage.html
//
// add here the sites where you DO NOT want the ads to show up
// @include http://bad.example.com/*
// @include http://*.bad.example.com/*
//
// ==/UserScript==


/* 
 * This script is granted to the Public Domain.
 */

// add a new event listener for "BeforeExternalScript" (this is called each time before an external script is called)
window.opera.addEventListener( 'BeforeExternalScript', function (e) {
	var addAdr = new Array(

		// the list of script adresses we want to "ignore" - in regular expression format
		// - commas after all except the last one

		/^http:\/\/ads\.example\.com\//,
		/^http:\/\/banners\.example\.com\//,
		/^http:\/\/images\.example\.com\/ads\//,
		/^http:\/\/\w*\.server1\.example\.com\//

	);

	// compare with each adress, and see if it matches
	for( var aa = 0; addAdr[aa]; aa++ ) {
		// if it matches, skip it
		if( e.element.getAttribute('src').match(addAdr[aa]) ) {
			e.preventDefault();
		}
	}

}, false );
