Last active
October 3, 2021 16:08
-
-
Save tkon99/ce19eebd7a82a89f82ad7c6d0b42b9b7 to your computer and use it in GitHub Desktop.
LSE Moodle automated login (stop clicking the same buttons every day)
This file contains 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 LSE Moodle automation | |
// @namespace http://tkon.nl | |
// @version 0.1 | |
// @description Automate tedious LSE moodle login stuff | |
// @author You | |
// @match https://moodle.lse.ac.uk/* | |
// @icon https://moodle.lse.ac.uk/theme/image.php/synergycustom/theme/1633074455/favicon | |
// @require https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
console.log("Automation loaded"); | |
$(document).ready(function(){ | |
switch(location.pathname){ | |
case "/": // check if logged in, if not then log in | |
var loginlink = $(".usermenu .login a"); | |
if(loginlink.text() == "Log in"){ | |
window.location.href = loginlink.attr("href"); | |
} | |
break; | |
case "/login/index.php": // automatically click login button | |
var button = document.getElementsByClassName("potentialidp")[1]; | |
var link = $(button).find("a").attr("href"); | |
window.location.href = link; | |
break; | |
} | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment