Skip to content

Instantly share code, notes, and snippets.

@gelbermann
Last active October 22, 2020 21:20
Show Gist options
  • Save gelbermann/56f9efaaf4de7789a7693b601cc92a1e to your computer and use it in GitHub Desktop.
Save gelbermann/56f9efaaf4de7789a7693b601cc92a1e to your computer and use it in GitHub Desktop.
GreaseMonkey: course-links from GR++ homepage
// ==UserScript==
// @name Make table content link to correct course
// @version 1
// @grant none
// @include https://grades.cs.technion.ac.il/*
// ==/UserScript==
let allFields = Array.from(document.getElementsByClassName("black-text")).slice(0,-1);
for(let i = 0 ; i < allFields.length / 2 ; i++) {
// Make titles into links for visibility
let courseNum = allFields[2*i].innerHTML;
let courseName = allFields[2*i + 1].innerHTML;
allFields[2*i].innerHTML = `<a href='#'>${courseNum}</a>`;
allFields[2*i + 1].innerHTML = `<a href='#'>${courseName}</a>`;
// Add the correct functionality to titles
// (The best way would be to ues the 'go' function under stud_library.js,
// but it requires some more investigation)
allFields[2*i].onclick = function() {
document.forms.SubSub.RecreatePath.value = `5-${i}`;
document.forms.SubSub.submit();
}
allFields[2*i+1].onclick = allFields[2*i].onclick;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment