Update app.py
Browse files
app.py
CHANGED
|
@@ -132,37 +132,56 @@ function simulateButtonPress() {
|
|
| 132 |
console.log('Button Pressed!');
|
| 133 |
}
|
| 134 |
|
| 135 |
-
// Function to
|
| 136 |
-
function
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
}
|
| 149 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 150 |
});
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 158 |
});
|
| 159 |
-
}
|
| 160 |
-
|
| 161 |
-
// Start observing
|
| 162 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 163 |
|
| 164 |
window.addEventListener('load', () => {
|
| 165 |
-
|
| 166 |
console.log("Yo");
|
| 167 |
});
|
| 168 |
|
|
|
|
| 132 |
console.log('Button Pressed!');
|
| 133 |
}
|
| 134 |
|
| 135 |
+
// Function to monitor image src changes
|
| 136 |
+
function monitorImageSrcChanges() {
|
| 137 |
+
// Create a MutationObserver instance
|
| 138 |
+
const observer = new MutationObserver((mutationsList, observer) => {
|
| 139 |
+
// Loop through all mutations
|
| 140 |
+
mutationsList.forEach(mutation => {
|
| 141 |
+
// Check if any new image tags were added
|
| 142 |
+
if (mutation.type === 'childList') {
|
| 143 |
+
mutation.addedNodes.forEach(node => {
|
| 144 |
+
if (node.nodeName === 'IMG') {
|
| 145 |
+
// New image added, monitor its src
|
| 146 |
+
observeImageSrc(node);
|
| 147 |
+
}
|
|
|
|
| 148 |
});
|
| 149 |
+
}
|
| 150 |
+
// Check if an image src attribute has changed
|
| 151 |
+
if (mutation.type === 'attributes' && mutation.attributeName === 'src') {
|
| 152 |
+
console.log('Image src changed:', mutation.target.src);
|
| 153 |
+
}
|
| 154 |
});
|
| 155 |
+
});
|
| 156 |
+
|
| 157 |
+
// Options for the observer (what to monitor)
|
| 158 |
+
const config = { childList: true, attributes: true, subtree: true, attributeFilter: ['src'] };
|
| 159 |
+
|
| 160 |
+
// Start observing the document body (or any specific element)
|
| 161 |
+
observer.observe(document.body, config);
|
| 162 |
+
|
| 163 |
+
// Initial monitoring of images already in the DOM
|
| 164 |
+
document.querySelectorAll('img').forEach(img => {
|
| 165 |
+
observeImageSrc(img);
|
| 166 |
+
});
|
| 167 |
+
|
| 168 |
+
// Function to observe an image's src attribute changes
|
| 169 |
+
function observeImageSrc(img) {
|
| 170 |
+
const srcObserver = new MutationObserver(mutations => {
|
| 171 |
+
mutations.forEach(mutation => {
|
| 172 |
+
if (mutation.type === 'attributes' && mutation.attributeName === 'src') {
|
| 173 |
+
console.log('Image src changed:', img.src);
|
| 174 |
+
}
|
| 175 |
+
});
|
| 176 |
});
|
|
|
|
|
|
|
|
|
|
| 177 |
|
| 178 |
+
// Start observing src attribute changes of the image
|
| 179 |
+
srcObserver.observe(img, { attributes: true, attributeFilter: ['src'] });
|
| 180 |
+
}
|
| 181 |
+
}
|
| 182 |
|
| 183 |
window.addEventListener('load', () => {
|
| 184 |
+
monitorImageSrcChanges();
|
| 185 |
console.log("Yo");
|
| 186 |
});
|
| 187 |
|