Skip to content

Instantly share code, notes, and snippets.

@CSymes
Last active April 20, 2018 11:46
Show Gist options
  • Save CSymes/a287349bf732a8b018762e3370ddf153 to your computer and use it in GitHub Desktop.
Save CSymes/a287349bf732a8b018762e3370ddf153 to your computer and use it in GitHub Desktop.
I got sick of having to slowly scroll down discussions on Canvas, so made a userscript to mark all unread posts as read for me. Adds a button to the header on each discussion page.
// ==UserScript==
// @name Canvas 'Mark All as Read'
// @namespace com.plasticsquid.canvas.read
// @version 1.0
// @description Adds a button to allow marking of all posts as read in a Canvas discussion
// @author Cary Symes
// @match https://*.instructure.com/courses/*/discussion_topics/*
// @grant none
// ==/UserScript==
// DISCLAIMER
// I threw this together in an enraged fury, and so cannot guarantee that
// it is in any way, shape or form bug-free or even unlikely
// to cause the apocalypse. But hey, at least it works on my machine.
// Also any change to Canvas may break this at any time.
// Hosted at https://gist.github.com/CSymes/a287349bf732a8b018762e3370ddf153
function MarkAsRead() {
// Click on all unread indicators (case insensitive)
$('a.discussion-read-state-btn[title="Mark as Read" i]').click();
// Will mark them as read
}
(function() {
'use strict';
// Header of the discussion page - already contains buttons
var header = $('#discussion-toolbar .span9');
// Let's add another
var marker = $('<button/>', {
text: 'Mark All As Read',
id: 'MAAR',
class: 'btn', // Style it like the other buttons
click: MarkAsRead // Callback
});
marker.css('margin-left', '1em'); // Pad it apart from the other buttons
header.append(marker);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment