unstoppable onBlur

in Script development
Subscribe to unstoppable onBlur 17 posts, 5 voices



scriptonator User

Hello, thats html that i decided to hook:

<html><head>
window.onblur=function()
{
alert('try to block me!');
}
</head><body></body></html>

I've made 2 scripts, 1st doesnt work at all, so here only 2nd:

// ==UserScript==
// @name test2
// @include *
// ==/UserScript==

function newblur() {

event.stopPropagation();
event.preventDefault();
}

window.addEventListener('blur', newblur, true);

HTMLFormElement.prototype._blur = HTMLFormElement.prototype.blur;
HTMLFormElement.prototype.blur = newblur;

This script works partially (hooks something, like alt+tab defocusing, but still being vulnerable by defocusing with mouse click).

Whats wrong, how complitely disable blur event?

 
JoeSimmons Scriptwright
FirefoxWindows

unsafeWindow.onblur = null;

 
scriptonator User

Thanks Joe, but now the opposite situation
"it hooks defocusing by internal mouse clicking, but vulnerable to external alt+tab" :)

 
JoeSimmons Scriptwright
FirefoxWindows

im not understanding you. what else do you need?

 
scriptonator User

Just to avoid alert window at ANY situation like mouseclicks, alt+tabs, etc(fully disable onblur event):

<html><head>
window.onblur=function()
{
alert('try to block me!');
}
</head><body></body></html>

Maybe there is a way to replace source code with greasemonkey?
Like replacing "window.onblur" with some trash "window.jikjikblur"

 
JoeSimmons Scriptwright
FirefoxWindows

my code above stops that. there must be something else doing it. whats the page?

 
scriptonator User

Tested with firefox 3.0.1 & 3.5.8 and greasemonkey 0.8.20100211.5 (when doing alt+tab and then back to the browser - nasty alert still appears).

The "test page" is exactly what I had written in previous post, running as file://

 
JoeSimmons Scriptwright
FirefoxWindows

works fine on my test page. by the way, your page code doesnt even work. i used that exact code and it showed the function as text on my page.

 
scriptonator User

Tested also on 3.6, the same :(
Didnt saw, forum obfuscated script tag, so i will replace it with "<sript>"...

<html><head>
<sript>
    window.onblur=function()
    {   
	alert('try to block me!');
    }
</sript>
</head><body></body></html>

What browser version do you use?</sript>

 
scriptonator User
FirefoxWindows

Look, I also made new - replacing script.
But it doesnt replacing inside "head" tag. I guess some mistake with "/head/*" ?

// ==UserScript==
// @name           antiblur
// @include        *
// ==/UserScript==
textNodes = document.evaluate(
  "/head/*",
  document,
  null,
  XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
  null);
var searchRE = new RegExp('onblur','gi');
var replace = 'fuckblur';
for (var i=0;i<textNodes.snapshotLength;i++) {
  var node = textNodes.snapshotItem(i);
  node.data = node.data.replace(searchRE, replace);
}

 
Avindra V.G. Scriptwright
FirefoxWindows

Replacing or removing text within script tags achieves nothing in terms of scripting. Additionally, /head/ is wrong because the document starts with html, so you should use /html/head/.

 
Marti Scriptwright
FirefoxX11

scriptonator wrote:
...
var allNodes = document.evaluate(
  "/head/*",
  document.documentElement,
  null,
  XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
  null
);
...
This should work with the existing logic and is more accurate on usage of document.evaluate... AVG's comment is correct within that contextNode. You might need this too.

 
scriptonator User
SafariMacintosh

So must I return to unsuccessful disabling "window.onblur event" by hooking it instead of replacing?

 
scriptonator User
FirefoxWindows

nobody knows? :(
How to disable all nasty activity of such code
(sript = script)

<html><head>
<sript>
    window.onblur=function()
    {   
	alert('try to block me!');
    }
</sript>
</head><body></body></html>

 
JoeSimmons Scriptwright
FirefoxWindows

scriptonator wrote:
nobody knows? :(

How to disable all nasty activity of such code
unsafeWindow.onblur = null;
this works perfectly fine. u must be doing something wrong
 
LouCypher Scriptwright
ChromeWindows

scriptonator wrote:
The "test page" is exactly what I had written in previous post, running as file://
...and have you set fileIsGreaseable to true in about:config?
 
scriptonator User

LouCypher, can I kiss you :D
JoeSimmons thanks, now works!

Cross
Presentational HTML allowed.
Use <code> for inline code and <pre> for code blocks. Use &lt; and &gt; for literal < and >.
We help break paragraphs and link your links.
or cancel