Greasy Fork is available in English.

Средний балл СФ УУНиТ

Отображение среднего балла в журнале СФ УУНиТ

// ==UserScript==
// @name         Средний балл СФ УУНиТ
// @namespace    https://github.com/WolfySoCute
// @version      0.4.1
// @description  Отображение среднего балла в журнале СФ УУНиТ
// @author       Wolfy
// @match        *://account.struust.ru/Journals/DisciplineGrades/*
// @match        *://account.strbsu.ru/Journals/DisciplineGrades/*
// @icon         https://account.struust.ru/favicon.ico
// @grant        none
// @license      GNU GPLv3
// ==/UserScript==

(function() {
    'use strict';

    const journalNode = document.querySelector(".journal-student");
	const grades = [];

	if (journalNode) {
		for (const tr of journalNode.getElementsByTagName('tr')) {
			const gradeNode = tr.getElementsByClassName('journal-student-central')[2];
			if (gradeNode) {
				const grade = gradeNode.textContent.split(' / ');
				if (!isNaN(parseFloat(grade[0]))) grades.push(...grade.map(parseFloat));
			}
		}

		if (grades.length){
			const sum = grades.reduce((partialSum, a) => partialSum + Number(a), 0);
			const newTr = document.createElement('tr');
			newTr.innerHTML = `<td colspan="3" class="journal-student-central"><strong>Средний балл:</strong></td><td class="journal-student-central">${(sum / grades.length).toFixed(2)}</td>`;

			journalNode.firstElementChild.appendChild(newTr);
		}
	}
})();