返回首頁 

DSVV ERP ATTENDANCE HIGHLIGHTER - dsvv.ac.in

Add some styling to your boring attendance


Install this script?
  1. // ==UserScript==// @name DSVV ERP ATTENDANCE HIGHLIGHTER - dsvv.ac.in// @namespace Violentmonkey Scripts// @include https://erp.dsvv.ac.in/StudentAttendance/MyAttendanceReport*// @require https://cdn.jsdelivr.net/npm/chart.js@4.4.0/dist/chart.umd.min.js// @grant none// @version 1.0// @author sharadcodes// @description Add some styling to your boring attendance// @license MIT// ==/UserScript==if (document.querySelector("#content > div:nth-child(1) > div > div > div:nth-child(1) > span.rlbv").innerText === "MCA-III-SEM") {var tables = Array.from(document.querySelectorAll("table")).slice(3);tables = tables.filter((table) => !table.parentNode.classList.contains("innerfooter"));tables.forEach((table) => {table.querySelectorAll("tr td:not(.col-1)").forEach((td) => {if ((td.innerText.split("P").length > 0 ||td.innerText.split("A").length > 0 ||td.innerText.split("T").length > 0 ||td.innerText.split("L").length > 0) &&!td.classList.contains("col-1") &&td.innerText.length > 0) {console.log(td.innerHTML);if (td?.innerText?.includes("P")) {td.style.background = "lawngreen";} else if (td?.innerText?.includes("A")) {td.style.background = "pink";} else if (td?.innerText?.includes("T")) {td.style.background = "orange";} else if (td?.innerText?.includes("L")) {td.style.background = "cyan";}}});});// Get all the elements with class "col-6"var fractions = document.querySelectorAll("#content > div:nth-child(1) > table > tbody > tr > td");fractions = Array.from(fractions).slice(0, fractions.length - 6);generatePercentageAndChart(fractions);// Get all the elements with class "col-6"fractions = document.querySelectorAll("#content > div:nth-child(2) > table > tbody > tr > td");generatePercentageAndChart(fractions);fractions = document.querySelectorAll("#content > div:nth-child(3) > table > tbody > tr > td");fractions = Array.from(fractions).slice(0, fractions.length - 1);generatePercentageAndChart(fractions);}// Loop through each element and add a percentage calculation to the corresponding "percentage" cellfunction generatePercentageAndChart(fractions) {fractions.forEach(function (fraction) {// Extract the numerator and denominator from the text of the fraction cellvar numerator = parseFloat(fraction.textContent.split("/")[0]);var denominator = parseFloat(fraction.textContent.split("/")[1]);// Calculate the percentagevar percentage = (numerator / denominator) * 100;// Create a new text node with the percentage valuevar percentageNode = document.createTextNode(" Per: " + percentage.toFixed(2) + "%");fraction.appendChild(percentageNode);// Create a new div element to hold both the pie chart and the percentage textvar container = document.createElement("div");// Create a canvas for the pie chartvar chartCanvas = document.createElement("canvas");chartCanvas.style.maxWidth = "150px";chartCanvas.style.width = "150px";chartCanvas.style.height = "auto";container.appendChild(chartCanvas);// Append the container to the fraction elementfraction.appendChild(container);// Create a pie chart inside the chartCanvasnew Chart(chartCanvas, {type: "bar",data: {labels: ["Present", "Absent"],datasets: [{data: [numerator, denominator - numerator], // Calculate the remaining percentagebackgroundColor: ["#0f0", "#f00"],},],},options: {responsive: true, // Set chart to be responsivemaintainAspectRatio: false, // Disable aspect ratio to fill widthplugins: {legend: {display: false,},},},});});}