diff --git a/innsida-custom-css.user.js b/innsida-custom-css.user.js new file mode 100644 index 0000000..c1fd56e --- /dev/null +++ b/innsida-custom-css.user.js @@ -0,0 +1,111 @@ +// ==UserScript== +// @name Custom CSS and Text Removal for innsida.ntnu.no +// @namespace http://tampermonkey.net/ +// @version 1.0 +// @description Apply custom CSS and remove text in innsida.ntnu.no +// @author Magnus Børnes (magnborn@ntnu.no) +// @match https://innsida.ntnu.no/* +// @icon https://www.google.com/s2/favicons?sz=64&domain=ntnu.no +// @grant none +// @updateURL https://git.ntnu.no/M365-Drift/MonkeyMagic/raw/main/innsida-custom-css.user.js +// @downloadURL https://git.ntnu.no/M365-Drift/MonkeyMagic/raw/main/innsida-custom-css.user.js +// ==/UserScript== + +(function() { + 'use strict'; + + // Function to apply custom CSS + function applyCustomCSS() { + var css = ` + .content-width { + max-width: 100% !important; + } + + /* Åpnede saker */ + .svelte-1y4o19j { + margin:0 !important; + border: 0 0 0 10px #F00 solid; + } + article a { + font-weight: 100 !important; + } + .floating-iframe { + position: absolute; + bottom: 0; + left: 0; + width: 100%; + height: 600px; + border: none; + } + aside { + position: relative; + } + `; + var style = document.createElement('style'); + style.type = 'text/css'; + style.appendChild(document.createTextNode(css)); + document.head.appendChild(style); + } + + // Function to remove text content after delimiters + function removeTextContent() { + var links = document.querySelectorAll('article a'); + links.forEach(function(link) { + var text = link.textContent; + var patterns = [ + ' / ', ' | ', + ' \u00A0/\u00A0 ', ' \u00A0|\u00A0 ', + ' /\u00A0', '\u00A0/ ', + ' |\u00A0', '\u00A0| ' + ]; + var removed = false; + patterns.forEach(function(pattern) { + var index = text.indexOf(pattern); + if (index !== -1 && !removed) { + link.textContent = text.substring(0, index); + removed = true; + } + }); + }); + } + + // New function to insert iframe + function insertIframe() { + setTimeout(function() { + var iframe = document.createElement('iframe'); + iframe.src = 'https://copilotstudio.microsoft.com/environments/Default-09a10672-822f-4467-a5ba-5bb375967c05/bots/cre79_ntnuCopilot/webchat?__version__=2'; + iframe.className = 'floating-iframe'; + + var targetElement = document.evaluate('/html/body/div/div[2]/aside', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; + if (targetElement) { + targetElement.appendChild(iframe); + console.log('XPath found: iframe inserted.'); + } else { + document.body.appendChild(iframe); + console.log('XPath not found: iframe added to body.'); + } + }, 2000); // Delay of 2000 milliseconds + } + + // Function to observe DOM changes + function observeDOMChanges() { + var observer = new MutationObserver(function(mutations) { + mutations.forEach(function(mutation) { + if (mutation.addedNodes.length) { + applyCustomCSS(); + removeTextContent(); + } + }); + }); + + observer.observe(document.body, { childList: true, subtree: true }); + } + + // Initial application of custom CSS and text removal + applyCustomCSS(); + removeTextContent(); + insertIframe(); + + // Start observing DOM changes + observeDOMChanges(); +})(); diff --git a/topdesk-highlight-summary.user.js b/topdesk-highlight-summary.user.js new file mode 100644 index 0000000..611592c --- /dev/null +++ b/topdesk-highlight-summary.user.js @@ -0,0 +1,47 @@ +// ==UserScript== +// @name TOPdesk - Highlight Summary +// @namespace http://tampermonkey.net/ +// @version 1.0 +// @description Highlight the summary section in a box with rounded corners and white background +// @author Magnus Børnes (magnborn@ntnu.no) +// @match https://hjelp.ntnu.no/* +// @icon https://www.google.com/s2/favicons?sz=64&domain=topdesk.com +// @grant none +// @updateURL https://git.ntnu.no/M365-Drift/MonkeyMagic/raw/main/topdesk-highlight-summary.user.js +// @downloadURL https://git.ntnu.no/M365-Drift/MonkeyMagic/raw/main/topdesk-highlight-summary.user.js +// ==/UserScript== + +(function() { + 'use strict'; + + // Function to highlight the summary + function highlightSummary() { + // Find all div elements + const divs = document.querySelectorAll('div'); + + divs.forEach(div => { + // Get the inner HTML of the div + let html = div.innerHTML; + + // Match the summary text + const summaryMatch = html.match(/
Summary: (.*?)\.

/); + + if (summaryMatch) { + // Extract the summary text + const summaryText = summaryMatch[0]; + + // Create a highlighted box + const highlightedBox = `
${summaryText}
`; + + // Replace the summary text with the highlighted box + html = html.replace(summaryText, highlightedBox); + + // Update the div's inner HTML + div.innerHTML = html; + } + }); + } + + // Run the function to highlight the summary + highlightSummary(); +})();