6

i'm looking for a conclusive, 100%-effective way to block this latest hideous trend of marketers and scammers alike. you'll be familiar with it yourself - it's a very easy way to tell whether or not to trust a website if it flags up a warning like this when you try and navigate away:

"are you sure?" spam

i'm aware some sites use this benevolently - even superuser does it when attempting to close the browser - but i hate it. if i close a tab it's because i want it closed. i do NOT appreciate my browser second-guessing my choices. if there is a way to kill this, i expect it to kill superuser's implementation of it as well.

there are more than a few userscripts that aim to kill this, and i'll post them here. all of them refuse to work with a certain link, which i'll also post, which renders them moot immediately.

https://chrome.google.com/webstore/detail/let-me-out/hnfdibcbmlppjlkefinedeffoiomlecc/reviews?utm_campaign=en&utm_source=en-et-na-us-home&utm_medium=et

https://userscripts.org/scripts/show/98260

https://userscripts.org/scripts/show/187713

here's the site that somehow manages to overcome any protection against it:

http://as.sexad.net/as/pu?p=adc

(PLEASE NOTE: this is a dangerous site! do NOT visit it if you are not protected with an anti-virus, if you're running an obsolete web browser, if you have java installed, etc., etc. it WILL attempt to mislead you. also, be aware it has a penchant for playing awful music immediately upon loading at full volume so best to put the mute on.)

the above site will either load something about free sex videos or, more often, a video sharing site trying to be youtube. this evades any "block onunload" script i throw at it. you can also try posting a reply to this topic (i tried commenting, but that didn't cause the dialogue, so try answering, which i can't yet) and then closing your browser - superuser do the same thing, for their sins.

thanks for any suggestions. let's kill this user-hostile nonsense for good.

8
  • You could whitelist javascript for only those sites you want it to run on, which would essentially solve this problem.
    – Paul
    Feb 15, 2014 at 22:07
  • whitelisting javascript strikes me as an incredibly overreaching solution to tackle one annoyance. i shouldn't have to alter my entire browsing experience to accommodate some injurious design decisions.
    – seagull
    Feb 15, 2014 at 22:09
  • You are actually describing two annoyances. One is a straightforward "onunload", which can be countered with the userscript you provide. The other is "what if that doesn't work". Nefarious sites will use a range of techniques to subvert control of your browser. You may find an approach with the site example provided, but that doesn't mean it will work with the next site that obfuscates its methods. Whitelisting javascript managers generally involve a one-click per site you frequent, so it is quick to get back to where you were beforehand, but now with protection.
    – Paul
    Feb 15, 2014 at 22:30
  • i really don't want to go down the route of "guilty until proven innocent", but it's certainly something to consider. thanks.
    – seagull
    Feb 15, 2014 at 22:32
  • 1
    I hope all web browser makers allow users to control which sites can show the alert() and "are you sure to leave" as modal popup. These just leave spammers great ways to exploit users. Not only spammers, but dumb web developers in my country excessively use alert() for stupid things like "You are logged in." Jan 15, 2015 at 22:30

2 Answers 2

0

There are actually two ways to see the dialog you mention.

Only one of them is marketing spam. The sure-fire way to block that is to us NoScript or an equivalent that blocks JavaScript.

The other way you get it is, in fact, legitimate and helpful. You get it if you try and navigate away from a page where you have been adding content. This very site is a good example. If I'm halfway through typing and answer and I decide not to bother, I get a warning asking me if I am sure I want to leave. That's good!

8
  • 2
    i address this in my initial post. i don't believe it's good; i see it as an annoyance. i detest it. i wish to block them both conclusively.
    – seagull
    Feb 15, 2014 at 22:36
  • For the 2nd part, if you havent edited anything on the page, it shouldn't be triggered. You can test this on SuperUser. I think the behaviour is baked into all browsers so you are unlikely to avoid it without some serious hacking. For the 1st issue, NoScript will always block the behaviour. Feb 15, 2014 at 22:45
  • 2
    "serious hacking" is what i come to superuser for. i want a blanket ban on this sort of behaviour because i find it user-hostile and unnecessary. if i've closed the browser, the browser should close. questions regarding operation are neither here nor there; i wish for the behaviour never to manifest itself, not for a way to alter myself to ensure i never run into it.
    – seagull
    Feb 15, 2014 at 22:47
  • 2
    i'm not asking google to remove the feature, i'm asking if anyone knows a way to circumvent it. i think you've made this issue a little more personal than it ought to be.
    – seagull
    Feb 15, 2014 at 23:20
  • 1
    @seagull, I feel your pain and agree 1000%. Sadly, I can't offer a perfect solution. I've used chrome.google.com/webstore/detail/alert-control/… myself. It unfortunately breaks ALL alert boxes but for me personally, I'd prefer all alerts to be broken over having onbeforeunload alerts. NOTHING is more infuriating than disobedient software. If I have a tab and I close it, I don't care if the popup is a genuine and real message: "Closing this tab will make you forfeit your entire bank balance." I clicked the X and I expect that tab to CLOSE. Nov 6, 2015 at 4:36
0
  1. Install TamperMonkey

  2. Create a new script with the following text:

// ==UserScript==
// @name Disable Leave Page
// @namespace http://www.greasespot.net/
// @include *

// ==/UserScript==

location.href = "javascript:(" + function() {
  window.onbeforeunload = null;
  window.onunload = null;
} + ")()";

With a little fiddling you should be able to get it to work.

2
  • interesting - i'll give it a go, cheers!
    – seagull
    Feb 19, 2014 at 15:51
  • hi -- this doesn't work on either superuser or the spam site posted above. sorry.
    – seagull
    Feb 19, 2014 at 16:52

Not the answer you're looking for? Browse other questions tagged .