From 35acbff1cf4655cbbbd4050a67691365e23fe250 Mon Sep 17 00:00:00 2001 From: keplyx Date: Tue, 28 Jan 2020 10:43:11 +0100 Subject: [PATCH] Fixed injected css not working when injected too late --- screens/PlanexScreen.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/screens/PlanexScreen.js b/screens/PlanexScreen.js index 434e1d9..227e006 100644 --- a/screens/PlanexScreen.js +++ b/screens/PlanexScreen.js @@ -15,7 +15,8 @@ const PLANEX_URL = 'http://planex.insa-toulouse.fr/'; const CUSTOM_CSS_GENERAL = 'https://srv-falcon.etud.insa-toulouse.fr/~amicale_app/custom_css/planex/customMobile2.css'; const CUSTOM_CSS_NIGHTMODE = 'https://srv-falcon.etud.insa-toulouse.fr/~amicale_app/custom_css/planex/customDark2.css'; -// JS + JQuery functions used to remove alpha from events. Copy paste in browser console for quick testing +// // JS + JQuery functions used to remove alpha from events. Copy paste in browser console for quick testing +// // Remove alpha from given Jquery node // function removeAlpha(node) { // console.log(node); // let bg = node.css("background-color"); @@ -25,6 +26,7 @@ const CUSTOM_CSS_NIGHTMODE = 'https://srv-falcon.etud.insa-toulouse.fr/~amicale_ // node.css("background-color", newBg); // } // } +// // Observe for planning DOM changes // let observer = new MutationObserver(function(mutations) { // for (let i = 0; i < mutations.length; i++) { // if (mutations[i]['addedNodes'].length > 0 && $(mutations[i]['addedNodes'][0]).hasClass("fc-event")) @@ -32,6 +34,10 @@ const CUSTOM_CSS_NIGHTMODE = 'https://srv-falcon.etud.insa-toulouse.fr/~amicale_ // } // }); // observer.observe(document.querySelector(".fc-body"), {attributes: false, childList: true, characterData: false, subtree:true}); +// // Run remove alpha a first time on whole planning. Useful when code injected after planning fully loaded. +// $(".fc-event-container .fc-event").each(function(index) { +// removeAlpha($(this)); +// }); // Watch for changes in the calendar and call the remove alpha function const OBSERVE_MUTATIONS_INJECTED = @@ -50,7 +56,10 @@ const OBSERVE_MUTATIONS_INJECTED = ' removeAlpha($(mutations[i][\'addedNodes\'][0]))\n' + ' }\n' + '});\n' + - 'observer.observe(document.querySelector(".fc-body"), {attributes: false, childList: true, characterData: false, subtree:true});\n'; + 'observer.observe(document.querySelector(".fc-body"), {attributes: false, childList: true, characterData: false, subtree:true});\n' + + '$(".fc-event-container .fc-event").each(function(index) {\n' + + ' removeAlpha($(this));\n' + + '});'; /** * Class defining the app's planex screen. * This screen uses a webview to render the planex page