Skip to content

Instantly share code, notes, and snippets.

@henno
Last active June 10, 2024 12:20
Show Gist options
  • Save henno/5522650e4ded1a396259d5cd89728487 to your computer and use it in GitHub Desktop.
Save henno/5522650e4ded1a396259d5cd89728487 to your computer and use it in GitHub Desktop.
Tampermonkey: Stuudium - päeviku vaates lahtrid rohelised/punased heade/halbade sissekannete puhul
// ==UserScript==
// @name Stuudium õpetaja - päeviku vaates värvilised lahtrid
// @namespace http://tampermonkey.net/
// @version 2024-06-06
// @description try to take over the world!
// @author You
// @match https://torvakool.ope.ee/journal/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=ope.ee
// @grant none
// ==/UserScript==
(function () {
'use strict'
const studentRows = document.querySelectorAll('.student_row')
const headerCells = document.querySelectorAll('thead th.summary'); // Get all header cells
studentRows.forEach((row) => {
// Tooltip handling
const maCells = row.querySelectorAll('td[data-notes]:has(span.grade_MA)')
maCells.forEach((maCell) => {
const maExplanation = document.createElement('span')
maExplanation.textContent = maCell.getAttribute('data-notes')
maExplanation.classList.add('tooltip')
maCell.appendChild(maExplanation)
})
const allCellsInTheRow = row.querySelectorAll('td');
// Iterate over header cells and corresponding student cells
headerCells.forEach((headerCell, index) => {
const description = headerCell.querySelector('abbr')?.getAttribute('title');
const studentCell = allCellsInTheRow[index];
if (description && studentCell) {
console.log(description)
console.log(studentCell)
console.log('---')
studentCell.classList.add('has_notes');
studentCell.setAttribute('data-notes', description); // Set the description as data-notes
window.jQuery('td.has_notes:not(.active)').tipsy({
title: 'data-notes',
gravity: 'e',
delayIn: 200,
delayOut: 0,
live: true
});
}
});
const cellsWithMAorNotCompleted = row.querySelectorAll('td:has(span.grade_MA), td:has(span.grade_param_is_not_completed)')
const cellsWithAR = row.querySelectorAll('td:has(span.grade_AR)')
// Set the background color of cells with MA or not completed to pink
cellsWithMAorNotCompleted.forEach((cell) => {
cell.style.backgroundColor = 'pink'
})
// Set the background color of cells with AR to green
cellsWithAR.forEach((cell) => {
cell.style.backgroundColor = 'lightGreen'
})
})
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment