Production & Dev instance warning

Warns you if you are on the dev or prod instance of your web app (not on localhost)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Production & Dev instance warning
// @namespace    ahappyviking
// @version      1.0.0
// @description  Warns you if you are on the dev or prod instance of your web app (not on localhost)
// @match        https://*.[APP NAME HERE].com/*
// @icon         https://i.kym-cdn.com/entries/icons/original/000/027/475/Screen_Shot_2018-10-25_at_11.02.15_AM.png
// @grant        none
// ==/UserScript==

const main = () => {
    const elem = document.createElement('div')
    elem.style.position = "fixed"
    elem.style.left = 0
    elem.style.right = 0
    elem.style.top = 0
    elem.style.height = "14px"
    elem.style.fontSize = "10px"
    elem.style.cursor = "pointer"
    elem.style.zIndex = 99999
    elem.style.fontWeight = "bold"
    elem.style.textAlign = "center"
    elem.addEventListener("click", () => (elem.style.display = "none"))
    document.body.appendChild(elem)
      
    if (window.location.hostname.startsWith("dev")){
      elem.style.backgroundColor = "#04d9ff"
      elem.innerText = "NOT ON LOCALHOST - DEV"
    }else{
      elem.style.backgroundColor = "yellow"
      elem.innerText = "NOT ON LOCALHOST - PRODUCTION"
    }
  }
  
  main()