The War On Right Clicks



  • I came across this page:

    I should probably pop over to the compulsive behaviors topic, since I highlight and right click the shit out of nearly every web page I read. In Chrome (Linux Version 62.0.3202.62 (Official Build) (64-bit)) when I right click, I get an alert:

    0_1508766618351_1ff2973d-2bc2-4f0f-8398-bf4cde3e38ee-image.png

    And then after I dismiss it, the menu comes up as normal:

    0_1508766666631_a39c135d-8ec6-4ff7-a61b-48b45911a553-image.png



  • With Chrome on Windows the menu only pops up if you hold right click and dismiss the alert with the keyboard. So I guess it "works" if you do it normally. Also, the context menu key works without any issue.



  • @hungrier Ah, then a window manager quirk.


  • Grade A Premium Asshole

    When I was maybe 13 years old, me and a bunch of friends all built our own shitty websites on some free hosting and we all used a bit of JS to show an alert on right click to stop everyone else from stealing our stuff (saving images, etc). Obviously it was trivial to work around, but hey, we were kids.


  • kills Dumbledore



  • @jaloopa said in The War On Right Clicks:

    Right click, then dismiss the alert with escape. It takes you to a squarespace login page

    I just get the menu. It seems that ESC itself does that when on the page.



  • @jaloopa Looks like it works just by pressing esc on the page.

    :hanzo:'d



  • Which reminds me of this annoying "feature" of Tom's Hardware. The first visit of each day, hijack any click on a link (be left, right or middle) to pop up a box asking to sign up for their newsletter, then load the article in the current tab after dismissing the box.



  • @hungrier I miss Opera 12... you could just disable javascript and do whatever you wanted without the scripts getting in the way.


  • SockDev

    @anonymous234 but so much of the web is just JS these days :(



  • Ugh. Really, wouldn't this be a good use for an API? I know that cluttering the browser with useless APIs is stupid, but a lot of websites want to do this, and only a very few should be allowed to. It seems like a good candidate for an API.

    This site is requesting permission to override the default right click menu.

    Allow Deny this time Always deny for www.fuckface.nut



  • @blek said in The War On Right Clicks:

    When I was maybe 13 years old, me and a bunch of friends all built our own shitty websites on some free hosting and we all used a bit of JS to show an alert on right click to stop everyone else from stealing our stuff (saving images, etc). Obviously it was trivial to work around, but hey, we were kids.

    Until about 6 months ago, The Sun newspaper (thesun.co.uk) still fucking did this, a national newspaper with daily readership in the millions.

    They're a bunch of scumbags, though, and have been since...ohh, about the 15th of April, 1989.



  • @arantor Worse, it seems like browsers actually implement their interface stuff in JS. If you pause the execution in the debugger in chrome you can't right click or scroll at all, even on a static website.



  • @thegoryone said in The War On Right Clicks:

    ohh, about the 15th of April, 1989.

    Let me guess: this is the date it started.


  • SockDev

    @khudzlin no, it's in reference to the Hillsborough disaster (it was a football stadium where there was a massive human crush and 96 people died) and The Sun had an article entitled 'THE TRUTH' about what happened, which ultimately was to blame the fans rather than, well, anything else.

    To this day, Liverpool supporters hate The Sun, and not unreasonably so.


  • SockDev

    This post is deleted!


  • @anonymous234 said in The War On Right Clicks:

    @arantor Worse, it seems like browsers actually implement their interface stuff in JS. If you pause the execution in the debugger in chrome you can't right click or scroll at all, even on a static website.

    I would have guessed that JS runs in the same thread as the interface. Which kind of makes sense.



  • @anonymous234 said in The War On Right Clicks:

    @arantor Worse, it seems like browsers actually implement their interface stuff in JS. If you pause the execution in the debugger in chrome you can't right click or scroll at all, even on a static website.

    In Firefox, not only does hitting :pause_button: in the debugger still let me scroll (but only by rolling the scroll wheel on my mouse), but it doesn't even stop the "14 out of 16" up at the top from updating as I do. :wtf:

    It does, however, completely disable everything else on the page -- including the composer's textarea. It even stops CSS from activating/deactivating for :hover...

    Also, even though right-clicking the page doesn't do anything, pressing still opens the menu (and if some element had focus, it does target it like it should).



  • @arantor said in The War On Right Clicks:

    @khudzlin no, it's in reference to the Hillsborough disaster (it was a football stadium where there was a massive human crush and 96 people died) and The Sun had an article entitled 'THE TRUTH' about what happened, which ultimately was to blame the fans rather than, well, anything else.

    Yup, this.

    I'm a Forest fan married to a Liverpool fan, the two teams present that day. There is understandably not a lot of love for the Sun in our house. Especially when it turned out that fault was ultimately with stadium management not preventing overcrowding & the police response making the crush worse.

    IIRC Stephen Gerrard (former England & Liverpool FC captain) lost a cousin that day



  • @boomzilla said in The War On Right Clicks:

    @hungrier Ah, then a window manager quirk.

    Not sure — in Safari under macOS, I also get the “function disabled” popup, and when I close that using the mouse, the right-click menu appears at the location I originally right-clicked at.



  • @hungrier said in The War On Right Clicks:

    With Chrome on Windows the menu only pops up if you hold right click and dismiss the alert with the keyboard. So I guess it "works" if you do it normally. Also, the context menu key works without any issue.

    I tend to dismiss alerts by pressing the Escape key, so I'm very confused as to why that apparently means "redirect to SquareSpace login".



  • Got one of those buggers on a blog. Quickly fired up tampermonkey and patched that listener oput by straightforwardly nulling it. (implementing that as a fix on all sites isn't a good idea since some pages legitimately "catch" right clicks like google docs to provide a more contextual context menu


  • Dupa

    @boomzilla said in The War On Right Clicks:

    @anonymous234 said in The War On Right Clicks:

    @arantor Worse, it seems like browsers actually implement their interface stuff in JS. If you pause the execution in the debugger in chrome you can't right click or scroll at all, even on a static website.

    I would have guessed that JS runs in the same thread as the interface. Which kind of makes sense.

    It shouldn’t, in Chrome. AFAIR, it used to in Firefox but they changed that recently?


  • Dupa

    @thegoryone said in The War On Right Clicks:

    IIRC Stephen Gerrard (former England & Liverpool FC captain) lost a cousin that day

    Man, was that a great player!

    Steven Gerrard - Top 20 Legendary Goals |HD| – 04:40
    — Anfield Legend



  • @khudzlin said in The War On Right Clicks:

    @thegoryone said in The War On Right Clicks:

    ohh, about the 15th of April, 1989.

    Let me guess: this is the date it started.

    No. 1989 would be the Hillsborough Disaster, I believe.

    But they weren't exactly angels before that either. Consider their oh-so-kindly headline in 1982: "Gotcha!" and what exactly that referred to. And a host of other things.





  • @anonymous234 said in The War On Right Clicks:

    @hungrier I miss Opera 12... you could just disable javascript and do whatever you wanted without the scripts getting in the way.

    I've got a Firefox (but soon, Pale Moon only) extension for 1-click javascript disabling: QuickJava. In fact, it was one of the first* extensions I downloaded.

    *Even if even the second-to-last is technically one of the first, I think it was within the first five.



  • Worse is the war on middle clicks. Youtube has this annoying implementation in the playlist view where clicking exactly on the video works fine, but clicking on the whitespace (which is also set up as a link) turns into a left click. It's an extremely small difference, JS wise (window.location = x vs window.open(x)).



  • @sumireko said in The War On Right Clicks:

    Worse is the war on middle clicks. Youtube has this annoying implementation in the playlist view where clicking exactly on the video works fine, but clicking on the whitespace (which is also set up as a link) turns into a left click. It's an extremely small difference, JS wise (window.location = x vs window.open(x)).

    That'd be one of those extremely small differences that's all the difference in the world, right?



  • @steve_the_cynic said in The War On Right Clicks:

    @sumireko said in The War On Right Clicks:

    Worse is the war on middle clicks. Youtube has this annoying implementation in the playlist view where clicking exactly on the video works fine, but clicking on the whitespace (which is also set up as a link) turns into a left click. It's an extremely small difference, JS wise (window.location = x vs window.open(x)).

    That'd be one of those extremely small differences that's all the difference in the world, right?

    Yes



  • I wrote a greasemonkey script.

    This is pretty hacky, but so far, it seems to work...

    // ==UserScript==
    // @name        Right Click API
    // @namespace   localhost
    // @include     *
    // @version     1
    // @grant       unsafeWindow
    // @grant       GM_getValue
    // @grant       GM_setValue
    // @run-at      document-idle
    // ==/UserScript==
    
    try {
      var permitted = JSON.parse(GM_getValue('permitted', '[]'));
      var denied = JSON.parse(GM_getValue('denied', '[]'));
      var h = location.host;
    
      var eventId = '';
      for (var eventId = '', i = 0; i < 32; ++ i) {
        eventId += String.fromCharCode(Math.floor(Math.random() * 95) + 32);
      }
    
      window.addEventListener(eventId, function (event) {
        try {
          var p = JSON.parse(GM_getValue('permitted', '[]')).filter(e => e != h);
          var d = JSON.parse(GM_getValue('denied', '[]')).filter(e => e != h);
    
          if (event.detail !== undefined) {
            if (event.detail) p.push(h);
            else d.push(h);
          }
    
          GM_setValue('permitted', JSON.stringify(p));
          GM_setValue('denied', JSON.stringify(d));
        } catch (e) {
          console.error(e);
        }
      });
    
      permitted = permitted.indexOf(h) >= 0;
      denied = denied.indexOf(h) >= 0;
    
      if (permitted || denied) {
        console.log(`The Right Click API status for this site (${h}) is currently ${permitted ? 'PERMITTED' : 'DENIED'}.
    
    To force a re-prompt, execute RightClick.requestPermission() from the script console.
    The status can also be cleared by executing RightClick.unrequestPermission().
    Permission can only be requested (or unrequested) once per page load.`);
      }
    
      unsafeWindow.eval(`(${function (permitted, denied, eventId) {
        try {
          var requested = false;
    
          window.RightClick = {
            requestPermission: function requestPermission() {
              if (requested) {
                throw 'Permission has already been requested. Reload the page before trying again.';
    
              } else {
                requested = true;
    
                var h = location.host;
                var permission = confirm(`Will you allow ${h} to modify the default right-click action?`);
                permitted = permission;
                denied = !permission;
    
                window.dispatchEvent(new CustomEvent(eventId, {detail: permitted}));
    
                return {then: success_fn => { if (permitted) success_fn(); }};
              }
            },
    
            unrequestPermission: function unrequestPermission() {
              if (requested) {
                throw 'Permission has already been requested. Reload the page before trying again.';
    
              } else {
                requested = true;
                window.dispatchEvent(new CustomEvent(eventId, {detail: undefined}));
              }
            }
          };
    
          function setTraps() {
            var alert_fn = window.alert;
            window.alert = function alert() {
              RightClick.requestPermission();
            };
            setTimeout(() => window.alert = alert_fn, 0);
          }
    
          var buttonGetter = Object.getOwnPropertyDescriptor(MouseEvent.prototype, 'button');
          var button_get_fn = buttonGetter.get;
          buttonGetter.get = function button() {
            var button = button_get_fn.call(this);
            if (button & 2 && !permitted) {
              if (denied) button = button ^ 2;
              else setTraps();
            }
            return button;
          };
          Object.defineProperty(MouseEvent.prototype, 'button', buttonGetter);
    
          var whichGetter = Object.getOwnPropertyDescriptor(UIEvent.prototype, 'which');
          var which_get_fn = whichGetter.get;
          whichGetter.get = function which() {
            var which = which_get_fn.call(this);
            if (which == 3 && !permitted) {
              if (denied) which = 0;
              else setTraps();
            }
            return which;
          };
          Object.defineProperty(UIEvent.prototype, 'which', whichGetter);
    
          var cancelableGetter = Object.getOwnPropertyDescriptor(Event.prototype, 'cancelable');
          var cancelable_get_fn = cancelableGetter.get;
          cancelableGetter.get = function cancelable() {
            return this.button & 2 && denied ? false : cancelable_get_fn.call(this);
          }
          Object.defineProperty(Event.prototype, 'cancelable', cancelableGetter);
    
          var preventDefault_fn = Event.prototype.preventDefault;
          Event.prototype.preventDefault = function preventDefault() {
            if (this.button & 2 && (!permitted || denied)) {
              if (!denied) RightClick.requestPermission().then(preventDefault_fn.bind(this));
            } else preventDefault_fn.call(this);
          }
    
          // manually trigger a right-click event, to see if the page will tip its hand...
          document.dispatchEvent(new MouseEvent('mousedown', {button:2,buttons:2,which:3}));
    
        } catch (e) {
          console.error(e);
        }
      }})`)(permitted, denied, eventId);
    
    } catch (e) {
      console.error(e);
    }
    

Log in to reply
 

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.