Create js.js
Browse files
js.js
ADDED
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<script>
|
2 |
+
|
3 |
+
/*
|
4 |
+
function simulateButtonPress_() {
|
5 |
+
const button = document.getElementById('simulate-button');
|
6 |
+
if (button) {
|
7 |
+
button.click(); // Simulate the button press
|
8 |
+
console.log('Button Pressed!');
|
9 |
+
}
|
10 |
+
}
|
11 |
+
*/
|
12 |
+
|
13 |
+
function simulateButtonPress() {
|
14 |
+
console.log('Button Pressed!');
|
15 |
+
}
|
16 |
+
|
17 |
+
// Function to observe image changes
|
18 |
+
function observeImageChanges() {
|
19 |
+
// Select all images with the 'image-monitor' class
|
20 |
+
const images = document.querySelectorAll('.svelte-1pijsyv');
|
21 |
+
|
22 |
+
// Create a MutationObserver to watch for changes in the image src
|
23 |
+
const observer = new MutationObserver((mutationsList, observer) => {
|
24 |
+
mutationsList.forEach(mutation => {
|
25 |
+
if (mutation.type === 'attributes' && mutation.attributeName === 'src') {
|
26 |
+
// If the image src changes, simulate button press
|
27 |
+
console.log('Image changed!');
|
28 |
+
simulateButtonPress();
|
29 |
+
}
|
30 |
+
});
|
31 |
+
});
|
32 |
+
|
33 |
+
// Observer options: observe changes to attributes (like src)
|
34 |
+
const config = { attributes: true };
|
35 |
+
|
36 |
+
// Start observing each image
|
37 |
+
images.forEach(image => {
|
38 |
+
observer.observe(image, config);
|
39 |
+
});
|
40 |
+
}
|
41 |
+
|
42 |
+
// Start observing
|
43 |
+
|
44 |
+
|
45 |
+
window.addEventListener('load', () => {
|
46 |
+
observeImageChanges();
|
47 |
+
console.log("Yo");
|
48 |
+
});
|
49 |
+
|
50 |
+
</script>
|