Skip to content

Instantly share code, notes, and snippets.

@nhoffman
Last active May 31, 2022 20:55
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 nhoffman/2cfd76df965bea1f17558628aedfd723 to your computer and use it in GitHub Desktop.
Save nhoffman/2cfd76df965bea1f17558628aedfd723 to your computer and use it in GitHub Desktop.
userscript for medialab inspection proof
// ==UserScript==
// @name medialab_cap_topics
// @namespace http://tampermonkey.net/
// @version 0.6
// @description Add a menu to MediaLab inspection proof to filter CAP checklist items
// @author Noah Hoffman
// @match https://www.medialab.com/lms/admin/ad_ic_viewchecklist.aspx?*
// @require http://code.jquery.com/jquery-3.4.1.min.js
// @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant none
// @downloadUrl https://gist.github.com/nhoffman/2cfd76df965bea1f17558628aedfd723/raw/medialab_cap_topics.user.js
// @updateUrl https://gist.github.com/nhoffman/2cfd76df965bea1f17558628aedfd723/raw/medialab_cap_topics.user.js
// ==/UserScript==
var topics = [
{
value: "all",
text: "All items",
items: []
},
{
value: "informatics",
text: "Informatics",
items: [
"COM.04050", "COM.10000", "COM.10100", "COM.10200", "COM.10300",
"COM.10500", "COM.29950", "COM.30000", "COM.30100", "COM.40630",
"COM.40800", "GEN.42195", "GEN.42750", "GEN.42800", "GEN.42900",
"GEN.43022", "GEN.43033", "GEN.43035", "GEN.43037", "GEN.43040",
"GEN.43055", "GEN.43066", "GEN.43150", "GEN.43200", "GEN.43262",
"GEN.43325", "GEN.43335", "GEN.43450", "GEN.43750", "GEN.43800",
"GEN.43825", "GEN.43837", "GEN.43875", "GEN.43876", "GEN.43878",
"GEN.43881", "GEN.43887", "GEN.43890", "GEN.43893", "GEN.43900",
"GEN.43910", "GEN.43920", "GEN.43946", "GEN.46000", "GEN.48500",
"GEN.48750", "GEN.50057", "GEN.50614", "GEN.50630", "GEN.51728",
"GEN.52842", "GEN.52850", "GEN.52860", "GEN.52900", "GEN.52920"]
},
{
value: "ngs_analytics",
text: "NGS Analytics",
items: [
"MOL.35860", "MOL.35865", "MOL.35870", "MOL.36035", "MOL.36105",
"MOL.36115", "MOL.36117", "MOL.36125", "MOL.36135", "MOL.36145"
]
}
];
(function() {
'use strict';
$("#ctl00_pageTitleLabel").text("Inspection Proof (with topic filter)");
$("select#filteroptions").after("<select id=\"select-topic\" class=\"form-control\"></select>");
var topicmap = {};
$.each(topics, function(i, topic){
$("select#select-topic").append($('<option>/', {value: topic.value, text: topic.text}));
topicmap[topic.value] = topic.items;
});
function hide_all(){
$('table tr').each(function(i, row){
$(row).hide();
});
};
function show_items(items){
$('table tr').each(function(i, row){
let item = $(row).find( "> td:nth-child(2) a" ).text();
if($.inArray(item, items) != -1){
$(row).show();
}
});
};
$("select#select-topic").change(function(){
hide_all();
let items = topicmap[$(this).val()];
if(items.length > 0){show_items(items)};
});
})();
@nhoffman
Copy link
Author

Filters CAP checklist items by user-defined categories.

  • Install the Tampermonkey Chrome extension
  • Add this script by pasting the url for the raw gist into Chrome (see @downloadUrl above)
  • Visit the Inspection Proof module in MediaLab. The title should be updated to "Inspection Proof (with topic filter)", and an additional drop down menu should be visible.

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