-
Notifications
You must be signed in to change notification settings - Fork 0
/
GoogleCalendarBlurEventTextToggler.user.js
66 lines (56 loc) · 2.53 KB
/
GoogleCalendarBlurEventTextToggler.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// ==UserScript==
// @name Blur Text in Google Calendar Events with Toggle
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Blurs only the text content of calendar events in Google Calendar, with a toggle to turn the blurring on and off
// @match *://calendar.google.com/*
// @updateURL https://github.com/alfameCom/GreasemonkeyScripts-QOL-collection/edit/main/GoogleCalendarBlurEventTextToggler.user.js
// @grant none
// ==/UserScript==
(function() {
'use strict';
let blurEnabled = false;
const style = document.createElement('style');
document.head.appendChild(style);
let styleSheetIndex = style.sheet.insertRule('.NlL62b.GTG3wb.elYzab-cXXICe-Hjleke span { filter: none; }', 0);
function createToggleButton() {
const toggleBtn = document.createElement('div');
toggleBtn.innerHTML = blurEnabled ? '🙈' : '🙉';
toggleBtn.style.cssText = 'position: fixed; bottom: 20px; left: 20px; z-index: 1000; font-size: 36px; cursor: pointer;';
toggleBtn.title = 'Toggle text blurring';
toggleBtn.addEventListener('click', () => {
blurEnabled = !blurEnabled;
toggleBtn.innerHTML = blurEnabled ? '🙈' : '🙉';
updateBlurEffect();
});
document.body.appendChild(toggleBtn);
}
function updateBlurEffect() {
if (blurEnabled) {
style.sheet.deleteRule(styleSheetIndex);
styleSheetIndex = style.sheet.insertRule('.NlL62b.GTG3wb.elYzab-cXXICe-Hjleke span { filter: blur(4px); }', 0);
} else {
style.sheet.deleteRule(styleSheetIndex);
styleSheetIndex = style.sheet.insertRule('.NlL62b.GTG3wb.elYzab-cXXICe-Hjleke span { filter: none; }', 0);
}
}
const observer = new MutationObserver(mutations => {
mutations.forEach(mutation => {
if (mutation.type === 'childList' && mutation.addedNodes.length > 0) {
mutation.addedNodes.forEach(node => {
if (node.nodeType === Node.ELEMENT_NODE) {
const textElements = node.querySelectorAll('.NlL62b.GTG3wb.elYzab-cXXICe-Hjleke .ynRLnc');
textElements.forEach(textElement => {
textElement.style.filter = blurEnabled ? 'blur(4px)' : 'none';
});
}
});
}
});
});
observer.observe(document.body, {
childList: true,
subtree: true
});
createToggleButton();
})();