// ==UserScript==
// @name        Remove concourse elements
// @namespace   cloudpipeline.digital
// @description Strips away some of the cruft from the concourse pipeline view when showing it on monitoring screens.
// @include     https://deployer.*.cloudpipeline.digital/*
// @include     https://deployer.cloud.service.gov.uk/*
// @version     1
// @grant       none
// ==/UserScript==
var readyStateCheckInterval = setInterval(function() {
    if (document.readyState === "complete") {
        clearInterval(readyStateCheckInterval);

        console.log("Monitor mode is go");
        var element = document.getElementsByClassName("legend")[0];
        element.parentNode.removeChild(element);

        var element = document.getElementsByClassName("lower-right-info")[0];
        element.parentNode.removeChild(element);

        var hostname = location.hostname.replace("deployer.", "").replace(".cloudpipeline.digital","");

        var element = document.getElementById("top-bar-app");
        element.innerHTML = "&nbsp;<font size=5>" + hostname + "</font>";
        // Move it to the bottom because there's more space there.
        element.style.position = "absolute";
        element.style.bottom = "0";

        var element = document.getElementsByClassName("bottom")[0];
        // Remove the padding because the top bar isn't there any more.
        element.style.paddingTop = "0";
    }
}, 10);

// ==UserScript==
// @name        Remove concourse elements
// @namespace   cloudpipeline.digital
// @description Strips away some of the cruft from the concourse pipeline view when showing it on monitoring screens.
// @include     https://deployer.*.cloudpipeline.digital/*
// @include     https://deployer.cloud.service.gov.uk/*
// @version     1
// @grant       none
// ==/UserScript==
var readyStateCheckInterval = setInterval(function() {
    if (document.readyState === "complete") {
        clearInterval(readyStateCheckInterval);

        console.log("Monitor mode is go");
        var element = document.getElementsByClassName("legend")[0];
        element.parentNode.removeChild(element);

        var element = document.getElementsByClassName("lower-right-info")[0];
        element.parentNode.removeChild(element);

        var hostname = location.hostname.replace("deployer.", "").replace(".cloudpipeline.digital","");

        var element = document.getElementById("top-bar-app");
        element.innerHTML = "&nbsp;<font size=5>" + hostname + "</font>";
        // Move it to the bottom because there's more space there.
        element.style.position = "absolute";
        element.style.bottom = "0";

        var element = document.getElementsByClassName("bottom")[0];
        // Remove the padding because the top bar isn't there any more.
        element.style.paddingTop = "0";
    }
}, 2000);

Increase delay of clean_concourse plugin to 2s
Increase delay of clean_concourse plugin to 2s

This plugin assumes that all the elements are present and the page
rendered after 10ms, and if not, it fails because it cannot find the
right DOM elements.

The new version of concourse 2.4.0 takes longer to completely render in
the dashboard screen, specially when we have 3 frames as we do. Because
that the script does not work in our dashboard.

In this commit we workaround this issue by delaying the execution of
the script much more longer, up to 2000ms or 2s.

A more elegant solution should be waiting/polling until all elements are
present and then apply the changes. But as this is a simple script for
our dashboards it is not so relevant.
