On click javascript events

General discussion about the NoScript extension for Firefox
Post Reply
ghost33
Posts: 4
Joined: Sun Jan 08, 2017 10:31 pm

On click javascript events

Post by ghost33 » Sun Jan 08, 2017 10:34 pm

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.
Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:51.0) Gecko/20100101 Firefox/51.0

User avatar
Thrawn
Senior Member
Posts: 3106
Joined: Mon Jan 16, 2012 3:46 am
Location: Australia
Contact:

Re: On click javascript events

Post by Thrawn » Sun Jan 08, 2017 11:29 pm

It's possible to do this with surrogate scripts, but you'll need some JavaScript knowledge. And it will never be foolproof.
======
Thrawn
------------
Religion is not the opium of the masses. Daily life is the opium of the masses.

True religion, which dares to acknowledge death and challenge the way we live, is an attempt to wake up.
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0

barbaz
Senior Member
Posts: 9172
Joined: Sat Aug 03, 2013 5:45 pm

Re: On click javascript events

Post by barbaz » Mon Jan 09, 2017 12:09 am

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?
*Always* check the changelogs BEFORE updating that important software!
-

ghost33
Posts: 4
Joined: Sun Jan 08, 2017 10:31 pm

Re: On click javascript events

Post by ghost33 » Mon Jan 09, 2017 1:12 am

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.
Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:51.0) Gecko/20100101 Firefox/51.0

barbaz
Senior Member
Posts: 9172
Joined: Sat Aug 03, 2013 5:45 pm

Re: On click javascript events

Post by barbaz » Mon Jan 09, 2017 2:30 am

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
*Always* check the changelogs BEFORE updating that important software!
-

ghost33
Posts: 4
Joined: Sun Jan 08, 2017 10:31 pm

Re: On click javascript events

Post by ghost33 » Mon Jan 09, 2017 2:40 am

Thanks for your reply sadly it causes the popunder to load on the current tab so it's no useful.
Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:51.0) Gecko/20100101 Firefox/51.0

barbaz
Senior Member
Posts: 9172
Joined: Sat Aug 03, 2013 5:45 pm

Re: On click javascript events

Post by barbaz » Mon Jan 09, 2017 4:18 am

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)}
*Always* check the changelogs BEFORE updating that important software!
-

ghost33
Posts: 4
Joined: Sun Jan 08, 2017 10:31 pm

Re: On click javascript events

Post by ghost33 » Mon Jan 09, 2017 5:53 am

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.
Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:51.0) Gecko/20100101 Firefox/51.0

barbaz
Senior Member
Posts: 9172
Joined: Sat Aug 03, 2013 5:45 pm

Re: On click javascript events

Post by barbaz » Mon Jan 09, 2017 6:11 am

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.
*Always* check the changelogs BEFORE updating that important software!
-

Post Reply