Moodle AutoConnect

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

当前为 2024-11-19 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Moodle AutoConnect
// @namespace    https://t.me/johannmosin
// @version      0.1.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
            }
        }, 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();
    }
})();