Created
February 6, 2018 21:35
-
-
Save malonehedges/95a7f1094b6585e326d7adca6ca7b805 to your computer and use it in GitHub Desktop.
Moodle Auto-Login
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 Moodle Auto-Login | |
// @namespace https://moodle.oxy.edu/ | |
// @version 0.1.0 | |
// @description Automatically redirect to the login page if logged out. | |
// @author Malone Hedges (https://malone.io) | |
// @match https://moodle.oxy.edu/* | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
var loginPageURL = 'https://moodle.oxy.edu/login/index.php'; | |
// Don't do anything if we're already on the login page | |
if (location.href === loginPageURL) { | |
return; | |
} | |
var userMenuClass = document.querySelector('div.usermenu').children[0].className; | |
// If we're logged out, the child of `div.usermenu` will be a `span.login`. | |
if (userMenuClass === 'login') { | |
// Redirect if we're logged out | |
location.href = loginPageURL; | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment