Skip to content

Instantly share code, notes, and snippets.

@trietsch
Created October 17, 2025 09:59
Show Gist options
  • Select an option

  • Save trietsch/c9c0804a3f133490f72c7ea9139e4f4c to your computer and use it in GitHub Desktop.

Select an option

Save trietsch/c9c0804a3f133490f72c7ea9139e4f4c to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Environment Banner
// @version 1.0.0
// @description Inject a small box at the top of a Grafana page to display the environment based on the URL
// @author You
// @include /^.*\.weu\.grafana\.azure\.com\/.*$/
// @grant none
// ==/UserScript==
(function () {
'use strict';
const url = window.location.href;
let env = null;
let color = null;
if (url.includes('-dev-')) {
env = 'dev';
color = 'rgba(0, 128, 0, 0.8)'; // semi-transparent green
} else if (url.includes('-acc-')) {
env = 'acc';
color = 'rgba(255, 165, 0, 0.85)'; // semi-transparent orange
} else if (url.includes('-prd-')) {
env = 'prd';
color = 'rgba(255, 0, 0, 0.85)'; // semi-transparent red
}
if (!env) return;
const box = document.createElement('div');
box.textContent = env.toUpperCase();
box.style.position = 'fixed';
box.style.top = '2px'; // vertical spacing
box.style.left = '50%';
box.style.transform = 'translateX(-50%)';
box.style.backgroundColor = color;
box.style.color = 'white';
box.style.fontFamily = 'monospace';
box.style.fontSize = '14px';
box.style.padding = '6px 12px';
box.style.borderRadius = '8px';
box.style.boxShadow = '0 2px 6px rgba(0, 0, 0, 0.2)';
box.style.zIndex = '999999';
box.style.pointerEvents = 'none'; // don't block clicks
document.body.appendChild(box);
})();
@trietsch
Copy link
Copy Markdown
Author

trietsch commented Oct 17, 2025

image image image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment