Lectio autologin

Automatisk login til Lectio

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

ستحتاج إلى تثبيت إضافة مثل 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()');
}