tiss_developer_tweaks

a better tiss for tiss-developers - menu: switch between environments

目前為 2017-11-01 提交的版本,檢視 最新版本

// ==UserScript==
// @name           tiss_developer_tweaks
// @namespace      *tiss.tuwien.ac.at*
// @include        *tiss.tuwien.ac.at*
// @version        0.2
// @author         lual
// @description	   a better tiss for tiss-developers - menu: switch between environments
// @author         fg (csd)
// @grant          GM_addStyle
// ==/UserScript==
// changes:        2017-11-01 initial - publish on greasyfork
//////////////////////////////////////////////////////////////////////
// List of links to Environments
var linkListHref = ['localhost:3001','localhost:3002','localhost:3003','dev1.tiss.tuwien.ac.at','mig.tiss.tuwien.ac.at','tiss.tuwien.ac.at'];
var linkListText = ['lh:3001',       'lh:3002',       'lh:3003',       'dev1',                  'mig',                  'Echtsystem!'];

function populateMenu() {
  var menu = document.getElementsByClassName("clearfix toolNav")[0];
  var li;
  var newLink;
  var text;
  for (var i = 0; i < linkListHref.length; i++ ) {
    li = document.createElement("li");
    newSpan = document.createElement("span");
    if (window.location.host == linkListHref[i])
    {
      text = document.createTextNode(linkListText[i]);
      newSpan.appendChild(text);
      newSpan.setAttribute("style", "color:grey; font-weight: bold;");
    } else {
      newLink = document.createElement("a");
      newLink.setAttribute('href',linkListHref[i] + window.location.pathname + window.location.search + window.location.hash);
      newLink.innerHTML = linkListText[i];
      newSpan.appendChild(newLink);
    }
    li.appendChild(newSpan);
    menu.appendChild(li);
  }
}
populateMenu();
//////////////////////////////////////////////////////////////////////
//include userstyle tiss-env-border
//https://userstyles.org/styles/121958/tiss-env-border
GM_addStyle(`
@-moz-document regexp(".*[^\.]tiss[\.]tuwien[\.]ac[\.]at.*") {
  body:before {
    content: "";
    position: fixed;
    background: #FF0000;
    left: 0;
    right: 0;
    height: 11px;
    z-index:100;
    background-image:url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' version='1.1' height='11px' width='90px'><text x='9' y='9' fill='white' font-size='10' font-weight='bold' font-family='Arial, Helvetica, sans-serif' >ECHTSYSTEM ! </text></svg>");
    top: 0;
  }
  body {
    margin-top:11px;
  }
}
`);
//////////////////////////////////////////////////////////////////////