Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function isJQueryLoaded(){
- if (window.jQuery) {
- //jQuery is loaded
- alert("jQuery sucessfully loaded!");
- return true;
- } else {
- //jQuery is not loaded
- alert("jQuery doesn't work!");
- return false;
- }
- }
- //Playback counter.
- var counter = 0;
- var observer;
- function lel(){
- //isJQueryLoaded();
- //Start video if it already exists.
- let x = document.getElementsByClassName('state-paused');
- if(x[0] !== undefined){
- x[0].click();
- }
- //Run observer on site body.
- var bodyNode = document.body;
- // Create an observer instance
- observer = new MutationObserver(function (mutations) {
- mutations.every(function (mutation) {
- //console.log(mutation);
- var target = mutation.target; // Changed DOM Element.
- //If changed target contains state-paused and play-pause class (video only) , click play button.
- if(target.classList.contains('state-paused') && target.classList.contains('play-pause'))
- {
- counter++;
- console.log("Video Restarted " + counter + " times.");
- target.click();
- return false; //Cancel .every iteration.
- }
- else if(target.classList.contains('activity-button')){
- console.log(target);
- }
- });
- });
- // Configuration of the observer:
- var config = {
- attributes: true,
- characterData: true,
- childList: true,
- subtree: true,
- attributeOldValue: true,
- characterDataOldValue: true,
- attributeFilter: ['class']
- };
- // Pass in the target node, as well as the observer options
- observer.observe(bodyNode, config);
- }
- lel();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement