ECOD-Live-Warnings

Warn Users for PROD envs

  1. // ==UserScript==
  2. // @name ECOD-Live-Warnings
  3. // @namespace ecod.live.warnings
  4. // @version 1.0.3
  5. // @description Warn Users for PROD envs
  6. // @author CRK
  7.  
  8. // @match https://www.retailecoscore.net/*
  9. // @match https://retailecoscore.net/*
  10. // @match https://www.ecodesigncloud.com/*
  11. // @match https://ecodesigncloud.com/*
  12. // @match https://deployment.ecodesigncloud.com/*
  13. // @match https://cluster-dashboard.ecodesigncloud.com/*
  14. // @match https://pgadmin.ecodesigncloud.com/*
  15. // @match https://apim.ecodesigncloud.com/*
  16. // @match https://rollouts-dashboard.ecodesigncloud.com/*
  17. // @match https://workflows.ecodesigncloud.com/*
  18.  
  19. // @grant none
  20. // @license MIT
  21. // @require https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.13.6/underscore-umd-min.js
  22. // ==/UserScript==
  23.  
  24. (function() {
  25. 'use strict';
  26. // Debounce function
  27. function debounce(func, delay) {
  28. let timeout;
  29. return function() {
  30. const context = this;
  31. const args = arguments;
  32. clearTimeout(timeout);
  33. timeout = setTimeout(() => {
  34. func.apply(context, args);
  35. }, delay);
  36. };
  37. }
  38. // Function to create and append the live text
  39. function createLiveText() {
  40. var liveText = document.createElement('div');
  41. liveText.innerHTML = 'LIVE';
  42. liveText.style.position = 'fixed';
  43. liveText.style.padding = '3px';
  44. liveText.style.top = '0';
  45. liveText.style.left = '0';
  46. liveText.style.color = 'white';
  47. liveText.style.backgroundColor = 'red';
  48. liveText.style.fontSize = '40px';
  49. liveText.style.fontFamily = 'Arial';
  50. liveText.style.fontWeight = 'bold';
  51. liveText.style.zIndex = '9999'; // Make sure it's always on top
  52. document.documentElement.appendChild(liveText);
  53. }
  54.  
  55. // Initial creation of the live text
  56. createLiveText();
  57.  
  58. // Function to reapply live text after AJAX updates, with debounce
  59. const debouncedReapplyLiveText = debounce(function() {
  60. var liveText = document.querySelector('#liveText');
  61. if (!liveText) {
  62. createLiveText();
  63. }
  64. }, 5000); // Debounce for 5 seconds
  65.  
  66. // Create a MutationObserver to detect changes in the DOM
  67. var observer = new MutationObserver(function(mutations) {
  68. mutations.forEach(function(mutation) {
  69. debouncedReapplyLiveText();
  70. });
  71. });
  72.  
  73. // Configuration of the MutationObserver
  74. var config = { attributes: true, childList: true, subtree: true };
  75.  
  76. // Start observing the document
  77. observer.observe(document.body, config);
  78. })();