Created
November 29, 2016 09:38
-
-
Save spidgorny/a85bac003acb2477c120008f1b38463b to your computer and use it in GitHub Desktop.
SAP Learning Hub Hacks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function () { | |
function setVideoEndHandler() { | |
let iframeDocument = window | |
.frames['contentContainer'] | |
.contentDocument; | |
let video = iframeDocument.querySelector('video'); | |
if (!video) { | |
video = iframeDocument.querySelector('audio'); | |
} | |
if (video) { | |
video.addEventListener('ended', (e) => { | |
console.log('ended'); | |
let nextButton = document.querySelector('#next'); | |
//console.log(nextButton); | |
nextButton.click(); | |
setTimeout(() => { | |
setVideoEndHandler(); | |
}, 2000); | |
}); | |
console.log('Video ended event registered.'); | |
} else { | |
console.log('No video on the page. Click next to install handler.'); | |
// setTimeout(() => { | |
// setVideoEndHandler(); | |
// }, 10000); | |
let nextButton = document.querySelector('#next'); | |
nextButton.addEventListener('click', () => { | |
console.log('Next clicked'); | |
setVideoEndHandler(); | |
}); | |
} | |
} | |
setVideoEndHandler(); | |
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function setSpeed(speed) { | |
var contentFrame = window.frames['contentContainer'].contentDocument; | |
var video = contentFrame.getElementById("mediaHolder").querySelector('video'); | |
if (video) { | |
video.playbackRate = speed; | |
} | |
var audio = contentFrame.getElementById("mediaHolder").querySelector('audio'); | |
if (audio) { | |
audio.playbackRate = speed; | |
} | |
} | |
(function () { | |
var nextButton = document.querySelector('#next'); | |
console.log(nextButton); | |
nextButton.addEventListener('click', (e) => { | |
console.log('next'); | |
setTimeout(() => { | |
setSpeed(1.5); | |
}, 1000); | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment