HighFashion / js.js
Uthar's picture
Create js.js
c887523 verified
raw
history blame
1.32 kB
<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>