Last active
April 20, 2018 11:46
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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