ECOD-Live-Warnings

Warn Users for PROD envs

当前为 2024-04-17 提交的版本,查看 最新版本

// ==UserScript==
// @name         ECOD-Live-Warnings
// @namespace    ecod.live.warnings
// @version      1.0.1
// @description  Warn Users for PROD envs
// @author       CRK

// @match        https://deployment.ecodesigncloud.com/*
// @match        https://cluster-dashboard.ecodesigncloud.com/*
// @match        https://retailecoscore.net/*
// @match        https://ecodesigncloud.com/*
// @match        https://pgadmin.ecodesigncloud.com/*
// @match        https://apim.ecodesigncloud.com/console/*
// @match        https://rollouts-dashboard.ecodesigncloud.com/*
// @match        https://workflows.ecodesigncloud.com/*

// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';
    // Function to create and append the live text
    function createLiveText() {
        var liveText = document.createElement('div');
        liveText.innerHTML = 'LIVE';
        liveText.style.position = 'fixed';
        liveText.style.padding = '3px';
        liveText.style.top = '0';
        liveText.style.left = '0';
        liveText.style.color = 'white';
        liveText.style.backgroundColor = 'red';
        liveText.style.fontSize = '40px';
        liveText.style.fontFamily = 'Arial';
        liveText.style.fontWeight = 'bold';
        liveText.style.zIndex = '9999'; // Make sure it's always on top
        document.documentElement.appendChild(liveText);
    }

    // Initial creation of the live text
    createLiveText();

    // Function to reapply live text after AJAX updates
    function reapplyLiveText() {
        var liveText = document.querySelector('#liveText');
        if (!liveText) {
            createLiveText();
        }
    }

    // Create a MutationObserver to detect changes in the DOM
    var observer = new MutationObserver(function(mutations) {
        mutations.forEach(function(mutation) {
            reapplyLiveText();
        });
    });

    // Configuration of the MutationObserver
    var config = { attributes: true, childList: true, subtree: true };

    // Start observing the document
    observer.observe(document.body, config);
})();