Skip to content

Instantly share code, notes, and snippets.

@billmei
Created January 14, 2021 16:17
Show Gist options
  • Select an option

  • Save billmei/44a5c48b46ea3ace70bd36852197e55e to your computer and use it in GitHub Desktop.

Select an option

Save billmei/44a5c48b46ea3ace70bd36852197e55e to your computer and use it in GitHub Desktop.

Revisions

  1. billmei created this gist Jan 14, 2021.
    49 changes: 49 additions & 0 deletions keepalive.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,49 @@
    // ==UserScript==
    // @name KeepAlive
    // @namespace https://billmei.net
    // @version 0.1
    // @description Prevents Queen's MyCareer, Moodle, and D2L from timing out
    // @include https://careers.sso.queensu.ca/*
    // @include https://moodle.queensu.ca/*
    // @include https://qsblearning.ca/*
    // @copyright 2014, Bill Mei
    // ==/UserScript==

    // MyCareer
    if (document.location.hostname === "careers.sso.queensu.ca") {
    countdownNum = null;
    countdownInterval = null;
    beginCountdown = null;
    countdown = null;
    sessionTimeoutTimeout = null;
    sessionTimeoutPopup = function() {
    keepMeLoggedIn.open('get', '/keepAlive.html?rand=' + Math.floor(Math.random()*100000));
    keepMeLoggedIn.send(null);
    };
    }

    // Moodle
    if (document.location.hostname === "moodle.queensu.ca") {
    var keepalive_timeout = setTimeout(function(){
    M.ajax_warn_logout.showBar = function() {
    var url = M.cfg.wwwroot + '/local/ajax_logout_warn/ajax_renew.php',
    cfg = {
    method: 'GET',
    on: {
    complete: function(id, o, p) {
    M.ajax_warn_logout.resetTimer();
    }
    }
    };
    Y.io(url, cfg);
    };
    M.ajax_warn_logout.showBar();
    clearTimeout(keepalive_timeout);
    }, (3*1000));
    }

    // D2L
    if (document.location.hostname === "qsblearning.ca") {
    D2L.PT.Auth.SessionTimeout.Expire = null;
    D2L.PT.Auth.SessionTimeout.IsExpired = function(){return false;};
    }