Created
December 4, 2023 14:13
-
-
Save liuderchi/95faaad0102e7ad96b240c70b6597347 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For clean UI to screenshot capture, hide UIs of Google Maps | |
if (!window.__derek_elsCSSDisplayValues) { | |
window.__derek_elsCSSDisplayValues = {}; // query -> displayValue | |
} | |
const queries = [ | |
'#featureListPanel', // left panel | |
'#mapsprosearch-field', // search bar | |
// buttons | |
'#search-bar', | |
'#drawingToolbar', | |
'#directionsToolbar', | |
'#measureToolbar', | |
'#zoomToolbar', | |
'#map-area-container [role="button"]', | |
// top right UI | |
'#gb', | |
]; | |
// hide elements | |
const isHidden = | |
document.querySelector('#featureListPanel').style.display === 'none'; | |
queries.forEach(function (query) { | |
if (isHidden) { | |
const els = document.querySelectorAll(query); | |
els.forEach(function (el) { | |
el.style.display = window.__derek_elsCSSDisplayValues[query]; | |
}); | |
} else { | |
const els = document.querySelectorAll(query); | |
window.__derek_elsCSSDisplayValues[query] = els[0].style.display; | |
els.forEach(function (el) { | |
el.style.display = 'none'; | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment