Page 1 of 2

(windows).mouseleave(function() {

Posted: Fri Jul 24, 2015 11:26 pm
by Smorgen
Hey,

I find this function highly annoying; (windows).mouseleave(function() {
How can we block this? What is does is pop up a window with register, subscribe to newsletter ect....
You can see it on http://www.geektime.com for example. Click on any article, then move your mouse to top of screen and it appears. It's very popular these days.

/Smorgen

Re: (windows).mouseleave(function() {

Posted: Sat Jul 25, 2015 12:44 am
by barbaz
If you can't just disable JS on the site, create a surrogate script that blocks the mouseleave event from being sent.

Untested, but a starting point:

replacement:

Code: Select all

window.addEventListener("mouseleave", function(e){e.stopImmediatePropagation();}, false);
sources:

Code: Select all

@.geektime.com

Re: (windows).mouseleave(function() {

Posted: Sat Jul 25, 2015 5:42 am
by Smorgen
It's not only that site, it's a lot of them. Can you do a *.com, *.net etc...?

Re: (windows).mouseleave(function() {

Posted: Sat Jul 25, 2015 5:48 am
by Smorgen
I'm retarded when it comes to these kinds of things.....where do I add that?
Coding is like rocket science to me, it just doesn't compute....

Re: (windows).mouseleave(function() {

Posted: Sat Jul 25, 2015 5:55 pm
by barbaz
Smorgen wrote:It's not only that site, it's a lot of them. Can you do a *.com, *.net etc...?
Sure.. here's a sources value for all .com & .net:

Code: Select all

@^https?://[^/:]+\.(?:com|net)[/:]
Smorgen wrote:where do I add that?
go to about:config, right-click > new > string
name: noscript.surrogate.nomouseleave.replacement
value: replacement from above
right-click > new > string
name: noscript.surrogate.nomouseleave.sources
value: sources value from above

(you can change the "nomouseleave" to be anything you want as long as it's the same in the replacement & sources pref names)

Re: (windows).mouseleave(function() {

Posted: Sat Jul 25, 2015 9:45 pm
by Smorgen
You are a genius!!

Re: (windows).mouseleave(function() {

Posted: Sat Jul 25, 2015 10:32 pm
by barbaz
Thanks for the positive feedback and glad it helped! :D

Re: (windows).mouseleave(function() {

Posted: Sun Jul 26, 2015 10:14 pm
by Thrawn
barbaz wrote:

Code: Select all

@^https?://[^/:]+\.(?:com|net)[/:]
Why the (?: before the TLD?

Re: (windows).mouseleave(function() {

Posted: Sun Jul 26, 2015 10:49 pm
by barbaz
Thrawn wrote:Why the (?: before the TLD?
Habit of mine to use non-capturing parentheses when not needing to capture the contents.

Re: (windows).mouseleave(function() {

Posted: Mon Jul 27, 2015 12:54 am
by Thrawn
Simpler approach is to use a URL Matcher:

Code: Select all

@.com .net

Re: (windows).mouseleave(function() {

Posted: Mon Jul 27, 2015 1:09 am
by barbaz
Er, I kind of didn't know that was possible for TLDs Image
Thanks.

Re: (windows).mouseleave(function() {

Posted: Mon Jul 27, 2015 3:04 am
by Thrawn
I believe URL matchers just do a text match, so they don't care whether it's a TLD.

Re: (windows).mouseleave(function() {

Posted: Thu Aug 13, 2015 7:55 am
by Smorgen
Some sites still has the mouseleave. I checked and they are .com or .net. Strange....

Re: (windows).mouseleave(function() {

Posted: Thu Aug 13, 2015 5:13 pm
by barbaz
3 things I can think to try:
1) change the "false" to true
2) add also listener for "mouseout" event

Code: Select all

window.addEventListener("mouseleave", function(e){e.stopImmediatePropagation();}, false);window.addEventListener("mouseout", function(e){e.stopImmediatePropagation();}, false);
3) stopPropagation as well as stopImmediatePropagation (actually, I'm not sure if it's already fully covered by stopImmediatePropagation or not... but in case not...)

Code: Select all

window.addEventListener("mouseleave", function(e){e.stopImmediatePropagation();e.stopPropagation();}, false);
If none of those works, can you please provide a URL?

Re: (windows).mouseleave(function() {

Posted: Fri Aug 14, 2015 11:57 pm
by Smorgen
It works!
It was this site; http://www.supercompressor.com/ if you want to check it yourself.

Thanks a lot!

/Smorgen