// ==UserScript== // @name VUT elerning fix // @namespace http://tampermonkey.net/ // @version 1.0 // @description Disables animation of presentations // @author KAJIK // @match https://moodle.vut.cz/* // @updateURL https://karlserver.mooo.com/files/download.php?file=.%2FVUT+elerning+fix-1.0.user.js // @grant none // ==/UserScript== (function() { 'use strict'; // Function to simulate a full user interaction function simulateFullClick(element) { // Create and dispatch 'mousedown' event const mousedownEvent = new MouseEvent('mousedown', { bubbles: true, cancelable: true, view: window }); element.dispatchEvent(mousedownEvent); // Create and dispatch 'mouseup' event const mouseupEvent = new MouseEvent('mouseup', { bubbles: true, cancelable: true, view: window }); element.dispatchEvent(mouseupEvent); // Create and dispatch 'click' event const clickEvent = new MouseEvent('click', { bubbles: true, cancelable: true, view: window }); element.dispatchEvent(clickEvent); } // Function to set the progress bar to maximum function setProgressBarToMax() { const progressBar = document.querySelector('.progressbar__progress'); const thumb = document.querySelector('.progressbar__thumb'); if (progressBar && thumb) { // Get the width of the progress bar const progressBarRect = progressBar.getBoundingClientRect(); const maxX = progressBarRect.right; // Far right of the progress bar const minX = progressBarRect.left; // Far left of the progress bar // Simulate dragging the thumb to the maximum position const mousedownEvent = new MouseEvent('mousedown', { bubbles: true, cancelable: true, clientX: minX, clientY: progressBarRect.top + (progressBarRect.height / 2) }); thumb.dispatchEvent(mousedownEvent); const mousemoveEvent = new MouseEvent('mousemove', { bubbles: true, cancelable: true, clientX: maxX, clientY: progressBarRect.top + (progressBarRect.height / 2) }); thumb.dispatchEvent(mousemoveEvent); const mouseupEvent = new MouseEvent('mouseup', { bubbles: true, cancelable: true, clientX: maxX, clientY: progressBarRect.top + (progressBarRect.height / 2) }); thumb.dispatchEvent(mouseupEvent); } } // Function to check the button and click if aria-pressed is true function checkButton() { const button = document.querySelector('.universal-control-panel__button.universal-control-panel__button_play-pause'); if (button) { const ariaPressed = button.getAttribute('aria-pressed'); if (ariaPressed === 'true') { simulateFullClick(button); // Set progress bar to maximum after play/pause interaction setTimeout(() => { setProgressBarToMax(); }, 500); } } } // Monitor changes to the button using a MutationObserver const observer = new MutationObserver((mutationsList) => { for (const mutation of mutationsList) { if (mutation.type === 'attributes' && mutation.attributeName === 'aria-pressed') { checkButton(); } } }); // Wait for the button to appear in the DOM function waitForButton() { const button = document.querySelector('.universal-control-panel__button.universal-control-panel__button_play-pause'); if (button) { // Observe the button for attribute changes observer.observe(button, { attributes: true }); // Initial check checkButton(); } else { setTimeout(waitForButton, 1000); } } // Start the initial check waitForButton(); })();