Lectio autologin

Automatisk login til Lectio

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

You will need to install an extension such as Tampermonkey to install this script.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name Lectio autologin
// @namespace https://greasyfork.org/en/users/8372-sbares
// @description Automatisk login til Lectio
// @include http*://www.lectio.dk/*
// @version 1.0.2.5
// @noframes
// @grant GM_getValue
// @grant GM_setValue
// ==/UserScript==
var autologin = GM_getValue('lectio_autologin', true);
function toggleFunction() {
  GM_setValue('lectio_autologin', !autologin);
  location.reload();
}
exportFunction(toggleFunction, unsafeWindow, {
  defineAs: 'toggleFunction'
});
var elem = document.getElementById('s_m_mastermenu');
if (!elem) elem = document.getElementById('m_mastermenu');
var node = elem.childNodes[1];
var innerText = 'Slå autologin til';
if (autologin) {
  innerText = 'Slå autologin fra';
}
node.innerHTML = node.innerHTML + '<div class="button"><a id="m_toggle_autologin" href="javascript:toggleFunction();">' + innerText + '</a></div>';
if (!String.contains(location, 'login.aspx')) {
  return;
}
var usernameTextbox = document.getElementById('m_Content_username2');
var passwordTextbox = document.getElementById('password2');
var submitButton = document.getElementById('m_Content_submitbtn2');
var username = GM_getValue('lectio_username', '');
var password = GM_getValue('lectio_password', '');
if (autologin && username != '' && password != '') {
  usernameTextbox.value = username;
  passwordTextbox.value = password;
  submitButton.onclick();
} 
else {
  function submitFunction() {
    setTimeout(function () {
      GM_setValue('lectio_username', username);
      GM_setValue('lectio_password', password);
    });
  }
  function usernameFunction() {
    setTimeout(function () {
      username = usernameTextbox.value;
    });
  }
  function passwordFunction() {
    setTimeout(function () {
      password = passwordTextbox.value;
    });
  }
  exportFunction(submitFunction, unsafeWindow, {
    defineAs: 'submitFunction'
  });
  exportFunction(usernameFunction, unsafeWindow, {
    defineAs: 'usernameFunction'
  });
  exportFunction(passwordFunction, unsafeWindow, {
    defineAs: 'passwordFunction'
  });
  submitButton.setAttribute('onclick', 'submitFunction(); ' + submitButton.getAttribute('onclick'));
  usernameTextbox.setAttribute('onkeypress', usernameTextbox.getAttribute('onkeypress') + '; usernameFunction()');
  passwordTextbox.setAttribute('onkeypress', passwordTextbox.getAttribute('onkeypress') + '; passwordFunction()');
}