From bdddde7c89f16b313c4527b74c07704ca23d2694 Mon Sep 17 00:00:00 2001 From: Guillaume Dott Date: Wed, 13 Feb 2019 14:55:57 +0100 Subject: [PATCH] Add mutation observer to Leclerc Drive script --- LeclercDrive_allergies.user.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/LeclercDrive_allergies.user.js b/LeclercDrive_allergies.user.js index 2a52152..bce6b4c 100644 --- a/LeclercDrive_allergies.user.js +++ b/LeclercDrive_allergies.user.js @@ -4,7 +4,7 @@ // @description Affiche une alerte lorsqu'un produit contient un des ingrédients interdits // @include https://*.leclercdrive.fr/* // @include http://*.leclercdrive.fr/* -// @version 0.1 +// @version 1.0 // @grant none // @require https://code.amnesix.eu/guillaume/allergies-userscripts/raw/branch/master/Allergies-1.1.js // ==/UserScript== @@ -13,5 +13,15 @@ if(ingredients != null) { Allergies.process(ingredients); } + + var product = document.querySelector('div#divContenuCentre > div'); + + if(product != null) { + var observer = new MutationObserver(function(mutations) { + var composition = document.querySelector('div#fiche-produit-composition p.accordeons-detail-paragaphe'); + Allergies.process(composition); + }); + observer.observe(product, {childList: true}); + } })();