sxuid / Dynamics 365 - environment banner

// ==UserScript==
// @name         Dynamics 365 - environment banner
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Replaces the D365 Sandbox/Production banner with the org name
// @author       You
// @license      MIT
// @match        https://*.dynamics.com/main.aspx*
// @grant        none
// ==/UserScript==

(function () {
  'use strict';
  oneMinuteLoop();
})();

function oneMinuteLoop() {
  setCrmEnvironmentBannerName();
  setTimeout(oneMinuteLoop, 60 * 1000);
}

function setCrmEnvironmentBannerName() {
  try {
    var url = window.location.href;
    var org = url.split(".crm6")[0].split("//")[1];
    $("div.sandboxWatermark").text(org.toUpperCase());
  }
  catch (e) {}
}