Moodle AutoConnect

Автоматически присоединяется к конференциям на Moodle

تثبيت هذا البرنامج النصي؟
سكربت موصى به للمؤلف

ربما يعجبك أيضا Moodle AutoPilot.

تثبيت هذا البرنامج النصي

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 or Violentmonkey 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.

ستحتاج إلى تثبيت إضافة مثل Stylus لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتتمكن من تثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

(لدي بالفعل مثبت أنماط للمستخدم، دعني أقم بتثبيته!)

// ==UserScript==
// @name         Moodle AutoConnect
// @namespace    https://t.me/johannmosin
// @version      0.1.2.1
// @description  Автоматически присоединяется к конференциям на Moodle
// @author       Johann Mosin
// @match        https://edu.vsu.ru/mod/bigbluebuttonbn/view.php?*
// @match        https://*.edu.vsu.ru/html5client/join?sessionToken=*
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    // Function to handle "bigbluebuttonbn" pages
    function handleBigBlueButtonPage() {
        const checkInterval = setInterval(() => {
            console.log("Checking for session link...");
            const sessionLink = Array.from(document.querySelectorAll('a')).find(td => td.textContent.includes("Подключиться к сеансу"));
            if (sessionLink) {
                const href = sessionLink.href;
                console.log("Found session link:", href);
                window.open(href, '_blank');
                clearInterval(checkInterval); // Stop checking
            } else {location.reload();}
        }, 10000);
    }

    // Function to handle "html5client" pages
    function handleHtml5ClientPage() {
        const buttonInterval = setInterval(() => {
            console.log("Checking for buttons...");
            const joinButton = document.querySelector('button[aria-label="Только слушать"]');
            if (joinButton) {
                joinButton.click();
                console.log("Clicked button: Только слушать");
            }
            const connectButton = document.querySelector('button[aria-label="Проиграть звук"]');
            if (connectButton) {
                connectButton.click();
                console.log("Clicked button: Проиграть звук");
                clearInterval(buttonInterval); // Stop checking
            }
        }, 2000);
    }

    // Main logic to determine which handler to use
    if (window.location.href.includes("bigbluebuttonbn")) {
        console.log("Detected bigbluebuttonbn page.");
        handleBigBlueButtonPage();
    } else if (window.location.href.includes("html5client")) {
        console.log("Detected html5client page.");
        handleHtml5ClientPage();
    }
})();