There is a website which fires a function on when the tab is blurred. I don't want that to happen.
Is there a way I can stop javascript from firing window.onBlur event?
From initial search, I have come to the conclusion that I need to override the default function of javascript, which can be done using userscript managers like Greesemonkey.
I tried the following script in Greesemonkey:
window.onblur = null
This doesn't seem to have any effect and the webpage behaves same as previously.
-
if it's just for you, you can set an event breakpoint in devtools. you can also edit the js in devtools, running the site off your patch once you locate the event handler in code.dandavis– dandavis2018-11-02 16:52:20 +00:00Commented Nov 2, 2018 at 16:52
-
2You've rejected userscript managers with no explanation of why you're unable to use them, when this is the solution you should use. You can't edit the script of an arbitrary page without some kind of plugin that allows you to inject script.user229044– user229044 ♦2018-11-02 16:53:31 +00:00Commented Nov 2, 2018 at 16:53
-
@meagar: chrome let's you do just that in devtool's sources tab. new since 67-ish iircdandavis– dandavis2018-11-02 16:55:06 +00:00Commented Nov 2, 2018 at 16:55
-
@meagar the language of question wasn't clear enough. I do not know how to do it using user script manager too. Please have a look at edited question.Shubham Chaudhary– Shubham Chaudhary2018-11-02 17:20:22 +00:00Commented Nov 2, 2018 at 17:20
-
No. It's impossible to do this (automatically) without an extension. You have to either use Tampermonkey or write your own extension. The question also needs a minimal reproducible example and/or a link to the target page.Brock Adams– Brock Adams2018-11-02 18:37:50 +00:00Commented Nov 2, 2018 at 18:37
|
Show 1 more comment
1 Answer
Have look at Event.preventDefault() and Event.stopPropagation() if it helps your case.
If you would like to override the function which is called on the event, you can simply redefine it and insert it using a script manager. For example:
var originalCallbackFunction = callbackFuntion;
callbackFunction = function() { // Redefinition
/* Do something else */
}