2 years ago
#8699
theCrabNebula
Tampermonkey waitForKeyElements on successive YouTube videos
I have a script that currently does away with those pesky "Continue watching?" prompts on YouTube, using Tampermonkey and waitForKeyElements.
However, it only seems to work if the prompt appears on the first YouTube video that I load (within the video, not between them). It doesn't seem to work for prompts on successive videos when I keep my autoplay going. When a prompt appears at the start of a new video, it doesn't seem to work at all. Here's what I'm talking about:
I've heard this could be because YouTube replaces "history state" and doesn't actually reload/change pages when going from one video to the next (please let me know if I'm wrong on this). How could I cater the following script to modern YouTube autoplay/"page changes"?
Basically, how do I get the waitForKeyElements and function to fire every single time the prompt appears when I autoplay videos for an extended period of time (whether on the first video or another)?
// ==UserScript==
// @name YouTube Yes SJ3
// @include https://www.youtube.com/*
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js
// @require https://gist.github.com/raw/2625891/waitForKeyElements.js
// @grant GM_addStyle
// ==/UserScript==
waitForKeyElements ("#confirm-button.style-scope.yt-confirm-dialog-renderer.style-blue-text.size-default:contains('Yes')", clicks);
function clicks (jNode) {
var clickEvent = document.createEvent ('MouseEvents');
clickEvent.initEvent ('click', true, true);
jNode[0].dispatchEvent (clickEvent);
console.log('SJ3');
}
javascript
google-chrome
youtube
greasemonkey
tampermonkey
0 Answers
Your Answer