Created
March 5, 2024 14:40
-
-
Save dogamak/26bdae168223d56457084facf1ac3628 to your computer and use it in GitHub Desktop.
Removes events matching the given RegExes from the event calendar's sidebar, optionally preserving the first matching event.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name TKO-äly Event Calendar Blocklist | |
// @version 1 | |
// @grant none | |
// @include https://members.tko-aly.fi/ | |
// ==/UserScript== | |
const members = [ | |
{ pattern: /chess/, keepFirst: true }, | |
{ pattern: /liikuntavuoro/, keepFirst: true }, | |
{ pattern: /Board Game Weekly/, keepFirst: true }, | |
]; | |
const seen = new Array(BLOCKLIST.length).fill(false); | |
const events = document.querySelectorAll('#events_menu .event'); | |
[...events].forEach((el) => { | |
let matches = false; | |
BLOCKLIST.forEach(({ pattern, keepFirst }, i) => { | |
const match = el.innerText.match(pattern); | |
if (match && (!keepFirst || seen[i])) { | |
matches = true; | |
} | |
if (match) { | |
seen[i] = true; | |
} | |
}); | |
if (matches) { | |
el.style.display = 'none'; | |
el.nextElementSibling.style.display = 'none'; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment