Skip to content

Instantly share code, notes, and snippets.

@realgt
Created March 28, 2020 23:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save realgt/cf8d7c39b2cd0e0072cfbf671b980dc0 to your computer and use it in GitHub Desktop.
Save realgt/cf8d7c39b2cd0e0072cfbf671b980dc0 to your computer and use it in GitHub Desktop.
Turn Blackbaud assignments into a todo list
// ==UserScript==
// @name Blackbaud Assignments TODO
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Turns Assignment list into a Todo list!
// @author Fabio Rodriguez <realgt@gmail.com>
// @require https://code.jquery.com/jquery-2.2.4.min.js
// @require https://raw.github.com/emn178/js-sha1/master/build/sha1.min.js
// @include https://*.myschoolapp.com/app/*
// @grant none
// ==/UserScript==
(function($) {
'use strict';
if(typeof sha1 == "undefined") return;
let profileId = window.location.hash.split("/")[1];
let renderTodo = function(){
if ($("#assignment-center-assignment-items").length > 0) {
if ($('#todo-header').length == 0){
$(".add-existing-items-header").prepend("<th id='todo-header' width='5%'>To Do</th>");
}
$("#assignment-center-assignment-items tr").each(function(){
var row=$(this);
var rowId = sha1(row.text().trim().replace(/\s\s+/g, ' ').replace(/ /g,"_"));
row.prepend("<input class='todo' type='checkbox' id='" + rowId + "' style='width: 25px; height: 25px;'>");
});
//add event handler to set value
$(".todo").click(function(e){
var id = $(this).attr("id");
var checked = this.checked
//basically we're setting the sha1 hash of the line as the id and whether its done or not
localStorage.setItem(profileId + id,checked);
});
//loop over each item and set the check if its been done
$(".todo").each(function(){
var id = $(this).attr("id");
var checked = localStorage.getItem(profileId + id) === "true";
$(this).attr("checked",checked);
});
} else {
console.debug("no assignments found");
}
}
//trigger on page load
$(document).ready(function() {
setTimeout(function(){
renderTodo();
//add trigger on calendar button click
$(".assignment-calendar-header").click(function(){
setTimeout(function(){
renderTodo();
},1000);
});
},2000);
});
//trigger on hash change
window.onhashchange = function() {
setTimeout(function(){
renderTodo();
},1000);
};
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment