More Greasemonkey scripting

More work-related scripting.

    // ==UserScript==
    // @name           CI Manager Fixes
    // @namespace      https://bennettp123.com
    // @description    Fixes some of the broken CSS in CI Manager. Very much a work in progress.
    // @include        http://cimanager.REDACTED/*
    // ==/UserScript==
    
    function addCSS(cssString)
    {
        var head = document.getElementsByTagName('head')[0];
        if (!head) { return null; }
        var newCSS = document.createElement('style');
        newCSS.type = "text/css";
        newCSS.innerHTML = cssString;
        head.appendChild(newCSS);
    }
    
    // delete an element by ID and return its parent
    function removeByID(elementId)
    {
        var element = document.getElementById(elementId);
        if (!element) { return null; }
        var parent = element.parentNode;
        parent.removeChild(element);
        return parent;
    }
    
    // delete the stupid placeholder image, replace it with some regular text
    var imageID = "ctl00_MainContent_ctl00_imgNoRelationData"
    try {
        // (removeByID returns the parent of the element removed.)
        removeByID(imageID).innerHTML = "No relationship data available";
    }
    catch (error) {
        // who cares?
    }
    
    // add an empty placeholder to the end of the menu
    // **** EDIT: doesn't work properly with floats; disabled ****
    //        var menu = document.getElementById("menu");
    //        if (menu) {
    //            var placeholder = document.createElement('div');
    //            placeholder.id = "menu_placeholder";
    //            placeholder.innerHTML = " ";
    //            menu.appendChild(placeholder);
    //        }
    
    // add some custom CSS
    addCSS (
    '   div#page { overflow:auto!important } \n\
        div#main { float:none!important; \n\
                   background-image:none!important; \n\
                   width:auto!important; } \n\
        div#menu { margin-right:25px!important } \n\
        //div#menu_placeholder { height:1000px } \n\
        //td { width:auto!important } \n\
        //select,textarea,input { width:auto!important } \n\
        \n\
        #ctl00_MainContent_ctl00_txtNotes, \n\
        #ctl00_MainContent_ctl00_txtSiteName, \n\
        #ctl00_MainContent_ctl00_lstRelations, \n\
        #ctl00_MainContent_ctl00_pnlNoRelationData \n\
        { width:auto!important } \n\
        \n\
        #ctl00_MainContent_ctl00_lstRelations { min-width:140px } \n\
        \n\
        #ctl00_MainContent_ctl00_ddlStatus, \n\
        #ctl00_MainContent_ctl00_ddlClassification \n\
        { width:146px!important } \n\
        \n\
        #ctl00_MainContent_ctl00_txtCreationDate, \n\
        #ctl00_MainContent_ctl00_txtModifiedDate \n\
        { width:138px!important } \n\
        \n\
        #ctl00_MainContent_ctl00_chkAdditionalServices, \n\
        #ctl00_MainContent_ctl00_chkCAPUTemplates \n\
        { text-align:right } \n\
        \n\
        label + input { white-space:nowrap } \n\
        \n\
        //table * * div { width:auto!important } \n\
        \n\
        #ctl00_MainContent_pnlInitialView>table, \n\
        #ctl00_MainContent_pnlInitialView>table>tbody, \n\
        { width:58%!important } \n\
        \n\
        #ctl00_MainContent_pnlInitialView>table * td \n\
        { width:auto!important } \n\
        \n\
        #ctl00_MainContent_pnlInitialView>table * td>div \n\
        { overflow:hidden!important; \n\
          text-overflow:ellipsis!important; \n\
          white-space:nowrap!important; \n\
        } \n\
        #ctl00_MainContent_pnlInitialView>table * td h5, \n\
        #ctl00_MainContent_pnlInitialView>table * td div \n\
        { width:68%!important; } \n\
        \n\
        #ctl00_MainContent_pnlInitialView>table * td>hr \n\
        { visibility:hidden; } \n\
        \n\
        //#ctl00_MainContent_pnlInitialView>table>tbody, \n\
        //#ctl00_MainContent_pnlInitialView>table>tr \n\
        //{ width:78%!important ); \n\
        '
    );