Created
          January 19, 2021 15:42 
        
      - 
      
- 
        Save schu/55a89e539a9e146ecee21110f3c7d7e2 to your computer and use it in GitHub Desktop. 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | // ==UserScript== | |
| // @name Stay logged in | |
| // @version 1 | |
| // @grant none | |
| // @include https://www.example.com/* | |
| // ==/UserScript== | |
| function keepalive() { | |
| //console.log('Sending HTTP HEAD request to: ' + location.href); | |
| var req = new XMLHttpRequest(); | |
| req.open('HEAD', location.href); | |
| req.onreadystatechange = function() { | |
| if (req.readyState === XMLHttpRequest.DONE) { | |
| var status = req.status; | |
| if (status === 0 || (status >= 200 && status < 400)) { | |
| //console.log('Success: ' + status); | |
| } else { | |
| console.log('HTTP Error: ' + status); | |
| } | |
| } | |
| }; | |
| req.onerror = function() { | |
| console.log('Network Error: request failed'); | |
| }; | |
| req.send(); | |
| }; | |
| setInterval(keepalive, 10 * 60 * 1000); | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment