Ignore "Video Paused, continue watching?" using XPath

This script will click on "YES" button

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

You will need to install an extension such as Tampermonkey to install this script.

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name         Ignore "Video Paused, continue watching?" using XPath
// @version      24.10.27
// @description  This script will click on "YES" button
// @author       8TM (https://github.com/8tm/youtube_video_paused_continue_watching)
// @match        https://youtube.com/*
// @match        https://www.youtube.com/*
// @match        http://youtube.com/*
// @match        http://www.youtube.com/*
// @compatible   firefox Works with Firefox and Tampermonkey
// @grant        none
// @namespace https://greasyfork.org/users/1386567
// ==/UserScript==

(function() {
    setInterval(() => {
        // Find "YES" button using XPath
        let xpath = "//div[@id='main']//div[contains(@class, 'buttons')]//yt-button-renderer[@id='confirm-button']//button";
        let result = document.evaluate(xpath, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null);
        let confirmButton = result.singleNodeValue;

        if (confirmButton && confirmButton.offsetParent !== null && !confirmButton.disabled) {
            confirmButton.click();

            // Debug:
            // let currentDateTime = new Date();
            // let formattedDateTime = currentDateTime.toLocaleString();
            // console.log(`[${formattedDateTime}] Pushed 'YES' button.`);
            // alert(`[${formattedDateTime}] Pushed 'YES' button.`);

        }
    },500);
})();