Skip to content

Commit

Permalink
added elearning.med portal
Browse files Browse the repository at this point in the history
  • Loading branch information
OliEfr committed Dec 31, 2020
1 parent 91287d7 commit db113c8
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
1 change: 1 addition & 0 deletions background.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {})
Expand Down
29 changes: 29 additions & 0 deletions contentScripts/content_elearningMED.js
Original file line number Diff line number Diff line change
@@ -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' })
})
}
}
5 changes: 5 additions & 0 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit db113c8

Please sign in to comment.