Created
May 16, 2022 22:52
-
-
Save ConnorNelson/6f8f33efa5d0fc14cb632ff5f4b3fd9b to your computer and use it in GitHub Desktop.
Print Google Maps Better
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
const width = "8.5in"; | |
const height = "11in"; | |
function sleep(s) { | |
var sleepTime = 1000; | |
return new Promise(resolve => setTimeout(resolve, sleepTime)); | |
} | |
var body = document.querySelector("body"); | |
var content = document.querySelector("#content-container"); | |
var app = document.querySelector("#app-container"); | |
var scene = document.querySelector("#scene"); | |
while (true) { | |
var printWithMaps = document.querySelector('button[jsaction="pane.action.printWithMaps"]'); | |
if (printWithMaps) break; | |
var printOpen = document.querySelector('button[jsaction="pane.action.printOpen"]'); | |
printOpen.click(); | |
await sleep(); | |
} | |
printWithMaps.click(); | |
await sleep(); | |
var printRegion = document.querySelector("#print"); | |
printRegion.remove(); | |
await sleep(); | |
var directions = null; | |
content.querySelectorAll("div").forEach((div) => { | |
if (directions) | |
return; | |
if (window.getComputedStyle(div).position != "absolute") | |
return; | |
div.querySelectorAll("span").forEach((span) => { | |
if (directions) | |
return; | |
if (!span.textContent.includes("These directions are for planning")) | |
return; | |
span.remove(); | |
directions = div; | |
}); | |
}); | |
directions.remove(); | |
directions.style.position = "static"; | |
directions.style.width = width; | |
body.appendChild(directions); | |
await sleep(); | |
app.style.width = width; | |
app.style.height = height; | |
scene.style.width = width; | |
scene.style.height = height; | |
await sleep(); | |
window.dispatchEvent(new Event("resize")); | |
await sleep(); | |
window.addEventListener("click", (event) => { | |
print(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Get The Google Chrome Extension!
See https://github.com/ConnorNelson/PrintGoogleMapsBetter.
Available as "Print Google Maps Better".