Original post: https://siderite.dev/blog/getting-rid-of-annoying-youtube-pause-dialog
I guess I don't have to tell you about ad blockers and browser extensions that improve YouTube. They are a dime a dozen and bring many features to the habitual YouTube watcher. However there is one particular new YouTube annoyance that you don't really need an extension to get rid of: the dreaded Video paused dialog.
To get rid of it is easy: on an interval, check if there is a visible element of a certain type containing a certain text and click its button. While this can be done in simple Javascript, I am lazy, so the script that I am using will first load jQuery, then run a one line function periodically. This code is to be copied and pasted in the Console tab of the browser's development tools, then press Enter.
const scr = document.createElement('script');
scr.setAttribute('src','https://code.jquery.com/jquery-3.4.1.min.js');
document.querySelector('head').appendChild(scr);
setInterval(()=> {
$('#button:contains(Yes)','yt-confirm-dialog-renderer:visible:contains(Video paused)').click();
},500);
It's easy to understand:
- create a script element
- set its source to jQuery
- append it to the page
- execute every 500 milliseconds a code that:
- finds the element with id button containing the text "Yes"
- inside an element of type yt-confirm-dialog-renderer which is visible and contains the text "Video paused"
- click the element
There is an even more comfortable solution, though, that I recommend. You will need a Chrome extension called cjs that loads whatever script you tell it in whatever page you want. It gives you the option to inject jQuery, so all you have to do is write
setInterval(()=> { $('#button:contains(Yes)','yt-confirm-dialog-renderer:visible:contains(Video paused)').click(); },500);
as the script to be executed on YouTube.
That's it. You're all done.
Top comments (2)
Cool, but it could be even cooler with native JavaScript.
Yeah, but then I have to reinvent :visible and :contains. Not worth it.