Prevent Automatic Logout

No logout

目前为 2024-05-16 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Prevent Automatic Logout
  3. // @namespace http://tampermonkey.net/
  4. // @version 2024-05-16
  5. // @description No logout
  6. // @author You
  7. // @match https://web.budgetbakers.com/dashboard
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=budgetbakers.com
  9. // @grant none
  10. // @license MIT
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15.  
  16. // Attempt to find and override the logout interval/function directly
  17. // This part is speculative and needs adjustment based on the actual implementation
  18. const originalSetInterval = window.setInterval;
  19. window.setInterval = function(callback, interval) {
  20. // Check if this interval is likely the logout timer based on its interval
  21. if (interval === 3000) {
  22. console.log('Intercepted logout timer');
  23. // Do not set this interval
  24. return -1;
  25. }
  26. // For all other intervals, behave as normal
  27. return originalSetInterval(callback, interval);
  28. };
  29.  
  30. // Use a MutationObserver to detect when the logout dialog is added to the DOM and click the cancel button
  31. const observer = new MutationObserver(mutations => {
  32. mutations.forEach(mutation => {
  33. mutation.addedNodes.forEach(node => {
  34. // Assuming the cancel button can be uniquely identified by its text content
  35. // This needs to be adjusted based on the actual implementation
  36. if (node.textContent.includes('Cancel Logout Text Here')) {
  37. node.click();
  38. }
  39. });
  40. });
  41. });
  42.  
  43. // Start observing the body for added nodes
  44. observer.observe(document.body, { childList: true, subtree: true });
  45.  
  46. console.log('Automatic logout prevention script initialized');
  47. })();