AARP - Go To Next Video

trying to skip to the next video during the AARP driver-ed class

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         AARP - Go To Next Video
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  trying to skip to the next video during the AARP driver-ed class
// @author       You
// @license  MIT
// @match        https://app.aarpdriversafety.org/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=aarpdriversafety.org
// @grant        none
// @require http://code.jquery.com/jquery-3.5.1.min.js
// ==/UserScript==
/* globals jQuery, $, waitForKeyElements */

(function() {
    'use strict';
    const wait = 5000; // 5 seconds
    var counter = 0;

    setInterval(function(){
        const currentUrl = window.location.href;
        // we are in the table of contents page
        if(currentUrl.indexOf('/dash/index') > 0) {
            console.log('going to the next section');
            // go to the next available section
            $("div[data-test='currentIcon'] div.gritIcon__wrap").click();
        }
        const video = document.querySelector("video");
        if(video) {
            console.log('hello video');
            video.muted = true;
            video.play();
            video.pause();
            video.currentTime = video.duration; // go to the end of the video

            const isDisabled = $('#arrow-next').is(":disabled");
            if (!isDisabled) {
                let arrow = $('.icon.gritIcon--arrow-forward');
                arrow.click();
            }
        } else {
            console.log('hello: ' + counter);
            const timer = $('div.isTimer span.children div').text();
            if (timer == "00:00") {
                let arrow = $('.icon.gritIcon--arrow-forward');
                arrow.click();
                counter++;
                console.log('goodbye: ' + counter);
            }
    }
    }, wait);
})();