ECOD-Live-Warnings

Warn Users for PROD/DEMO envs

目前為 2024-04-17 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

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

// @match        https://aws-summit-demo.ecodesigncloud.com/*
// @match        https://cluster-dashboard.aws-summit-demo.ecodesigncloud.com/*
// @match        https://deployment.aws-summit-demo.ecodesigncloud.com/*
// @match        https://workflows.aws-summit-demo.ecodesigncloud.com/*
// @match        https://rollouts-dashboard.aws-summit-demo.ecodesigncloud.com/*
// @match        https://apim.aws-summit-demo.ecodesigncloud.com/*
// @match        https://pgadmin.aws-summit-demo.ecodesigncloud.com/*

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

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

// @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.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);
})();