forked from FroSteel/Planification
Version 4.1.14 — moveTooltip devenu no-op (popup statique)
This commit is contained in:
@@ -115,6 +115,31 @@ async function fetchFicheHtml(origin, phpsessid, formLink) {
|
||||
return html;
|
||||
}
|
||||
|
||||
// v4.1.7 : API timeline EasyVista. Renvoie le JSON des actions d'une fiche,
|
||||
// avec pour chaque action : intervenant, ACTION_ID, AM_DONE_BY_ID, description
|
||||
// complète (bien plus riche que le xhr2 tronqué).
|
||||
// Utilisé pour afficher le texte complet de l'action dans le tooltip.
|
||||
// v4.1.9 : le GUID du form est passé en paramètre (extrait dynamiquement du
|
||||
// HTML de la fiche par le viewer). Il est différent pour une demande S...
|
||||
// ({C99ECD05}) vs un incident I... ({07ED9C68}).
|
||||
async function fetchTimelineApi(origin, phpsessid, guid, formId, formChecksum) {
|
||||
// Sécurité : GUID doit être de la forme %7B...%7D ou {...}
|
||||
if (!/^(%7B|\{)[A-F0-9\-]{36}(%7D|\})$/i.test(guid)) {
|
||||
throw new Error("Invalid GUID: " + guid);
|
||||
}
|
||||
// S'assurer qu'on a la forme encodée %7B...%7D
|
||||
const encodedGuid = guid.startsWith("%7B") ? guid : `%7B${guid.replace(/[{}]/g, "")}%7D`;
|
||||
const url =
|
||||
`${origin}/api/v1/internal/forms/${encodedGuid}/timeline` +
|
||||
`?target=${encodeURIComponent(formId)}` +
|
||||
`&checksum=${encodeURIComponent(formChecksum)}` +
|
||||
`&type=todo§ionId=1&navigator=&nbRecord=0` +
|
||||
`&PHPSESSID=${encodeURIComponent(phpsessid)}`;
|
||||
const r = await fetch(url, { credentials: "include" });
|
||||
if (!r.ok) throw new Error("HTTP " + r.status);
|
||||
return await r.text();
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// Détection "session invalide"
|
||||
// ============================================================================
|
||||
@@ -183,6 +208,28 @@ chrome.runtime.onMessage.addListener((msg, sender, sendResponse) => {
|
||||
return;
|
||||
}
|
||||
|
||||
if (msg.type === "fetchTimelineApi") {
|
||||
const session = await findEasyVistaSession();
|
||||
if (!session) {
|
||||
sendResponse({ ok: false, error: "no_session" });
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const body = await fetchTimelineApi(
|
||||
session.origin, session.phpsessid,
|
||||
msg.guid, msg.formId, msg.formChecksum
|
||||
);
|
||||
if (looksLikeLoginPage(body)) {
|
||||
sendResponse({ ok: false, error: "session_expired" });
|
||||
return;
|
||||
}
|
||||
sendResponse({ ok: true, body });
|
||||
} catch (err) {
|
||||
sendResponse({ ok: false, error: String(err) });
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (msg.type === "scheduleAutoRefresh") {
|
||||
scheduleAutoRefreshAlarms();
|
||||
sendResponse({ ok: true });
|
||||
|
||||
Reference in New Issue
Block a user