您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Automatic page refresh after 3 minutes of inactivity when the page is not in focus, including handling of the ResizeObserver error.
Explanation and Instructions for Using the Auto Refresh 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.
If you do not have the Tampermonkey extension, install it from the Chrome Web Store using the following link:
Tampermonkey.
After installing Tampermonkey, click on the extension icon and select Create a new script. Copy and paste the script code into the script editor.
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.
document.hidden
), the timer starts and logs the remaining time until refresh in the console.checkTimer()
in the console (by pressing F12) to check the timer's status in real time.
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.
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!