Google Maps Satellite View Auto-Toggle

Automatically toggle to satellite view in Google Maps

< Σχολιασμός για τον κώδικα Google Maps Satellite View Auto-Toggle

Αναφορά: Καλός - ο κώδικας λειτουργεί

§
Δημοσιεύτηκε: 15/06/2024
Επεξεργάστηκε: 15/06/2024

Hello, Just so happens that I required the same script today Ive gotten help with a similar task years ago so I know there is a better way to make this. As I made mine the same way you have with a timer years ago.

And I got some help in the forums so that the code 'listens' instead of waiting for a timer to switch view.

So if youd like to update your code, here it is:

const mo = new MutationObserver(() => { const el = document.querySelector('#minimap button[jsaction*="minimap.main"]'); if (el) { el.click(); mo.disconnect(); } }); mo.observe(document.body, {childList: true, subtree: true});

Take care

§
Δημοσιεύτηκε: 15/06/2024
Επεξεργάστηκε: 15/06/2024



const mo = new MutationObserver(() => {
const el = document.querySelector('#minimap button[jsaction*="minimap.main"]');
if (el) {
el.click();
mo.disconnect();
}
});
mo.observe(document.body, {childList: true, subtree: true});

Δημοσίευση απάντησης

Συνδεθείτε για να δημοσιεύσετε μια απάντηση.