Auto Refresh for Legal Aid & Justice Websites

Automatic page refresh after 3 minutes of inactivity when the page is not in focus, including handling of the ResizeObserver error.

Автор
Chaim Marcus
Установок в день
0
Всего установок
0
Оценки
0 0 0
Версия
1.2.1
Создано
17.02.2025
Обновлено
17.02.2025
Размер
3,1 КБ
Лицензия
MIT
Работает на

Explanation and Instructions for Using the Auto Refresh Script

Explanation of the Script


This script is designed to automatically refresh the page when the user is inactive (i.e., when the page is not in focus) for 3 minutes. When the page becomes hidden (for example, when the user switches to another tab), the script starts a 3-minute timer. If the page remains hidden during these 3 minutes, the script will automatically refresh the page.


Additionally, the script includes a mechanism that updates the console every second with the remaining time until refresh, allowing you to monitor the timer’s activity. Furthermore, the script handles errors of the type
"ResizeObserver loop completed with undelivered notifications" by using a global error handler, ensuring that the error does not affect the script’s operation.

Installation and Usage Instructions


  1. Installing Tampermonkey:


    If you do not have the Tampermonkey extension, install it from the Chrome Web Store using the following link:
    Tampermonkey.


  2. Adding the Script:


    After installing Tampermonkey, click on the extension icon and select Create a new script. Copy and paste the script code into the script editor.


  3. Configuring the Target Websites:


    In the metadata block at the top of the script, you can see the @match lines that define the websites on which the script will run. You can update or add these lines as needed.


  4. Monitoring the Timer Activity:

    • When the page becomes inactive (document.hidden), the timer starts and logs the remaining time until refresh in the console.

    • If the user returns to the page before the timer finishes, the timer is canceled and console updates stop.

    • You can run the function checkTimer() in the console (by pressing F12) to check the timer's status in real time.

  5. Error Handling:


    The script includes global error handling that captures errors of the type "ResizeObserver loop completed with undelivered notifications" and prevents them from affecting the script's functionality.

Sharing the Script


You can upload the script to GreasyFork and share it with other users. It is recommended to include this explanation along with the installation instructions and detailed description, so that script enthusiasts know how to properly install and use it.

Good luck!