Greasy Fork

Greasy Fork is available in English.

Immodem

try to take over the world!

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

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Immodem
// @namespace    http://tampermonkey.net/
// @version      0.3
// @description  try to take over the world!
// @author       coz3n
// @match        https://immodem.poste-immo.intra.laposte.fr/*
// @grant        none
// ==/UserScript==

var obsconf = { childList: true },
    hash,
    initlaunch,
    url = [],
    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}#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:550px;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}"),
    initLaunch,
    buckets = {};


var observer = new MutationObserver(function(mutations) {
    // For the sake of...observation...let's output the mutation to console to see how this all works
    mutations.forEach(function(mutation) {
        //console.log(mutation);
        var cards = document.getElementsByClassName('taskCard');
        if (cards) {
            for (var card = 0; card < cards.length; card++) {
                var step = cards[card].getElementsByClassName("label-info")[0];
                if (step) {
                    var bucket = document.getElementById(step.innerHTML);
                    if (bucket) {
                        bucket.appendChild(cards[card].parentElement);
                    } else {
                        console.log("Il n'y a pas de de bucket pour ranger : ", cards[card]);
                    }
                }
            }
        }
    });
});

window.onload = function() {
    console.log("page loaded");
}

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],
        nav = document.querySelectorAll("[role=\"navigation\"]")[0],
        style = document.createElement('style');
    style.type = 'text/css';
    style.appendChild(css);
    document.head.appendChild(style);

    if (nav) {
        nav.parentElement.removeChild(nav);
    }

    if (wrap === undefined) {
        initlaunch = setTimeout(init(), 500);
    } else {
        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);
        observer.observe(wrap, obsconf);
    }
}


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"),
            entete = document.createElement('h2');
        bucket.classList.add('bucket');
        bucket.id = step[i];
        entete.innerHTML = step[i];
        entete.classList = "entete";
        bucket.appendChild(entete);
        for (var j = 0; j < buckets[step[i]].length; j++) {
            bucket.appendChild(buckets[step[i]][j]);
        }
        //console.log(bucket);
        wrap.appendChild(bucket);
    }
    modCards();
}

function modCards() {
    var taskInfos = document.getElementsByClassName('taskInfos');
    for (var i = 0; i < taskInfos.length; i++) {
        var att = taskInfos[i].innerHTML.split(" : ");
        taskInfos[i].innerHTML = "<b>" + att[0] + "</b> : " + att[1];
    }
}

/*
(function() {
    var origOpen = XMLHttpRequest.prototype.open;
    XMLHttpRequest.prototype.open = function(method, url) {
        this.addEventListener('load', function() {
            console.log('Chargement XHR terminé', method, url);
        });

        this.addEventListener('error', function() {
            console.log('erreur XHR de sortie', method, url);
        });
        origOpen.apply(this, arguments);
    };
})();

*/

(function() {
    var origOpen = XMLHttpRequest.prototype.open;
    XMLHttpRequest.prototype.open = function(method,url) {
        console.log('request started!');
        this.addEventListener('load', function() {
            console.log('chargement XHR terminé', method, url);
//            console.log('request completed!');
            console.log(this.readyState); //will always be 4 (ajax is completed successfully)
            console.log(this.responseText); //whatever the response was
        });
        origOpen.apply(this, arguments);
    };
})();