Immodem

try to take over the world!

当前为 2018-10-08 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Immodem
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.3
  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. var obsconf = {childList: true},
  12. nodes = [],
  13. hash,
  14. initlaunch,
  15. url = [],
  16. css = document.createTextNode("html{box-sizing:border-box}body{background:linear-gradient(to bottom,#fff 0,#ddd 100%)!important}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}.entete{width:100%;height:48px;text-align:center;font-size:1.5em;color:#fff;text-shadow:0 1px solid #aaa}.bucket{padding:24px 8px 8px;margin:0 10px;display:flex;flex-flow:column nowrap;flex:1 100%;background:#ddd}.bucket>div{width:100%!important}[id=\"Validation technique\"]{order:1}#Réalisation{order:2}.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)}p{margin-bottom:6px}@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')}*{font-family:roboto}"),
  17. initLaunch,
  18. buckets = {};
  19.  
  20.  
  21. var observer = new MutationObserver(function(mutations) {
  22. // For the sake of...observation...let's output the mutation to console to see how this all works
  23. mutations.forEach(function(mutation) {
  24. //console.log(mutation);
  25. var cards = document.getElementsByClassName('taskCard');
  26. if (cards) {
  27. for (var card = 0; card < cards.length; card++) {
  28. var step = cards[card].getElementsByClassName("label-info")[0];
  29. if (step) {
  30. var bucket = document.getElementById(step.innerHTML);
  31. if (bucket) {
  32. bucket.appendChild(cards[card].parentElement);
  33. } else {
  34. console.log("Il n'y a pas de de bucket pour ranger : ", cards[card]);
  35. }
  36. }
  37. }
  38. }
  39. });
  40. });
  41.  
  42. window.onload = function() {
  43. console.log("page loaded");
  44. }
  45.  
  46. window.onhashchange = function(event) {
  47. url = event.newURL.split("/");
  48. hash = url[url.length - 1];
  49.  
  50. if (hash == "cartTasks") {
  51. initLaunch = setTimeout(init, 500);
  52. } else {
  53. console.log("Pas de modification sur cette url")
  54. };
  55. }
  56.  
  57. function init() {
  58. var wrap = document.querySelectorAll("[vertilize-container]")[0],
  59. style = document.createElement('style');
  60. style.type = 'text/css';
  61. style.appendChild(css);
  62. document.head.appendChild(style);
  63.  
  64. wrap.id = "wrap";
  65.  
  66. var cards = wrap.children;
  67. for (var i = 0; i < cards.length; i++) {
  68. var label = cards[i].getElementsByClassName("itemStep")[0].firstElementChild.innerHTML;
  69. if (buckets[label]) {
  70. buckets[label].push(cards[i]);
  71. } else {
  72. buckets[label] = [];
  73. buckets[label].push(cards[i]);
  74. }
  75. }
  76. makeEnv(buckets, wrap);
  77. observer.observe(wrap, obsconf);
  78. }
  79.  
  80. function makeEnv(buckets, wrap) {
  81. // console.log(el);
  82. var step = Object.keys(buckets);
  83. for (var i = 0; i < step.length; i++) {
  84. var bucket = document.createElement("div");
  85. bucket.classList.add('bucket');
  86. bucket.id = step[i];
  87. for (var j = 0; j < buckets[step[i]].length; j++){
  88. bucket.appendChild(buckets[step[i]][j]);
  89. }
  90. //console.log(bucket);
  91. wrap.appendChild(bucket);
  92. }
  93. }