// ==UserScript==
// @name Disable script
// @author TarquinWJ 
// @namespace http://www.howtocreate.co.uk/ 
// @version 1.0
// @description  Attempts to prevent the page from running any scripts
//			of its own, while still allowing you to run
//			User JavaScripts.
// @ujs:category browser: enhancements
// @ujs:published 2005-05-30 20:32
// @ujs:modified 2005-09-19 09:19
// @ujs:documentation http://userjs.org/scripts/browser/enhancements/disable-script 
// @ujs:download http://userjs.org/scripts/download/browser/enhancements/disable-script.js
// ==/UserScript==


/* 
 * Please see
 * http://www.howtocreate.co.uk/operaStuff/userJavaScript.html#terms
 * for License and Terms of Use
 */

//this one will interfere with bookmarklets if you use them - you have been warned
window.opera.addEventListener( 'BeforeJavascriptURL', function (e) { e.preventDefault(); }, false );

window.opera.addEventListener( 'BeforeScript', function (e) { e.preventDefault(); }, false );
window.opera.addEventListener( 'BeforeExternalScript', function (e) { e.preventDefault(); }, false );
window.opera.addEventListener( 'BeforeEventListener', function (e) { if(!e.listener.toString().match(/^\s*function\s+\w*ujsenabled/i)) { e.preventDefault(); } }, false );

document.addEventListener('load',function ujsenabledNoscript() {
	for( var i = 0, j = document.getElementsByTagName('noscript'); j[i]; i++ ) {
		var nstag = document.createElement('wasnoscript');
		j[i].parentNode.insertBefore(nstag,j[i]);
		while( j[i].childNodes[0] ) { nstag.appendChild(j[i].childNodes[0]); }
	}
},false);