Skip to content

Instantly share code, notes, and snippets.

@ericswpark
Last active May 5, 2024 21:18
Show Gist options
  • Save ericswpark/377b1220877108434bc9bab9b35d1fef to your computer and use it in GitHub Desktop.
Save ericswpark/377b1220877108434bc9bab9b35d1fef to your computer and use it in GitHub Desktop.
Bookmarklet for marking all discussion posts as read on D2L Brightspace
javascript:void%20function(){const%20a=new%20MouseEvent(%22mouseup%22),b=document.querySelector(%22%23topicContextMenu%22).shadowRoot.querySelector(%22d2l-button-icon%22);b.dispatchEvent(a),(a=%3Enew%20Promise(b=%3EsetTimeout(b,a)))(5e2).then(()=%3E{const%20a=document.querySelector(%22%23d2l_pageTitleActions_markAllRead%22);a.click()})}();
const delay = ms => new Promise(res => setTimeout(res, ms));
// Open topic context menu
const mouseup_event = new MouseEvent("mouseup");
const chevron = document.querySelector("#topicContextMenu").shadowRoot.querySelector("d2l-button-icon");
chevron.dispatchEvent(mouseup_event);
// Wait for context menu to open
delay(500).then(()=> {
// Click on mark all read element
const mark_all_as_read = document.querySelector("#d2l_pageTitleActions_markAllRead");
mark_all_as_read.click();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment