Skip to content

Instantly share code, notes, and snippets.

@GhostTypes
Created February 23, 2025 22:29
Show Gist options
  • Select an option

  • Save GhostTypes/5ba569fa4f0fe770c09bfb83c1d3d5a1 to your computer and use it in GitHub Desktop.

Select an option

Save GhostTypes/5ba569fa4f0fe770c09bfb83c1d3d5a1 to your computer and use it in GitHub Desktop.
Speed up video playback (1.5x) and automatically advance all slides
If you have a brain, passing the tests at the end is no issue, however **you are responsible** to know the things you should.
(function() {
// Set video speed whenever a new video loads
function setVideoSpeed() {
const videoPlayer = videojs.getPlayer('gcn-video-player');
if (videoPlayer) {
videoPlayer.off('ratechange');
videoPlayer.playbackRate(1.5);
videoPlayer.playbackRate = function(rate) {
if (rate !== undefined) {
this.tech_.setPlaybackRate(rate);
return this;
}
return this.tech_.playbackRate();
};
}
}
function checkAndAdvance() {
const nextButton = document.querySelector('.tut-slides-next');
const currentSlideElem = document.querySelector('#current-slide');
// Check for the submit button
if (!nextButton || !currentSlideElem) {
setVideoSpeed();
setTimeout(checkAndAdvance, 1000);
return;
}
// Make sure it's clickable (indicates the slide is complete)
if (!nextButton.disabled && !nextButton.classList.contains('disabled')) {
let currentSlide = parseInt(currentSlideElem.textContent, 10);
let nextSlideElem = document.querySelector(`.tut-slides-item[data-slide-rank='${currentSlide + 1}']`);
if (!nextSlideElem) {
console.log('Reached the last slide!!');
return;
}
if (nextSlideElem) {
console.log(`Finished slide ${currentSlide} -> slide ${currentSlide + 1}`);
nextButton.dispatchEvent(new Event('click', { bubbles: true }));
setTimeout(checkAndAdvance, 1000);
} else {
console.log('No next slide found??');
return;
}
} else {
console.log('Next button is not available??');
setTimeout(checkAndAdvance, 1000);
}
}
// Start the process
checkAndAdvance();
})();(function() {
// Set video speed whenever a new video loads
function setVideoSpeed() {
const videoPlayer = videojs.getPlayer('gcn-video-player');
if (videoPlayer) {
videoPlayer.off('ratechange');
videoPlayer.playbackRate(1.65);
videoPlayer.playbackRate = function(rate) {
if (rate !== undefined) {
this.tech_.setPlaybackRate(rate);
return this;
}
return this.tech_.playbackRate();
};
}
}
function checkAndAdvance() {
const nextButton = document.querySelector('.tut-slides-next');
const currentSlideElem = document.querySelector('#current-slide');
// Check for the submit button
if (!nextButton || !currentSlideElem) {
setVideoSpeed();
setTimeout(checkAndAdvance, 1000);
return;
}
// Make sure it's clickable (indicates the slide is complete)
if (!nextButton.disabled && !nextButton.classList.contains('disabled')) {
let currentSlide = parseInt(currentSlideElem.textContent, 10);
let nextSlideElem = document.querySelector(`.tut-slides-item[data-slide-rank='${currentSlide + 1}']`);
if (!nextSlideElem) {
console.log('Reached the last slide!!');
return;
}
if (nextSlideElem) {
console.log(`Finished slide ${currentSlide} -> slide ${currentSlide + 1}`);
nextButton.dispatchEvent(new Event('click', { bubbles: true }));
setTimeout(checkAndAdvance, 1000);
} else {
console.log('No next slide found??');
return;
}
} else {
console.log('Next button is not available??');
setTimeout(checkAndAdvance, 1000);
}
}
// Start the process
checkAndAdvance();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment