Youtube Music - Non-Stop

Automatically dismisses the "Video paused. Continue watching?" prompt on YouTube Music.

// ==UserScript==
// @name           Youtube Music - Non-Stop
// @namespace      Youtube Music - Non-Stop
// @license        MIT
// @version        1.2.0
// @description    Automatically dismisses the "Video paused. Continue watching?" prompt on YouTube Music.
// @icon           https://www.gstatic.com/youtube/media/ytm/images/applauncher/music_icon_48x48.png
// @grant          none
// @author         Holome-FT
// @homepage       https://gist.github.com/Holome-FT/
// @match          https://music.youtube.com/*
// ==/UserScript==

(() => {
    'use strict';

    new MutationObserver(() => {
        const popupNode = document.querySelector("ytmusic-popup-container > tp-yt-paper-dialog > ytmusic-you-there-renderer");
        const popupStringNode = popupNode?.querySelector("yt-formatted-string")
        const popupbuttonNode = popupNode?.querySelector("div.ytmusic-you-there-renderer > yt-button-renderer > yt-button-shape > button");

        if (!popupStringNode || !popupStringNode.textContent.includes("Video paused. Continue watching?")) return ;
        if (!popupbuttonNode) return ;

        popupbuttonNode.click();
        console.info("Youtube Music - Non-Stop");
    }).observe(document.body, { childList: true, subtree: true });
})();