Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@tkon99
Last active October 3, 2021 16:08
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 tkon99/ce19eebd7a82a89f82ad7c6d0b42b9b7 to your computer and use it in GitHub Desktop.
Save tkon99/ce19eebd7a82a89f82ad7c6d0b42b9b7 to your computer and use it in GitHub Desktop.
LSE Moodle automated login (stop clicking the same buttons every day)
// ==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