File size: 1,321 Bytes
c887523
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<script>

/*
function simulateButtonPress_() {
    const button = document.getElementById('simulate-button');
    if (button) {
        button.click();  // Simulate the button press
        console.log('Button Pressed!');
    }
}
*/

function simulateButtonPress() {
    console.log('Button Pressed!');
}

// Function to observe image changes
function observeImageChanges() {
    // Select all images with the 'image-monitor' class
    const images = document.querySelectorAll('.svelte-1pijsyv');
    
    // Create a MutationObserver to watch for changes in the image src
    const observer = new MutationObserver((mutationsList, observer) => {
        mutationsList.forEach(mutation => {
            if (mutation.type === 'attributes' && mutation.attributeName === 'src') {
                // If the image src changes, simulate button press
                console.log('Image changed!');
                simulateButtonPress();
            }
        });
    });
    
    // Observer options: observe changes to attributes (like src)
    const config = { attributes: true };

    // Start observing each image
    images.forEach(image => {
        observer.observe(image, config);
    });
}

// Start observing


window.addEventListener('load', () => {
    observeImageChanges();
    console.log("Yo");
});
    
</script>