Skip to content

Comment on Ask HN: Is YouTube using a dark pattern to prevent background playlist play?

Comments

I haven't experienced this specifically on YouTube, but you may be talking about the Page Visibility API [0]. I've tried to disable it natively in Firefox and Chrome (without extensions) but with no avail. It can even tell if I switch desktops in i3wm. Here's two demos [1][2]. I'm guessing it's saving $$$ on bandwidth. I just want the option to turn it off.

[0] https://www.w3.org/TR/page-visibility-2/

[1] http://daniemon.com/tech/webapps/page-visibility/

[2] https://testdrive-archive.azurewebsites.net/Performance/Page...

I quickly did something like this for Twitch, seems to work:

    document.hasFocus = function() {
      return true;
    }
    Object.defineProperty(document, 'hasFocus', {value: true})
    
    document.hidden = function() {
      return false;
    }
    //Object.defineProperty(document, 'hidden', {value: false})
    Object.defineProperty(document, "hidden", {get: function() { return false; }
    });
    
    document.webkitHidden = function() {
      return false;
    }
    Object.defineProperty(document, 'webkitHidden', {value: false})
    
    document.addEventListener("focus", function(e) {
      e.stopPropagation();
      e.stopImmediatePropagation();
      e.preventDefault();
      return false;
    }, true);
    
    document.addEventListener("visibilitychange", function(e) {
      e.stopPropagation();
      e.stopImmediatePropagation();
      e.preventDefault();
      return false;
    }, true);

The pause button make sense, force users to focus on the page briefly every now and then to save bandwidth - Netflix does something similar to prevent long running auto-play.

The looping is quite different though, there's no legitimate use for it, and I can't find any controls that would allow you to set a song to auto-repeat. So it's either a bug that they're struggling to fix or an intentional change to make play-lists less functional when you are not watching the platform.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.