您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
a better tiss for tiss-developers
当前为
// ==UserScript== // @name tiss_developer_tweaks // @namespace https://greasyfork.org/de/users/157797-lual // @include *tiss.tuwien.ac.at* // @include http://localhost:3* // @exclude /^https?://dev.tiss.tuwien.ac.at.*$/ // @version 0.21 // @author lual // @description a better tiss for tiss-developers // @author fg (csd) // @grant GM_addStyle // @grant GM_getValue // @grant GM_setValue // ==/UserScript== // changes: 2017-11-01 publish on greasyfork // https://greasyfork.org/de/scripts/34721-tiss-developer-tweaks // 2017-11-03 mark current menu entry // fill unused space - use whole screen width // 2017-11-06 production warning border also for chrome // 2018-08-03 bugfix - production warning border - for tiss-help-system // 2018-08-03 add next.devcloud // 2018-09-18 dynamic environment list // 2018-09-18 exclude dev.tiss.tuwien.ac.at (redmine) /////////////////////////////////////////////////////////////////////////////// // list of links to environments var Util = { log: function () { var args = [].slice.call(arguments); args.unshift('%c' + SCRIPT_NAME + ':', 'font-weight: bold;color: purple;'); console.log.apply(console, args); }, storeGet: function(key) { if (typeof GM_getValue === "undefined") { var value = localStorage.getItem(key); if (value === "true" || value === "false") { return (value === "true") ? true : false; } return value; } return GM_getValue(key); }, storeSet: function(key, value) { if (typeof GM_setValue === "undefined") { return localStorage.setItem(key, value); } return GM_setValue(key, value); }, storeDel: function(key) { if (typeof GM_deleteValue === "undefined") { return localStorage.removeItem(key); } return GM_deleteValue(key); }, //moves an item in an array - (given arr will be altered!) move: function(arr, old_index, new_index) { while (old_index < 0) { old_index += arr.length; } while (new_index < 0) { new_index += arr.length; } if (new_index >= arr.length) { let k = new_index - arr.length; while ((k--) + 1) { arr.push(undefined); } } arr.splice(new_index, 0, arr.splice(old_index, 1)[0]); return arr; } }; var SCRIPT_NAME = 'tiss_developer_tweaks'; var TISS_ENV_LIST_MAXSIZE = 7; Util.log('started'); let tissEnvList = [] let tissEnvListUnparsed = Util.storeGet('tissEnvList'); if (tissEnvListUnparsed==null) { // fill initial tissEnvList = [ { "host": 'tiss.tuwien.ac.at', "prot": 'https:', "text": 'Echtsystem!', "protect": true, "score": 0, "last_use": Date.now() } ] } else { Util.log('tissEnvListUnparsed: ' + tissEnvListUnparsed); tissEnvList = JSON.parse(tissEnvListUnparsed); } //Util.log('tissEnvList: ' + JSON.stringify(tissEnvList, null, " ")); var i = tissEnvList.findIndex(function (x) { return (x.host === window.location.host && x.prot===window.location.protocol); }); if (i===-1) { //aktuelle seite ist noch nicht in liste - in liste aufnehmen //vorher noch maxsize prüfen if(tissEnvList.length>TISS_ENV_LIST_MAXSIZE){ Util.log('tissEnvList wird zu lange. Letzter Link fliegt raus:' + tissEnvList[tissEnvList.length-1].text) tissEnvList.pop; }; tissEnvList.push({ "host": window.location.host, "prot": window.location.protocol, "text": window.location.host.replace('.tiss.tuwien.ac.at','').replace('devcloud','dc').replace('localhost','lh'), "protect": false, "score":0, "last_use": Date.now() }); Util.log('Neu in tissEnvList aufgenommen:' + tissEnvList[tissEnvList.length-1].text) } else { //aktuelle seite ist bereits in liste //score erhöhen tissEnvList[i].score++; tissEnvList[i].last_use=Date.now(); if (tissEnvList[i].protect===false && i>0 && tissEnvList[i-1].protect===false && tissEnvList[i].score > tissEnvList[i-1].score) { //um einen platz nach vorne sortieren Util.move(tissEnvList, i, i-1); Util.log(tissEnvList[i].text + 'rutscht mit score ' + tissEnvList[i].score + ' einen platz nach vorne! ') } //todo - eventuell den score aller anderen seiten verringern, die nicht innerhalb der letzten 3 tage aufgerufen wurden } //tissEnvList is now actual - write to local storage //Util.log('tissEnvList: ' + JSON.stringify(tissEnvList, null, " ")); Util.storeSet('tissEnvList', JSON.stringify(tissEnvList, null, " ")); function populateMenu() { var menu; menu = document.getElementsByClassName("clearfix toolNav")[0]; if (menu == null){ return } var li; var newLink; var text; var newSpan; for (var i = 0; i < tissEnvList.length; i++ ) { li = document.createElement("li"); newSpan = document.createElement("span"); if (window.location.host == tissEnvList[i].host) { text = document.createTextNode(tissEnvList[i].text); newSpan.appendChild(text); newSpan.setAttribute("style", "color:grey; font-weight: bold;"); newSpan.setAttribute("style", "color:grey; font-weight: bold; background: #FFFFFF; border-left: 1px solid #CDDAE1; border-right: 1px solid #CDDAE1; border-top: 1px solid #CDDAE1; padding-left:4px; padding-right:4px; background: linear-gradient(to top, #F5FAFD, #FFFFFF);"); } else { newLink = document.createElement("a"); newLink.setAttribute('href',tissEnvList[i].prot + '//' + tissEnvList[i].host + window.location.pathname + window.location.search + window.location.hash); newLink.innerHTML = tissEnvList[i].text; newSpan.appendChild(newLink); } li.appendChild(newSpan); menu.appendChild(li); } } populateMenu(); //////////////////////////////////////////////////////////////////////////////// //ECHTSYSTEM! - warning-bar //(kopiert von userstyle tiss-env-border https://userstyles.org/styles/121958/tiss-env-border) //@-moz-document regexp(".*[^\.]tiss[\.]tuwien[\.]ac[\.]at.*"){ body:before... } funktioniert leider nur im ff if (window.location.host == 'tiss.tuwien.ac.at') { GM_addStyle(` 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; } `); } //////////////////////////////////////////////////////////////////////////////// // mark current menu entry GM_addStyle(` #supNav ul li.currentPageItem > span > a { background: #FFFFFF; border-bottom: 1px solid #CDDAE1; border-top: 1px solid #CDDAE1; } .organisation #supNav ul li.currentPageItem > span > a { background: linear-gradient(to right, #DAC4F3, #F5FAFD, #F5FAFD, #F5FAFD, #F5FAFD, #FFFFFF); } .lehre #supNav ul li.currentPageItem > span > a { background: linear-gradient(to right, #DA923C, #F5FAFD, #F5FAFD, #F5FAFD, #F5FAFD, #FFFFFF); } .forschung #supNav ul li.currentPageItem > span > a { background: linear-gradient(to right, #9FC65A, #F5FAFD, #F5FAFD, #F5FAFD, #F5FAFD, #FFFFFF); } #shadow_top { z-index: 0;} `); //////////////////////////////////////////////////////////////////////////////// // fill unused space - use whole screen width GM_addStyle("body>#wrapper {max-width: 98%!important;}"); //////////////////////////////////////////////////////////////////////////////// Util.log('End');