Oracle Cloud Console Session Keep-Alive

keep Oracle Cloud Console session alive by making AJAX requests

  1. // ==UserScript==
  2. // @name Oracle Cloud Console Session Keep-Alive
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.3
  5. // @description keep Oracle Cloud Console session alive by making AJAX requests
  6. // @author Your Name
  7. // @match https://cloud.oracle.com/*
  8. // @grant none
  9. // @license MIT
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. // Configure the request interval (in milliseconds).
  16. var requestInterval = 60000; // 1 min
  17. if(!window.oracleCloudkeepAliveScriptInitialized) window.oracleCloudkeepAliveScriptInitialized=1; else return;
  18.  
  19. setInterval(function() {
  20. // URL to request; ensure it's correct and allowed to be requested from the browser.
  21. var url = 'https://cloud.oracle.com/plugins/compute/latest/prod-oc1-index.tpl.html?region=sa-saopaulo-1';
  22.  
  23. // Fetch the URL
  24. fetch(url, {
  25. method: 'GET', // or 'POST' depending on what's necessary for your context
  26. credentials: 'include' // This might be necessary to include session cookies
  27. })
  28. .then(response => {
  29. if (response.ok) {
  30. console.log('Session refresh successful.');
  31. return response.text(); // or process it differently if needed
  32. }
  33. throw new Error('Session refresh failed: ' + response.statusText);
  34. })
  35. .catch(error => {
  36. console.error('Error refreshing session:', error);
  37. });
  38. }, requestInterval);
  39. })();