first commit

master
Guillaume Dott 2019-02-13 14:20:08 +01:00
commit c8696b9bfa
3 changed files with 84 additions and 0 deletions

51
Allergies-1.1.js 100644
View File

@ -0,0 +1,51 @@
var Allergies = {};
Allergies.allergenes = [
'miel',
'paprika',
'piment',
'poivre de cayenne',
'poivron',
'chorizo',
'carvi',
'cumin',
'curry',
'anis',
'camomille',
"cire d'abeille",
'e160c',
'e901',
'celeri',
'céleri'
];
Allergies.process = function(element) {
var found = Allergies.check_allergenes(element.textContent);
if(found.length > 0) {
element.insertBefore(Allergies.warning(found), element.firstChild);
}
};
Allergies.check_allergenes = function(text) {
var lower_text = text.toLowerCase();
return Allergies.allergenes.filter(function(allergene) { return lower_text.indexOf(allergene) >= 0 });
};
Allergies.warning = function(found) {
var div = document.createElement('div');
var warning_message = document.createElement('p');
warning_message.style.color = '#F00';
warning_message.style.fontSize = '3em';
warning_message.style.fontWeight = 'bold';
warning_message.textContent = "ATTENTION";
div.appendChild(warning_message);
var message = document.createElement('p');
message.textContent = "Ce produit contient les allergènes suivants : " + found.join(', ');
message.style.fontSize = '18px';
message.style.marginTop = '0';
div.appendChild(message);
return div;
};

View File

@ -0,0 +1,13 @@
// ==UserScript==
// @name Cora Drive allergies
// @namespace http://amnesix.eu
// @description Affiche une alerte lorsqu'un produit contient un des ingrédients interdits
// @include https://www.coradrive.fr/*
// @include http://www.coradrive.fr/*
// @version 1.5
// @grant none
// @require http://files.amnesix.eu/~guillaume/allergies/Allergies-1.1.js
// ==/UserScript==
(function() {
document.querySelectorAll('.rnd8 .bloc_info h4').forEach(Allergies.process);
})();

View File

@ -0,0 +1,20 @@
// ==UserScript==
// @name Courses U allergies
// @namespace http://amnesix.eu
// @description Affiche une alerte lorsqu'un produit contient un des ingrédients interdits
// @include https://www.coursesu.com/*
// @include http://www.coursesu.com/*
// @version 2.1
// @grant none
// @require http://files.amnesix.eu/~guillaume/allergies/Allergies-1.1.js
// ==/UserScript==
(function() {
document.querySelectorAll('#listeInfosProduitsZone .infos').forEach(Allergies.process);
var productModalZone = document.getElementById('productModalZone');
var observer = new MutationObserver(function(mutations) {
var composition = mutations[0].addedNodes[0].querySelector('.composition');
Allergies.process(composition);
});
observer.observe(productModalZone, {childList: true});
})();