Greasy Fork is available in English.

Youtube 'Video paused. Continue watching?' Auto confirmer

Automatically clicks 'Ok' when the 'Video paused. Continue watching?' dialog pops up and pauses your videos.

< Feedback on Youtube 'Video paused. Continue watching?' Auto confirmer

Değerlendirme: İdare eder - script çalışıyor ama hataları var

§
Gönderildi: 19.08.2019
Düzenlendi: 19.08.2019

Good intention, but horrible execution

Today I woke up after browser with this masterpiece were running in background for hours and found out that YouTube tab ate completely ungodly chunk of RAM and entire PC operating from SWAP. I'm not sure it's due to this script, but it never happened to me before it, so it must be. When I were looking at it befor installing it, it felt like something is off, but I decided to leave it as-is since it wasn't malicious off. Apparently, that were a bad idea. :neutral:

Ok, the most important part: who told you it's a good idea to call any function which returns live array of nodes every 10ms? Why would you even need to run it this fast? 100~500 ms is way WAY more than enought to catch this pop-up before it stayed up for too long.

Second: Why keep running that same function again and again from within a loop? Well, beside the fact it doesn't guarantee you returning stuff in the same order even though in practice it usually do. Anyway, it's extremely inefficient to do it again and again. Just save result into a variable and re-use it from there. Something like this:

setInterval(function() {
    'use strict';
    let arr = document.getElementsByClassName('line-text style-scope yt-confirm-dialog-renderer');
    if (arr.length >= 1) {
        for (let i = 0; i < arr.length; i++) {
            if (arr[i].innerText == "Video paused. Continue watching?") {
                arr[i].parentNode.parentNode.parentNode.querySelector('#confirm-button').click()
            }
        }
    }
}, 100)();

Also, I changed it to this on my side:

(function main() {
    'use strict';
    console.log('Unpause autoconfirmer started.');
    setInterval(() => {
        for (let node of document.getElementsByClassName('line-text style-scope yt-confirm-dialog-renderer'))
            if (node.innerText == "Video paused. Continue watching?")
                node.parentNode.parentNode.parentNode.querySelector('#confirm-button').click();
    }, 500);
})();

But it may not work in very old versions of some browsers due to presence of arrow function, let operator and for...of loop.

§
Gönderildi: 20.08.2019

Updated code:

(function main() {
    'use strict';
    console.log('Unpause autoconfirmer started.');
    setInterval(function() {
        for (let node of document.querySelectorAll('.ytd-popup-container[role="dialog"]:not([style*="display: none"])'))
            if (node.style.display !== 'none' && node.textContent.contains('Video paused.')) {
                let btn = node.querySelector('#confirm-button');
                if (btn) btn.click();
            }
    }, 500);
})();

Seems like main issue with your code is not even in repeated arrays, but not checking is dialog actually visible. YouTube just hides it after confirmation and in the result your script keeps pressing confirm button every 10ms which creates flood of messages "Thank you for confirmation." in the bottom-left corner.

§
Gönderildi: 22.08.2019

node.textContent.contains threw an error in my environment.

(function main() {
    'use strict';
    console.log('Unpause autoconfirmer started.');
    setInterval(function() {
        for (let node of document.querySelectorAll('.ytd-popup-container[role="dialog"]:not([style*="display: none"])'))
            if (node.style.display !== 'none' && node.textContent.includes('Video paused.')) {
                let btn = node.querySelector('#confirm-button');
                if (btn) btn.click();
            }
    }, 500);
})();
§
Gönderildi: 23.08.2019
Düzenlendi: 23.08.2019

@Vannius Correct. Made mistake. Should be 'includes'. Thank you for the correction.

Stumbled upon this myself today when music stopped and message popped up again. Probably the most stupid part is that I actually checked which function I can use there from console and still wrote the wrong one in the script. I think I'll somehow swap these two around even if my life will depend on it. >_<

§
Gönderildi: 18.10.2019

I used a somewhat more convoluted solution:

(() => {
    'use strict';
    console.log('Unpause autoconfirmer started.');
    let interval = setInterval(() => {
        document.querySelectorAll('#confirm-button').forEach((btn) => {
            if (btn && btn.parentComponent.textContent.includes('Video paused.')) {
                clearInterval(interval);
                setInterval(() => {
                    if (btn.parentComponent.style.display !== 'none') btn.click();
                }, 100);
            }
        });
    }, 100);
})();

but then I discovered a much simpler method:

(() => {
  'use strict';
  setInterval(() => {
    window._lact = Date.now();
  }, 300000);
})();
§
Gönderildi: 30.11.2019

@Azlehria said: I used a somewhat more convoluted solution:

(() => {
    'use strict';
    console.log('Unpause autoconfirmer started.');
    let interval = setInterval(() => {
        document.querySelectorAll('#confirm-button').forEach((btn) => {
            if (btn && btn.parentComponent.textContent.includes('Video paused.')) {
                clearInterval(interval);
                setInterval(() => {
                    if (btn.parentComponent.style.display !== 'none') btn.click();
                }, 100);
            }
        });
    }, 100);
})();

but then I discovered a much simpler method:

(() => {
  'use strict';
  setInterval(() => {
    window._lact = Date.now();
  }, 300000);
})();

The latter is the best solution because of the lower cpu consumption and it doesn't fail if your youtube isn't in english which is the cause of your scripts not running in my system.

§
Gönderildi: 05.03.2020
Düzenlendi: 05.03.2020

And if you just try to block www.youtube.com/manifest.json

It's work like a charm on uBlock Origin ||www.youtube.com/manifest.json$other,domain=www.youtube.com,important

content: {"start_url":"\/","gcm_user_visible_only":true,"display":"standalone","gcm_sender_id":"402845223712","name":"YouTube"}

Cevap paylaş

Yanıt göndermek için oturum açın.