Browse Source

Fixed injected css not working when injected too late

keplyx 4 years ago
parent
commit
35acbff1cf
1 changed files with 11 additions and 2 deletions
  1. 11
    2
      screens/PlanexScreen.js

+ 11
- 2
screens/PlanexScreen.js View File

@@ -15,7 +15,8 @@ const PLANEX_URL = 'http://planex.insa-toulouse.fr/';
15 15
 const CUSTOM_CSS_GENERAL = 'https://srv-falcon.etud.insa-toulouse.fr/~amicale_app/custom_css/planex/customMobile2.css';
16 16
 const CUSTOM_CSS_NIGHTMODE = 'https://srv-falcon.etud.insa-toulouse.fr/~amicale_app/custom_css/planex/customDark2.css';
17 17
 
18
-// JS + JQuery functions used to remove alpha from events. Copy paste in browser console for quick testing
18
+// // JS + JQuery functions used to remove alpha from events. Copy paste in browser console for quick testing
19
+// // Remove alpha from given Jquery node
19 20
 // function removeAlpha(node) {
20 21
 //     console.log(node);
21 22
 //     let bg = node.css("background-color");
@@ -25,6 +26,7 @@ const CUSTOM_CSS_NIGHTMODE = 'https://srv-falcon.etud.insa-toulouse.fr/~amicale_
25 26
 //         node.css("background-color", newBg);
26 27
 //     }
27 28
 // }
29
+// // Observe for planning DOM changes
28 30
 // let observer = new MutationObserver(function(mutations) {
29 31
 //     for (let i = 0; i < mutations.length; i++) {
30 32
 //         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_
32 34
 //     }
33 35
 // });
34 36
 // observer.observe(document.querySelector(".fc-body"), {attributes: false, childList: true, characterData: false, subtree:true});
37
+// // Run remove alpha a first time on whole planning. Useful when code injected after planning fully loaded.
38
+// $(".fc-event-container .fc-event").each(function(index) {
39
+//     removeAlpha($(this));
40
+// });
35 41
 
36 42
 // Watch for changes in the calendar and call the remove alpha function
37 43
 const OBSERVE_MUTATIONS_INJECTED =
@@ -50,7 +56,10 @@ const OBSERVE_MUTATIONS_INJECTED =
50 56
     '            removeAlpha($(mutations[i][\'addedNodes\'][0]))\n' +
51 57
     '    }\n' +
52 58
     '});\n' +
53
-    'observer.observe(document.querySelector(".fc-body"), {attributes: false, childList: true, characterData: false, subtree:true});\n';
59
+    'observer.observe(document.querySelector(".fc-body"), {attributes: false, childList: true, characterData: false, subtree:true});\n' +
60
+    '$(".fc-event-container .fc-event").each(function(index) {\n' +
61
+    '    removeAlpha($(this));\n' +
62
+    '});';
54 63
 /**
55 64
  * Class defining the app's planex screen.
56 65
  * This screen uses a webview to render the planex page

Loading…
Cancel
Save