Created
July 5, 2026 06:34
-
-
Save onetdev/27a62a04cfa99b23f56db99d1b769429 to your computer and use it in GitHub Desktop.
Generali Egészségpénztár lekötés táblázat fix (Userscript)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==UserScript== | |
| // @name Generali Egészségpénztár lekötés formázó | |
| // @namespace http://onet.dev | |
| // @version 2026-02-01 | |
| // @description A lekötéseket dátum szerint sorba rendezi, és kiírja a feloldásig hátralévő időt | |
| // @author Konrád Koller | |
| // @match https://eportal.generalipenztar.hu/Lekotesek.aspx | |
| // @icon https://www.google.com/s2/favicons?sz=64&domain=generalipenztar.hu | |
| // @grant none | |
| // ==/UserScript== | |
| (function () { | |
| 'use strict'; | |
| // Táblázat és sorok kinyerése | |
| const table = document.querySelector("#ContentPlaceHolder1_grdLekotesek"); | |
| const tbody = table.querySelector("tbody"); | |
| const rows = Array.from(tbody.querySelectorAll("tr:not(:first-child)")); | |
| const now = new Date(); | |
| // Sorok rendezése az első oszlop (dátum) alapján | |
| rows.sort((a, b) => { | |
| const dateA = new Date(a.cells[0].textContent.trim()); | |
| const dateB = new Date(b.cells[0].textContent.trim()); | |
| return dateA - dateB; | |
| }); | |
| // Visszaillesztjük a sorokat rendezett sorrendben | |
| rows.forEach(row => tbody.appendChild(row)); | |
| // Harmadik oszlop kitöltése | |
| rows.forEach(row => { | |
| const firstCellText = row.cells[0]?.textContent?.trim(); | |
| const secondCellText = row.cells[2]?.textContent?.trim(); | |
| const targetCell = row.cells[2]; // 3. oszlop | |
| if (!targetCell) return; | |
| // Ha a második cellában van érték, azt írjuk ki | |
| if (secondCellText) { | |
| targetCell.textContent = secondCellText; | |
| targetCell.style.color = ""; | |
| return; | |
| } | |
| // Ha nincs második cella érték, számolunk | |
| if (!firstCellText) return; | |
| const baseDate = new Date(firstCellText); | |
| if (isNaN(baseDate)) { | |
| targetCell.textContent = "Érvénytelen dátum"; | |
| return; | |
| } | |
| // Lekötés + 2 év | |
| const expiryDate = new Date(baseDate); | |
| expiryDate.setFullYear(expiryDate.getFullYear() + 2); | |
| const diffMs = expiryDate.getTime() - now.getTime(); | |
| const diffDays = Math.ceil(diffMs / (1000 * 60 * 60 * 24)); | |
| if (diffMs >= 0) { | |
| targetCell.textContent = `${diffDays} nap múlva`; | |
| targetCell.style.color = ""; | |
| } else { | |
| targetCell.textContent = `${Math.abs(diffDays)} napja lejárt`; | |
| targetCell.style.color = "red"; | |
| } | |
| }); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment