From b6ceb1f6521bf6d6068c8dac0e7610919a59d039 Mon Sep 17 00:00:00 2001 From: Luigi D'Acunto Date: Sat, 7 Jun 2025 19:46:46 +0200 Subject: [PATCH] Aggiorna la versione a 1.1.002 e migliora la regex per il matching dei codici corso, aggiungendo un link per aprire la pagina del corso nella modale. --- CHANGELOG.md | 3 ++- tampermonkey-script/GAIA-Swissknife.user.js | 23 ++++++++++++++------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bf3d4de..874882c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,8 @@ # 🧰 GAIA Swissknife – Changelog -## v1.1.001 - 2025-06-07: +## v1.1.002 - 2025-06-07: - Modificata regex per il matching dei codici corso, compatibile con i codici che contengono spazi +- Aggiunto link per aprire la pagina del corso nella modale dove compaiono i corsi rilevati ## v1.1.0 – 2025-04-09 - Refactoring in funzioni modulari diff --git a/tampermonkey-script/GAIA-Swissknife.user.js b/tampermonkey-script/GAIA-Swissknife.user.js index fca02d4..ba70f3c 100644 --- a/tampermonkey-script/GAIA-Swissknife.user.js +++ b/tampermonkey-script/GAIA-Swissknife.user.js @@ -5,7 +5,7 @@ // @downloadURL https://luigidacunto.com/scripts/gaia-swissknife/tampermonkey-script/GAIA-Swissknife.user.js // @changelogURL https://luigidacunto.com/scripts/gaia-swissknife/tampermonkey-script/CHANGELOG.md // @author Luigi D'Acunto -// @version 1.1.001 +// @version 1.1.002 // @description Aggiunge funzionalità alle pagine di GAIA // @match https://gaia.cri.it/* // @require https://code.jquery.com/jquery-3.6.0.min.js @@ -413,7 +413,7 @@ GM_addStyle(GM_getResourceText("DataTablesCSS")); if ($corsoLink.length === 0) return; // blocco non relativo a richiesta corso const corsoText = $corsoLink.text().trim(); - const match = corsoText.match(/([A-Z]{3,}\/\d{4}\/[A-Z]+(?: [A-Z]+)?\/\d+)/); + const match = corsoText.match(/([A-Z]{3,}\/\d{4}\/[A-Z]+(?: [A-Z]+)?\/\d{4,})/); if (!match) return; const codiceCorso = match[1]; @@ -427,6 +427,7 @@ GM_addStyle(GM_getResourceText("DataTablesCSS")); codice: codiceCorso, nome, id: idMatch[1], + linkCorso: $corsoLink.attr("href"), $panel }); } @@ -445,11 +446,16 @@ GM_addStyle(GM_getResourceText("DataTablesCSS"));
📋 Richieste trovate:
- ${corsiUnici.map(c => { - const count = richieste.filter(r => r.codice === c).length; - const plural = count === 1 ? "richiesta" : "richieste"; - return `• ${c} – ${count} ${plural}`; - }).join("
")} + ${corsiUnici.map(c => { + const matching = richieste.filter(r => r.codice === c); + const count = matching.length; + const plural = count === 1 ? "richiesta" : "richieste"; + const courseUrl = matching[0]?.linkCorso ? `https://gaia.cri.it${matching[0].linkCorso}` : null; + const label = courseUrl + ? `${c} – ${count} ${plural}` + : `${c} – ${count} ${plural}`; + return `• ${label}`; + }).join("
")}