goNextVideo

Completare la % di visione dei video

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

You will need to install an extension such as Tampermonkey to install this script.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name         goNextVideo
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  Completare la % di visione dei video
// @author       You
// @match    https://lms.pegaso.multiversity.click/videolezione/*
// @require https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js
// @icon         https://www.google.com/s2/favicons?sz=64&domain=greasyfork.org
// @grant        none
// @run-at      document-start
// @license MIT 
// ==/UserScript==
/* global $ */
(function () {
    function loopInteractive() {


        if (document.getElementById('video')) {
            var mioVideo = document.getElementById('video');
            mioVideo.muted = true;
        }
        var refreshIntervalId = setInterval(() => {
            if (document.querySelectorAll('.bg-platform-hover-light')[0].innerText === "Test di fine lezione\nEsegui") {

                var startingParent = document.querySelectorAll('.bg-platform-hover-light')[0].parentElement.parentNode.parentNode.parentNode;
                var childNodes = Array.from(startingParent.parentNode.childNodes);
                var currentIndex = childNodes.indexOf(startingParent);
                console.log(currentIndex);
                console.log("childNodes", childNodes);
                console.log(childNodes[currentIndex + 1].childNodes[0].childNodes[0]);
                if (startingParent.parentNode.childNodes[currentIndex + 1].childNodes[0].childNodes.length === 2) {
                    var nextModule = childNodes[currentIndex + 1].childNodes[0].childNodes[0].childNodes[0];
                    nextModule.click();
                    if (startingParent.parentNode.childNodes[currentIndex + 1].childNodes[0].childNodes[1].childNodes[1].children[1].children[0]) {
                        var nextLessonToClick = startingParent.parentNode.childNodes[currentIndex + 1].childNodes[0].childNodes[1].childNodes[1].children[1].children[0]
                        nextLessonToClick.click();
                        nextModule.click();
                        if (document.getElementById('video')) {
                            var mioVideo = document.getElementById('video');
                            mioVideo.muted = true;
                        }
                    }


                }

            }
            var elementSelector = document.querySelectorAll('.bg-platform-hover-light')[0];
            var matches = elementSelector.innerText.match(/(\d+)%/);
            console.log("Percentage is: ->", matches[1]);

            if (matches[1] === "100") {
                console.log("### STEP 1 ### Next video triggered")
                arrowClick = document.querySelector('#video').parentNode.childNodes[5].childNodes[0].childNodes[1].childNodes[2].childNodes[1];
                arrowClick.click();
                clearInterval(refreshIntervalId);
                console.log("### STEP 2 ### CLEANED INTERVAL")
                setTimeout(() => {
                    console.log("### STEP 3 ### TIMEOUT TRIGGERED")
                    if (document.getElementById('video')) {
                        var mioVideo = document.getElementById('video');
                        mioVideo.muted = true;
                    }
                    loopInteractive();
                }, "10000");
            }

        }, "5000");
    };
    loopInteractive();
})();