// ==UserScript== // @name TUM Live Servus // @namespace TUM-Live-Addons // @match https://live.rbg.tum.de/* // @grant none // @require https://cdn.jsdelivr.net/gh/sizzlemctwizzle/GM_config@2207c5c1322ebb56e401f03c2e581719f909762a/gm_config.js // @version 0.1.2 // @author Max Lang // @license 0BSD // @description Uses Bavarian greeting on TUM Live. // @downloadURL https://update.greasyfork.cloud/scripts/444361/TUM%20Live%20Servus.user.js // @updateURL https://update.greasyfork.cloud/scripts/444361/TUM%20Live%20Servus.meta.js // ==/UserScript== /* License (BSD Zero Clause License): Copyright (C) 2022 by Max Lang Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ (function() { const style = document.createElement('style'); style.textContent = '.tum-live-servus-error { color: #b22734; }\n' + 'html.dark .tum-live-servus-error { color: #efa7c4; }'; document.head.appendChild(style); function updateGreetings() { const funcStr = `"use strict"; return (${GM_config.get('GreetingFormat')});`; const greetingSupplier = new Function(funcStr)(); document.querySelectorAll('.tum-live-servus-greeting').forEach(node => { try { node.replaceChildren(greetingSupplier(node.dataset.tumLiveServusName, node)); } catch (e) { console.error('Exception raised while evaluating format function:', funcStr, e); const p = document.createElement('p'); const code = document.createElement('code'); code.classList.add('tum-live-servus-error'); code.textContent = e; p.append('Exception: ', code); node.replaceChildren(p); } }); } const greetingFormatLabel = document.createElement('label') greetingFormatLabel.for = 'TUMLiveServusConfig_field_GreetingFormat'; greetingFormatLabel.innerHTML = '
Any function-expression taking (up to) two arguments:\n' + '
name
Evaluated in the global scope using Function
.