Skip to content

Instantly share code, notes, and snippets.

@dogamak
Created March 5, 2024 14:40
Show Gist options
  • Save dogamak/26bdae168223d56457084facf1ac3628 to your computer and use it in GitHub Desktop.
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.
// ==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