Update app.py
Browse files
app.py
CHANGED
|
@@ -123,6 +123,9 @@ function monitorImageSrcChanges() {
|
|
| 123 |
// Set of recently downloaded image URLs to avoid re-triggering the download
|
| 124 |
const downloadedImages = new Set();
|
| 125 |
|
|
|
|
|
|
|
|
|
|
| 126 |
// Create a MutationObserver instance
|
| 127 |
const observer = new MutationObserver((mutationsList, observer) => {
|
| 128 |
// Loop through all mutations
|
|
@@ -203,9 +206,19 @@ function monitorImageSrcChanges() {
|
|
| 203 |
console.error('Button with id "TheButt" not found!');
|
| 204 |
}
|
| 205 |
}, 500); // Adjust the timeout if needed to make sure the download starts before clicking
|
|
|
|
|
|
|
| 206 |
}
|
| 207 |
-
}
|
| 208 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 209 |
|
| 210 |
window.addEventListener('load', () => {
|
| 211 |
monitorImageSrcChanges();
|
|
|
|
| 123 |
// Set of recently downloaded image URLs to avoid re-triggering the download
|
| 124 |
const downloadedImages = new Set();
|
| 125 |
|
| 126 |
+
// Track the last time a download occurred (in milliseconds)
|
| 127 |
+
let lastDownloadTime = Date.now();
|
| 128 |
+
|
| 129 |
// Create a MutationObserver instance
|
| 130 |
const observer = new MutationObserver((mutationsList, observer) => {
|
| 131 |
// Loop through all mutations
|
|
|
|
| 206 |
console.error('Button with id "TheButt" not found!');
|
| 207 |
}
|
| 208 |
}, 500); // Adjust the timeout if needed to make sure the download starts before clicking
|
| 209 |
+
// Update the last download time
|
| 210 |
+
lastDownloadTime = Date.now();
|
| 211 |
}
|
|
|
|
| 212 |
|
| 213 |
+
// Function to check for inactivity and reload the page if no download happened in 400 seconds
|
| 214 |
+
setInterval(() => {
|
| 215 |
+
const currentTime = Date.now();
|
| 216 |
+
if (currentTime - lastDownloadTime >= 400000) { // 400,000ms = 400 seconds
|
| 217 |
+
console.log("No download detected for 400 seconds, reloading the page...");
|
| 218 |
+
location.reload(); // Reload the page
|
| 219 |
+
}
|
| 220 |
+
}, 1000); // Check every second
|
| 221 |
+
}
|
| 222 |
|
| 223 |
window.addEventListener('load', () => {
|
| 224 |
monitorImageSrcChanges();
|