Getting rid of Youtube Music's "Are you still listening?" dialog

Tutorials

Youtube Music is a great way to listen for music for free, and with no adverts if you use an adblocker. There is one annoying problem however: after listening for a while, Youtube will keep pausing the music to show a dialog which says “Are you still listening?”. This article will show how to automatically confirm the dialog.

First, you need to install a plugin to allow running custom JavaScript on web pages. I used Greasemonkey/Tampermonkey (Firefox | Chrome), it seems to be the most popular plugin for this task.

Open up the plugin’s menu, and click “new user script”. Open up the menu again, select the script and click “edit”. Paste the following code as the source:

// ==UserScript==
// @name     Youtube Music Listening Clicker
// @version  1
// @grant    none
// ==/UserScript==

setInterval(() => {
  if (!document.querySelector("paper-dialog.ytmusic-popup-container").getAttribute("aria-hidden"))
    document.querySelector(".ytmusic-you-there-renderer .style-blue-text .size-default").click();
}, 1000);

console.log("Youtube Music Listening Clicker loaded")

Save and go back to the plugin’s menu, select the script, and click “User script options”. Add “music.youtube.com” to the scripts include textbox and check “Only use these” below.

Reload youtube music if you have it open. Enjoy no more annoying dialogs!

Please note: the music may still pause for a second or so if the tab isn’t focused, due to Firefox/Chrome limiting JavaScript in the backend. There’s no real fix for this. One way to reduce the dialog from appearing at all is to just play another playlist when the dialog first appears, otherwise it will just keep asking.