Make any Acellus Video Unpaused (Flawed)

Unpauses the video when changing tabs on Acellus ;)

2024-04-26 يوللانغان نەشرى. ئەڭ يېڭى نەشرىنى كۆرۈش.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         Make any Acellus Video Unpaused (Flawed)
// @namespace    https://greasyfork.org/en/users/1291009
// @version      1.0
// @description  Unpauses the video when changing tabs on Acellus ;)
// @author       BadOrBest
// @license      MIT
// @icon         https://www.google.com/s2/favicons?sz=64&domain=acellus.com
// @match        https://admin192c.acellus.com/student/*
// @grant        none
// @grant        GM_addStyle
// @grant        GM_setValue
// @grant        GM_getValue
// @grant        GM_deleteValue
// @run-at       document-end
// ==/UserScript==

(function() {
    'use strict';

    // Function to unpause media elements
    function unpauseMedia() {
        // Select all video, audio, and Plyr elements
        var mediaElements = document.querySelectorAll('video, audio, .plyr');

        // Loop through each media element and unpause it
        mediaElements.forEach(function(mediaElement) {
            // Check if the media is paused
            if (mediaElement.paused) {
                // Unpause the media
                mediaElement.play();
            }
        });
    }

    // Function to set aggressive unpause interval
    function setUnpauseInterval() {
        // Clear any existing interval
        clearInterval(window.unpauseInterval);

        // Set new interval
        window.unpauseInterval = setInterval(unpauseMedia, 1000); // Change the interval as needed
    }

    // Set aggressive unpause interval initially
    setUnpauseInterval();

    // Event listener for tab visibility change
    document.addEventListener('visibilitychange', function() {
        // If tab is visible, reset the interval
        if (!document.hidden) {
            setUnpauseInterval();
        }
    });
})();