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
 const CUSTOM_CSS_GENERAL = 'https://srv-falcon.etud.insa-toulouse.fr/~amicale_app/custom_css/planex/customMobile2.css';
15
 const CUSTOM_CSS_GENERAL = 'https://srv-falcon.etud.insa-toulouse.fr/~amicale_app/custom_css/planex/customMobile2.css';
16
 const CUSTOM_CSS_NIGHTMODE = 'https://srv-falcon.etud.insa-toulouse.fr/~amicale_app/custom_css/planex/customDark2.css';
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
 // function removeAlpha(node) {
20
 // function removeAlpha(node) {
20
 //     console.log(node);
21
 //     console.log(node);
21
 //     let bg = node.css("background-color");
22
 //     let bg = node.css("background-color");
25
 //         node.css("background-color", newBg);
26
 //         node.css("background-color", newBg);
26
 //     }
27
 //     }
27
 // }
28
 // }
29
+// // Observe for planning DOM changes
28
 // let observer = new MutationObserver(function(mutations) {
30
 // let observer = new MutationObserver(function(mutations) {
29
 //     for (let i = 0; i < mutations.length; i++) {
31
 //     for (let i = 0; i < mutations.length; i++) {
30
 //         if (mutations[i]['addedNodes'].length > 0 && $(mutations[i]['addedNodes'][0]).hasClass("fc-event"))
32
 //         if (mutations[i]['addedNodes'].length > 0 && $(mutations[i]['addedNodes'][0]).hasClass("fc-event"))
32
 //     }
34
 //     }
33
 // });
35
 // });
34
 // observer.observe(document.querySelector(".fc-body"), {attributes: false, childList: true, characterData: false, subtree:true});
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
 // Watch for changes in the calendar and call the remove alpha function
42
 // Watch for changes in the calendar and call the remove alpha function
37
 const OBSERVE_MUTATIONS_INJECTED =
43
 const OBSERVE_MUTATIONS_INJECTED =
50
     '            removeAlpha($(mutations[i][\'addedNodes\'][0]))\n' +
56
     '            removeAlpha($(mutations[i][\'addedNodes\'][0]))\n' +
51
     '    }\n' +
57
     '    }\n' +
52
     '});\n' +
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
  * Class defining the app's planex screen.
64
  * Class defining the app's planex screen.
56
  * This screen uses a webview to render the planex page
65
  * This screen uses a webview to render the planex page

Loading…
Cancel
Save