Wire the seam end to end: the background mirrors config.local.json into storage (a content script would need web_accessible_resources, which would expose the email to the mairie page), and the content script lays the computed values into the form. The layer is deliberately thin and untested: all the logic lives in formulaire-valeurs.js. It never writes an empty value, never touches the image, the honeypots or the CSRF tokens, and never submits: a human reads and sends. A banner states what is left to do, and warns when a field could not be filled, so that a silent failure stays diagnosable. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
30 lines
1.4 KiB
JavaScript
30 lines
1.4 KiB
JavaScript
// Listener enregistré au niveau racine (synchrone) : l'event page peut être
|
|
// déchargée, le clic toolbar doit toujours la réveiller et être capté.
|
|
browser.action.onClicked.addListener(() => {
|
|
browser.tabs.create({ url: browser.runtime.getURL("liste.html") });
|
|
});
|
|
|
|
// C'est le background qui lit config.local.json, pas le content script : ce
|
|
// dernier ne pourrait le faire que via web_accessible_resources, ce qui
|
|
// exposerait l'email à la page de la mairie. Il la reçoit par le storage.
|
|
//
|
|
// Le fichier est OPTIONNEL (absent d'un clone frais), donc impossible à
|
|
// déclarer dans un tableau `js` du manifest — Firefox refuserait d'installer
|
|
// l'extension. D'où fetch + repli : absent ou JSON invalide → {} → défauts nus,
|
|
// jamais d'exception.
|
|
async function chargerConfigLocale() {
|
|
let locale = {};
|
|
try {
|
|
const reponse = await fetch(browser.runtime.getURL("config.local.json"));
|
|
if (reponse.ok) locale = await reponse.json();
|
|
} catch {
|
|
console.warn("Écho du Huit : config.local.json illisible, défauts utilisés.");
|
|
}
|
|
await browser.storage.local.set({ [globalThis.EchoConfig.CLE_CONFIG_LOCALE]: locale });
|
|
}
|
|
|
|
// À chaque réveil de l'event page, et pas seulement à l'installation : le
|
|
// fichier peut avoir changé depuis, le storage doit refléter le disque.
|
|
chargerConfigLocale();
|
|
browser.runtime.onInstalled.addListener(chargerConfigLocale);
|