cackoa / erep Autologin

// ==UserScript==
// @author       cackoa
// @license      MIT
// @name         erep Autologin
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  performs autologin after erepepublik logout
// @author       cackoa
// @include      https://www.erepublik.com/en
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    var erep_login = 'login';
    var erep_password = 'pass';

  document.onreadystatechange = () => {
  if (document.readyState === 'complete') {
      var login = document.getElementById("citizen_email");
      if (typeof(login) != 'undefined' && login != null)
      {
          setTimeout(function() {
              if(login.value.length == 0){
                  login.value = erep_login;
                  document.getElementById("citizen_password").value = erep_password;
              }
              var buttons = document.getElementsByTagName('button');
              if(buttons.length > 0) {
                  buttons[0].click();
              }
          }, 40000);
      }
  }
};
})();