Mi Drive - Total Closures Only

hides construction on Mi Drive other than total closures

当前为 2015-12-28 提交的版本,查看 最新版本

// ==UserScript==
// @name         Mi Drive - Total Closures Only
// @namespace    vaindil
// @version      0.2
// @description  hides construction on Mi Drive other than total closures
// @author       vaindil
// @match        http://mdotnetpublic.state.mi.us/drive/
// @grant        none
// ==/UserScript==

console.log("(TC) beginning");
err_num = 0;

startcode = function() {
    try {
        if (document.getElementById('construction_layer') !== null && document.getElementById('construction_layer') !== "") {
            //debugger;
            console.log("(TC) start");
            var elem = document.querySelectorAll('[*|href="images/bo_18px_.png"]');
            var elemt = document.querySelectorAll('[*|href="images/bg_18px_.png"]');
            for (var i = elem.length - 1; i >= 0; i--) {
                elem[i].parentNode.removeChild(elem[i]);
            }
            for (var j = elemt.length - 1; j >= 0; j--) {
                elemt[j].parentNode.removeChild(elemt[j]);
            }
            console.log("(TC) layers removed");
        } else {
            if (err_num == 9) {
                alert("Mi Drive took too long to load, Total Closures can't run.");
                console.log("(TC) too many errors, quitting");
                return;
            }
            err_num++;
            console.log("(TC) not loaded, pausing");
            setTimeout(startcode, 3000);
        }
    } catch (err) {
        if (err_num == 9) {
            console.log("TC too many errors, quitting");
            return;
        }
        console.log("TC error: "+err);
        err_num++;
        setTimeout(startcode, 3000);
    }
};

startcode();