Skip to content

Instantly share code, notes, and snippets.

@AstroCB
Created October 17, 2019 02:59
Show Gist options
  • Save AstroCB/5b34b657a55c16234bf5d9c9435d053d to your computer and use it in GitHub Desktop.
Save AstroCB/5b34b657a55c16234bf5d9c9435d053d to your computer and use it in GitHub Desktop.
Small script that adds a button to the Piazza toolbar to mark all posts in the currently selected class as read.
// Button to mark all posts as read
function makeButton() {
let button = document.createElement("button");
button.setAttribute("id", "new_post_button");
button.setAttribute("class", "btn-primary left btn-small");
button.addEventListener("click", _ => {
// Clear unread posts and reload page
document.querySelectorAll(".unread").forEach(b => b.click());
window.location.reload();
});
let text = document.createElement("i");
text.setAttribute("class", "icon-check icon-white");
button.appendChild(text);
return button;
}
let toolbar = document.querySelector("#feed_search");
toolbar.insertBefore(makeButton(), toolbar.children[0]);
@AstroCB
Copy link
Author

AstroCB commented Oct 17, 2019

I recommend adding this as a userscript that runs on page load for ease of use.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment