Page 1 of 1

On click javascript events

Posted: Sun Jan 08, 2017 10:34 pm
by ghost33
Could you add an option to block all javascript on click events? or the option to block all javascript popups and have a whitelist with it as well. Most pages specially those that stream are using this method to force the opening of popups and sometimes it gets crazy and 5+ popups open at once everytime you click.

Re: On click javascript events

Posted: Sun Jan 08, 2017 11:29 pm
by Thrawn
It's possible to do this with surrogate scripts, but you'll need some JavaScript knowledge. And it will never be foolproof.

Re: On click javascript events

Posted: Mon Jan 09, 2017 12:09 am
by barbaz
ghost33 wrote:or the option to block all javascript popups and have a whitelist with it as well. Most pages specially those that stream are using this method to force the opening of popups and sometimes it gets crazy and 5+ popups open at once everytime you click.
Have you tried using an addon that's designed to block popups, such as uBlock Origin?

Re: On click javascript events

Posted: Mon Jan 09, 2017 1:12 am
by ghost33
Yes it does not work for that it can close the pop up once they open and load a page but it cant prevent it from opening. They supposedly were going to be able to block something like that but I haven't seen it happening.

Re: On click javascript events

Posted: Mon Jan 09, 2017 2:30 am
by barbaz
Er, actually uBlock Origin *does* block the pop-up from loading. It's only the opening of the new window that it can't prevent.


Does this surrogate script work? (not tested)

replacement

Code: Select all

Object.defineProperty(window, 'open', {enumerable:true,get:function(){return function(){}}});
sources is @ followed by the list of sites you don't want opening popups. For example -

Code: Select all

@.example.net .example.com

Re: On click javascript events

Posted: Mon Jan 09, 2017 2:40 am
by ghost33
Thanks for your reply sadly it causes the popunder to load on the current tab so it's no useful.

Re: On click javascript events

Posted: Mon Jan 09, 2017 4:18 am
by barbaz
This one should literally block the click listeners, but you may lose wanted functionality.

Code: Select all

for(let et of ['click', 'mousedown', 'mouseup']){window.addEventListener(et, function(e){e.stopPropagation();e.stopImmediatePropagation()}, true)}

Re: On click javascript events

Posted: Mon Jan 09, 2017 5:53 am
by ghost33
Could you do one or two to block all javascript that opens an other tab or window on the foreground or background?

The block all on mouse events takes away the ability to click on the player to see the video which is the reason I'm on those pages.

Re: On click javascript events

Posted: Mon Jan 09, 2017 6:11 am
by barbaz
ghost33 wrote:Could you do one or two to block all javascript that opens an other tab or window on the foreground or background?
Given that neutering window.open() produced undesirable results, that would require extensively digging through the individual websites' code. I don't have time for that, sorry.