Skip to content

Commit

Permalink
Update topdesk-highlight-summary.user.js
Browse files Browse the repository at this point in the history
(Hopefully) fixed accidentally tampering (pun intended) with Øyvind's tampermonkey script.
  • Loading branch information
magnborn authored and GitHub Enterprise committed Oct 23, 2024
1 parent 832fd97 commit 597dfc2
Showing 1 changed file with 19 additions and 17 deletions.
36 changes: 19 additions & 17 deletions topdesk-highlight-summary.user.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// ==UserScript==
// @name TOPdesk - Highlight Summary
// @namespace http://tampermonkey.net/
// @version 1.1
// @version 1.2
// @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/*
Expand All @@ -16,8 +16,8 @@

// Function to highlight the summary
function highlightSummary() {
// Find all div elements
const divs = document.querySelectorAll('div');
// Find all div elements with specific class or attribute
const divs = document.querySelectorAll('div[guielement="crt-content-label"]');

divs.forEach(div => {
// Get the inner HTML of the div
Expand Down Expand Up @@ -49,20 +49,22 @@
});
}

// Run the function to highlight the summary
highlightSummary();
// Run the function to highlight the summary after the DOM is fully loaded
document.addEventListener('DOMContentLoaded', () => {
highlightSummary();

// Debounce function to limit the frequency of highlightSummary calls
function debounce(func, wait) {
let timeout;
return function(...args) {
clearTimeout(timeout);
timeout = setTimeout(() => func.apply(this, args), wait);
};
}
// Debounce function to limit the frequency of highlightSummary calls
function debounce(func, wait) {
let timeout;
return function(...args) {
clearTimeout(timeout);
timeout = setTimeout(() => func.apply(this, args), wait);
};
}

// Reapply the highlighting 1 second after the window is resized
window.addEventListener('resize', debounce(() => {
highlightSummary();
}, 1000));
// Reapply the highlighting 1 second after the window is resized
window.addEventListener('resize', debounce(() => {
highlightSummary();
}, 1000));
});
})();

0 comments on commit 597dfc2

Please sign in to comment.