Immodem

try to take over the world!

目前为 2019-01-17 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Immodem
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.6
  5. // @description try to take over the world!
  6. // @author coz3n
  7. // @match https://immodem.poste-immo.intra.laposte.fr/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. let obsconf = { childList: true },
  12. url = [],
  13. css = document.createTextNode("@font-face{font-family:Roboto;font-style:normal;font-weight:400;src:local('Roboto Regular'),local('Roboto-Regular'),url(https://themes.googleusercontent.com/static/fonts/roboto/v11/2UX7WLTfW3W8TclTUvlFyQ.woff) format('woff')}html{box-sizing:border-box;overflow:hidden}*{font-family:roboto}*,:after,:before{box-sizing:inherit}body{padding:0;height:100vh}h4{font-size:16px}#page-content-wrapper,#wrapper,body{height:100vh}#wrapper{overflow-y:auto;overflow-x:hidden}#sidebar-wrapper{overflow:hidden}.container-fluid{height:100%}div vertilize-container{justify-content:space-between}#wrap{display:-webkit-flex;display:-moz-flex;display:-ms-flex;display:-o-flex;display:flex;flex-flow:row nowrap;justify-content:space-around}.entete{width:100%;height:48px;text-align:center;font-size:1.5em;color:#fff;text-shadow:0 1px 0 #aaa;margin:0;padding:0}.bucket{padding:24px 8px 8px;margin:0 10px;display:flex;background:#ddd;height:80vh;overflow-y:scroll;flex-flow:row wrap;flex:1 1 100%;justify-content:space-between;align-items:flex-start;align-content:flex-start;max-width:20vw}.bucket>div{width:100%!important}.taskCard{border-radius:2px!important;border:none;box-shadow:0 1px 2px 0 rgba(0,0,0,.5);transition:box-shadow .25s linear;height:auto!important}.taskCard:hover{box-shadow:0 2px 4px 1px rgba(0,0,0,.5)}.taskInfos{font-size:12px}p{margin-bottom:6px}[id=\"Validation CP\"]{order:0}#Réalisation{order:1}[id=\"Validation technique\"]{order:2}[id=\"Réception de la demande\"]{order:3}::-webkit-scrollbar{width:8px}::-webkit-scrollbar-thumb{background:#666;border-radius:16px}::-webkit-scrollbar-track{background:#ddd;width:12px}"),
  14. initLaunch,
  15. buckets = {
  16. "Validation CP" : [],
  17. "Réalisation" : [],
  18. "Validation technique" : [],
  19. "Réception de la demande" : []
  20. },
  21. sessionVal = localStorage.getItem("user_session");
  22.  
  23. console.log(sessionVal);
  24.  
  25. let observer = new MutationObserver(function(mutations) {
  26. // console.log("observer", mutations);
  27. // For the sake of...observation...let's output the mutation to console to see how this all works
  28. mutations.forEach(function(mutation) {
  29. let cards = document.getElementsByClassName('taskCard');
  30. if (cards) {
  31. for (let card = 0; card < cards.length; card++) {
  32. let step = cards[card].getElementsByClassName("label-info")[0];
  33. if (step) {
  34. let bucket;
  35. if (step.innerHTML == "Validation CdP") {
  36. bucket = document.getElementById("Validation CP");
  37. } else {
  38. bucket = document.getElementById(step.innerHTML);
  39. }
  40.  
  41. if (bucket) {
  42. bucket.appendChild(cards[card].parentElement);
  43. } else {
  44. //console.log("Il n'y a pas de de bucket pour ranger : ", cards[card]);
  45. return
  46. }
  47. }
  48. }
  49. }
  50. });
  51. });
  52.  
  53.  
  54. (function() {
  55. let origOpen = XMLHttpRequest.prototype.open;
  56. XMLHttpRequest.prototype.open = function(method, url) {
  57. // console.log('request started!');
  58. // console.log(this);
  59. this.addEventListener('load', function() {
  60. if (url == "/web/app.php/cartTasks/loadList/Family") {
  61. console.log("chargement de la liste", this);
  62. } else if (url == "/web/app.php/cartTasks/loadTasks/1963") {
  63. console.log("réception des cartes", this);
  64. initLaunch = setTimeout(init(this.responseText), 200);
  65. };
  66. });
  67. origOpen.apply(this, arguments);
  68. };
  69. })();
  70.  
  71. function init() {
  72. console.log(JSON.parse(arguments[0]));
  73.  
  74. let wrap = document.querySelectorAll("[vertilize-container]")[0],
  75. nav = document.querySelectorAll("[role=\"navigation\"]")[0],
  76. style = document.createElement('style');
  77. style.type = 'text/css';
  78. style.appendChild(css);
  79. document.head.appendChild(style);
  80.  
  81. if (nav) {
  82. nav.parentElement.removeChild(nav);
  83. }
  84.  
  85. if (!wrap) {
  86. clearTimeout(initLaunch);
  87. initLaunch = setTimeout(init(), 1000);
  88. } else {
  89. wrap.id = "wrap";
  90. let cards = wrap.children;
  91. for (let i = 0; i < cards.length; i++) {
  92. console.log("Une nouvelle carte : ", cards[i]);
  93. let label;
  94. if (cards[i].getElementsByClassName("itemStep")[0].firstElementChild.innerHTML == "Validation CdP") {
  95. label = "Validation CP";
  96. } else {
  97. label = cards[i].getElementsByClassName("itemStep")[0].firstElementChild.innerHTML;
  98. }
  99. if (buckets[label]) {
  100. buckets[label].push(cards[i]);
  101. } else {
  102. buckets[label] = [];
  103. buckets[label].push(cards[i]);
  104. }
  105. }
  106. makeEnv(buckets, wrap);
  107. observer.observe(wrap, obsconf);
  108. }
  109. }
  110.  
  111.  
  112. function makeEnv(buckets, wrap) {
  113. // console.log(el);
  114. let step = Object.keys(buckets);
  115. for (let i = 0; i < step.length; i++) {
  116. let bucket = document.createElement("div"),
  117. entete = document.createElement('h2');
  118. bucket.classList.add('bucket');
  119. bucket.id = step[i];
  120. entete.innerHTML = step[i];
  121. entete.classList = "entete";
  122. bucket.appendChild(entete);
  123. for (let j = 0; j < buckets[step[i]].length; j++) {
  124. bucket.appendChild(buckets[step[i]][j]);
  125. }
  126. //console.log(bucket);
  127. wrap.appendChild(bucket);
  128. }
  129. modCards();
  130. }
  131.  
  132. function modCards() {
  133. let taskInfos = document.getElementsByClassName('taskInfos');
  134. for (let i = 0; i < taskInfos.length; i++) {
  135. let att = taskInfos[i].innerHTML.split(" : ");
  136. taskInfos[i].innerHTML = "<b>" + att[0] + "</b> : " + att[1];
  137. }
  138. }