Immodem

Testing

目前为 2018-10-08 提交的版本。查看 最新版本

// ==UserScript==
// @name         Immodem
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  Testing
// @author       You
// @match        https://immodem.poste-immo.intra.laposte.fr/*
// @grant        none
// ==/UserScript==

var 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}.taskCard{border-radius:2px!important;border:none;box-shadow:0 1px 2px 0 rgba(0,0,0,.5);transition:box-shadow .25s linear}.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}"),
    initLaunch,
    hash,
    url = [],
    buckets = {};

window.onhashchange = function(event) {
    url = event.newURL.split("/");
    hash = url[url.length - 1];

    if (hash == "cartTasks") {
        initLaunch = setTimeout(init, 500);
    } else {
        console.log("Pas de modification sur cette url")
    };
}

function init() {
    var wrap = document.querySelectorAll("[vertilize-container]")[0],
        style = document.createElement('style');
    style.type = 'text/css';
    style.appendChild(css);
    document.head.appendChild(style);

    wrap.id = "wrap";

    var cards = wrap.children;
    for (var i = 0; i < cards.length; i++) {
        var label = cards[i].getElementsByClassName("itemStep")[0].firstElementChild.innerHTML;
        if (buckets[label]) {
            buckets[label].push(cards[i]);
        } else {
            buckets[label] = [];
            buckets[label].push(cards[i]);
        }
    }
    makeEnv(buckets, wrap);
//    wrap.appendChild(environnement);
}

function makeEnv(buckets, wrap) {
//    console.log(el);
    var step = Object.keys(buckets);
    for (var i = 0; i < step.length; i++) {
        var bucket = document.createElement("div");
        bucket.classList.add('bucket');
        bucket.id = step[i];
        for (var j = 0; j < buckets[step[i]].length; j++){
            bucket.appendChild(buckets[step[i]][j]);
        }
        console.log(bucket);
        wrap.appendChild(bucket);
    }
}