供参考 - 我到目前为止的代码:
HTML正文
<!-- 通过添加 calendar-page 类到 body 来标记日历页面 -->
<script>
// 检查 URL 是否以 "/calendar" 结尾
if (window.location.href.endsWith("/calendar")) {
// 向 body 添加一个类来触发 CSS 规则
document.body.classList.add('calendar-page');
}
</script>
<!-- 在日历屏幕上将“添加主题”更改为“添加事件” -->
<script>
// 检查 body 是否具有类 "hide-on-calendar"
if (document.body.classList.contains('calendar-page')) {
// 更新按钮的文本
const button = document.querySelector('.main-content.calendar .d-button-label');
if (button) {
button.textContent = 'Add Event';
}
}
</script>
CSS
//隐藏非活动事件类别
body.calendar-page li.select-kit-row.category-row[title]:not([title="Private Events"]):not([title="Public Events"]):not([title="Induction Sessions"]):not([title="Space Bookings"]) {
display: none;
}
如果有人对如何获取插件设置的类别值(在这种情况下是 Events 插件的“允许将事件添加到此类别中的主题”设置)有任何建议,这样我就不必硬编码类别了,那将是极好的……但我知道这有点贪心。