Skip to content

Instantly share code, notes, and snippets.

@liuderchi
Created December 4, 2023 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save liuderchi/95faaad0102e7ad96b240c70b6597347 to your computer and use it in GitHub Desktop.
Save liuderchi/95faaad0102e7ad96b240c70b6597347 to your computer and use it in GitHub Desktop.
// 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