-
Notifications
You must be signed in to change notification settings - Fork 0
/
PlanmillTodayColumnHighlighter.user.js
41 lines (34 loc) · 1.62 KB
/
PlanmillTodayColumnHighlighter.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// ==UserScript==
// @name Planmill Today Column Highlighter
// @version 1.2
// @description Highlight the column from 'today' element to a specified link with adjustment
// @match *://online.planmill.com/*
// @grant none
// @run-at document-end
// @updateURL https://raw.githubusercontent.com/alfameCom/GreasemonkeyScripts-QOL-collection/main/PlanmillTodayColumnHighlighter.user.js
// ==/UserScript==
(function() {
'use strict';
const highlightDiv = document.createElement('div');
document.body.appendChild(highlightDiv);
highlightDiv.style.backgroundColor = 'rgba(255, 255, 0, 0.2)';
highlightDiv.style.zIndex = '899';
highlightDiv.style.pointerEvents = 'none';
highlightDiv.style.position = 'fixed';
function updateHighlight() {
const startElement = document.querySelector('th.today');
const endBoundaryElement = document.getElementById('timecard-toggle-btn');
if (startElement && endBoundaryElement) {
const startRect = startElement.getBoundingClientRect();
const endBoundaryRect = endBoundaryElement.getBoundingClientRect();
const highlightTop = startRect.top + window.scrollY;
const highlightHeight = endBoundaryRect.top - startRect.top;
highlightDiv.style.left = `${startRect.left}px`;
highlightDiv.style.top = `${highlightTop}px`;
highlightDiv.style.width = `${startRect.width}px`;
highlightDiv.style.height = `${highlightHeight}px`;
}
}
setTimeout(updateHighlight, 100);
window.addEventListener('resize', updateHighlight);
})();