// ==UserScript==
// @name Prevent malicious redirects targeting Opera users
// @author Øystein R. Ryen 
// @version 2.0
// @description  Attempts to remove malicious redirects specifically
//			targeting Opera users.
// @ujs:category general: fixes
// @ujs:published 2005-10-25 22:27
// @ujs:modified 2005-10-25 23:27
// @ujs:documentation http://userjs.org/scripts/general/fixes/redirect-opera-fixer 
// @ujs:download http://userjs.org/scripts/download/general/fixes/redirect-opera-fixer.js
// ==/UserScript==


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

window.opera.addEventListener('BeforeScript',function(e) {
  if (e.element.text.match(/(indexOf\s*\(+\s*[\"\']+[Oo]pera[\"\']+\s*\)+\s*(!=|>)\s*-1\s*)|(window.opera)/)) window['hasBeenSniffedOut¤%$'] = 1;
  if (window['hasBeenSniffedOut¤%$']) {
    e.element.text=e.element.text.replace(/(window|document|this|top)\.location(\.href|\.replace)?\s*=\s*[\'\"]+[^\'\"]*(unsupported|(old|bad|invalid|error|upp?grade)[_-]?browser|about:blank)[^\'\"]*[\'\"]+/gi,'opera.postError(\'redirect prevented (\' + location.hostname + \')\');');
  }
},false);
