forked from FroSteel/Planification
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e42b145401 |
+2
-2
@@ -1,8 +1,8 @@
|
|||||||
{
|
{
|
||||||
"manifest_version": 3,
|
"manifest_version": 3,
|
||||||
"name": "Planning Techniciens — Vue claire",
|
"name": "Planning Techniciens — Vue claire",
|
||||||
"version": "4.1.3",
|
"version": "4.1.4",
|
||||||
"description": "Vue claire du planning EasyVista (itsma.etat-de-vaud.ch et itsma.vd.ch). v4.1.3 : fix ouverture intervention (tentative 3 regex retirée car elle écrasait le bon checksum avec le mauvais).",
|
"description": "Vue claire du planning EasyVista (itsma.etat-de-vaud.ch et itsma.vd.ch). v4.1.4 : fetch fiche fraîche à chaque clic (checksum pas en cache) + logging détaillé console pour diagnostiquer le checksum.",
|
||||||
"permissions": [
|
"permissions": [
|
||||||
"activeTab",
|
"activeTab",
|
||||||
"scripting",
|
"scripting",
|
||||||
|
|||||||
@@ -1978,23 +1978,16 @@ async function openInterventionInNewTab(iv, opts = {}) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let target = iv.ficheTarget;
|
let target = null;
|
||||||
let checksum = iv.ficheChecksum;
|
let checksum = null;
|
||||||
|
|
||||||
// SÉCURITÉ : si ficheTarget n'est pas égal à requestId, c'est qu'il vient
|
// v4.1.4 : on fetch TOUJOURS la fiche à la volée au clic pour extraire un
|
||||||
// d'une ancienne version (buggée) du cache. On invalide et on re-fetch.
|
// checksum FRAIS. Ne pas utiliser iv.ficheChecksum du cache : les checksums
|
||||||
if (target && target !== iv.requestId) {
|
// EasyVista peuvent expirer entre le fetch arrière-plan et le clic utilisateur.
|
||||||
console.warn("[click] ficheTarget incohérent :", target, "!=", iv.requestId, "→ re-fetch");
|
//
|
||||||
target = null;
|
// Retry automatique en cas d'échec du pattern checksum.
|
||||||
checksum = null;
|
{
|
||||||
iv.ficheTarget = null;
|
console.log("[click] fetch fiche fraîche pour iv", iv.actionId, "requestId=", iv.requestId);
|
||||||
iv.ficheChecksum = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Si pas encore fetché (ou invalidé), on fetch la fiche à la volée
|
|
||||||
// avec retry automatique en cas d'échec du pattern checksum
|
|
||||||
if (!target || !checksum) {
|
|
||||||
console.log("[click] fetch fiche à la volée pour iv", iv.actionId, "requestId=", iv.requestId);
|
|
||||||
let attempts = 0;
|
let attempts = 0;
|
||||||
const maxAttempts = 2;
|
const maxAttempts = 2;
|
||||||
while (attempts < maxAttempts && (!target || !checksum)) {
|
while (attempts < maxAttempts && (!target || !checksum)) {
|
||||||
@@ -2012,10 +2005,13 @@ async function openInterventionInNewTab(iv, opts = {}) {
|
|||||||
continue; // retry
|
continue; // retry
|
||||||
}
|
}
|
||||||
// Extraire le checksum lié au requestId précis
|
// Extraire le checksum lié au requestId précis
|
||||||
const rx = new RegExp(`target=${iv.requestId}&(?:amp;)?checksum=([a-f0-9]{40})`);
|
const rx = new RegExp(`target=${iv.requestId}&(?:amp;)?checksum=([a-f0-9]{40})`, 'g');
|
||||||
const m = ficheResp.html.match(rx);
|
const allMatches = [...ficheResp.html.matchAll(rx)];
|
||||||
if (!m) {
|
console.log(`[click] Trouvé ${allMatches.length} occurrence(s) de target=${iv.requestId}&checksum=... dans HTML de la fiche (taille ${ficheResp.html.length})`);
|
||||||
console.warn(`[click] tentative ${attempts}: pattern target=${iv.requestId} introuvable dans HTML (taille ${ficheResp.html.length})`);
|
allMatches.forEach((m, idx) => console.log(` [${idx}] checksum = ${m[1]}`));
|
||||||
|
|
||||||
|
if (allMatches.length === 0) {
|
||||||
|
console.warn(`[click] tentative ${attempts}: pattern target=${iv.requestId} introuvable`);
|
||||||
if (attempts >= maxAttempts) {
|
if (attempts >= maxAttempts) {
|
||||||
alert("Impossible de trouver le checksum pour cette fiche (après retry).");
|
alert("Impossible de trouver le checksum pour cette fiche (après retry).");
|
||||||
return;
|
return;
|
||||||
@@ -2024,8 +2020,11 @@ async function openInterventionInNewTab(iv, opts = {}) {
|
|||||||
await new Promise(r => setTimeout(r, 300));
|
await new Promise(r => setTimeout(r, 300));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
// On prend le PREMIER checksum trouvé (comme avant, comportement v4)
|
||||||
target = iv.requestId;
|
target = iv.requestId;
|
||||||
checksum = m[1];
|
checksum = allMatches[0][1];
|
||||||
|
console.log(`[click] checksum retenu: ${checksum}`);
|
||||||
|
// On stocke aussi en cache pour accélérer le prochain clic (au cas où)
|
||||||
iv.ficheTarget = target;
|
iv.ficheTarget = target;
|
||||||
iv.ficheChecksum = checksum;
|
iv.ficheChecksum = checksum;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@@ -2037,7 +2036,8 @@ async function openInterventionInNewTab(iv, opts = {}) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Construire l'URL qui fonctionne (format v3/v4)
|
// Construire l'URL qui fonctionne (format identique à l'URL manuelle qui
|
||||||
|
// marche dans le navigateur quand on ouvre une fiche depuis l'UI EasyVista).
|
||||||
const internalurltime = Math.floor(Date.now() / 1000);
|
const internalurltime = Math.floor(Date.now() / 1000);
|
||||||
const url =
|
const url =
|
||||||
`${session.origin}/index.php` +
|
`${session.origin}/index.php` +
|
||||||
|
|||||||
Reference in New Issue
Block a user