diff --git a/background.js b/background.js index 73248633..fa0ee486 100644 --- a/background.js +++ b/background.js @@ -13,6 +13,7 @@ chrome.storage.local.get(['enabledOWAFetch', 'NumberOfUnreadMails'], (resp) => { console.log('Loaded TUfast') chrome.storage.local.set({loggedOutSelma: false}, function() {}) +chrome.storage.local.set({loggedOutElearningMED: false}, function() {}) chrome.storage.local.set({loggedOutTumed: false}, function() {}) chrome.storage.local.set({loggedOutQis: false}, function() {}) chrome.storage.local.set({loggedOutOpal: false}, function() {}) diff --git a/contentScripts/content_elearningMED.js b/contentScripts/content_elearningMED.js new file mode 100644 index 00000000..507986c4 --- /dev/null +++ b/contentScripts/content_elearningMED.js @@ -0,0 +1,29 @@ +chrome.storage.local.get(['loggedOutElearningMED'], function(result) { + console.log(result.loggedOutElearningMED) + if(!result.loggedOutElearningMED) { + if (document.readyState !== 'loading') { + loginElearningMED(result.loggedOutElearningMED) + } else { + document.addEventListener('DOMContentLoaded', function () { + loginElearningMED(result.loggedOutElearningMED) + }) + } + console.log('Auto Login to elearning.med.') + } +}) + +function loginElearningMED(loggedOutElearningMED){ + if (document.getElementsByTagName("a")[0].textContent === "Moodle" && location.href === "https://elearning.med.tu-dresden.de/") { + document.getElementsByTagName("a")[0].click() + } else if (location.href === "https://elearning.med.tu-dresden.de/moodle/academiLogin.html" && document.querySelectorAll('[href="https://elearning.med.tu-dresden.de/moodle/auth/shibboleth/index.php"]')[0]) { + document.querySelectorAll('[href="https://elearning.med.tu-dresden.de/moodle/auth/shibboleth/index.php"]')[0].click() + } + + //detecting logout + if (document.getElementById("actionmenuaction-6")) { + document.getElementById("actionmenuaction-6").addEventListener('click', function () { + console.log("logout detected!") + chrome.runtime.sendMessage({ cmd: 'logged_out', portal: 'loggedOutElearningMED' }) + }) + } +} \ No newline at end of file diff --git a/manifest.json b/manifest.json index afaadaac..fd1a3a73 100644 --- a/manifest.json +++ b/manifest.json @@ -13,6 +13,11 @@ "persistent": false }, "content_scripts": [ + { + "js": ["contentScripts/content_elearningMED.js"], + "run_at": "document_start", + "matches": ["https://elearning.med.tu-dresden.de/*"] + }, { "js": [ "contentScripts/content_fwd_opalError.js"