Moodle AutoAttendance

Автоматически отмечает посещяемость в одноимённом элементе Moodle.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Moodle AutoAttendance
// @namespace    https://t.me/johannmosin
// @version      1.0.0
// @description  Автоматически отмечает посещяемость в одноимённом элементе Moodle.
// @author       Johann Mosin
// @match        https://edu.vsu.ru/mod/attendance/*
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    var intervalId = setInterval(function() {
        var submitButton = document.querySelector('input[type="submit"][value="Сохранить"].btn.btn-primary');

        if (submitButton) {
            var radioInput = document.querySelector('input[type="radio"].form-check-input[name="status"]');
            if (radioInput) {
                radioInput.click();
                submitButton.click();
                clearInterval(intervalId);
            }
        } else {
            var attendanceTd = Array.from(document.querySelectorAll('td')).find(td => td.textContent.includes("Отметить свое присутствие"));

            if (attendanceTd) {
                var attendanceLink = attendanceTd.querySelector('a');
                if (attendanceLink) {
                    window.location.href = attendanceLink.href;
                    clearInterval(intervalId);
                }
            } else {
                setTimeout(() => {
                    location.reload();
                }, 10000);
            }
        }
    }, 1000);
})();