Enables the user to have a bigger map when using the map-maker. It also hides top bar and sidebar.
当前为
// ==UserScript==
// @name GeoGuessr Bigger Map on Map-Maker
// @version 0.5.0
// @description Enables the user to have a bigger map when using the map-maker. It also hides top bar and sidebar.
// @author MrAmericanMike
// @namespace https://greasyfork.org/en/users/250979-mrmike/
// @include /^(https?)?(\:)?(\/\/)?([^\/]*\.)?geoguessr\.com($|\/.*)/
// @grant none
// @run-at document-end
// ==/UserScript==
(function () {
"use strict";
// Enable this if you want the delete key to delete the current location not having to go click the delete button
// set the value either true or false
const ENABLE_DELETE_KEY = true;
const ENABLE_LEAVE_PAGE_PREVENTION = true;
if (ENABLE_LEAVE_PAGE_PREVENTION) {
window.addEventListener("beforeunload", (event) => {
if (event.path[0].location.pathname == "/map-maker") {
event.preventDefault();
return event.returnValue = "Are you sure you want to exit?";
}
});
}
function addGlobalStyle(css) {
var head, style;
head = document.getElementsByTagName("head")[0];
if (!head) { return; }
style = document.createElement("style");
style.innerHTML = css.replace(/;/g, " !important;");
head.appendChild(style);
}
function doStyles() {
addGlobalStyle(`
.container {
--width: 100%;
}
.container--large {
--width: 100%;
}
.layout {
--layout-content-padding-top: 0rem;
--layout-content-padding-bottom: 0rem;
--layout-content-horizontal-padding: 0.5rem;
}
.layout__sidebar, .title, .header__search-bar {
display: none;
}{
display: none;
}
.layout--always-show-sidebar-on-large-devices {
grid-template-columns: 0rem 1fr;
}
.streetview-panel {
height: 100%;
max-height: 100%;
width: 50vw;
}
.map-maker-map__search {
border: none;
box-shadow: var(--shadow-1);
font-size: var(--font-size-14);
margin: 1rem;
max-width: 75%;
width: 50rem;
}
`);
}
function resetStyles() {
addGlobalStyle(`
.container {
--width: 100%;
}
.container--large {
--width: 87.5rem;
}
.container--small {
--width: 40rem;
}
.layout {
--layout-content-padding-top: 2.5rem;
--layout-content-padding-bottom: 2.5rem;
--layout-content-horizontal-padding: 4rem;
}
.layout--no-padding {
--layout-content-padding-top: 0rem;
--layout-content-padding-bottom: 0rem;
--layout-content-horizontal-padding: 0rem;
}
.layout__sidebar, .title, .header__search-bar{
display: block;
}
.layout--always-show-sidebar-on-large-devices {
grid-template-columns: 18rem 1fr;
}
.streetview-panel {
height: 100%;
max-height: 30rem;
width: 35rem;
}
.map-maker-map__search {
border: none;
box-shadow: var(--shadow-1);
font-size: var(--font-size-14);
margin: 1rem;
max-width: 75%;
width: 20rem;
}
`);
}
function keyDown(event) {
if (event.key == "Delete") {
let buttons = document.getElementsByClassName("button--danger");
for (let x = 0; x < buttons.length; x++) {
if (buttons[x].textContent == "Delete") {
buttons[x].click();
}
}
}
}
// LISTEN FOR PAGE CHANGES
let currentTab = "";
let oldTab = "";
window.addEventListener("click", (event) => {
for (let x = 250; x < 2000; x += 250) {
setTimeout(() => {
lookForURLChange(event);
}, x);
}
});
function lookForURLChange(event) {
if (event.explicitOriginalTarget) {
if (event.explicitOriginalTarget.baseURI) {
currentTab = event.explicitOriginalTarget.baseURI;
}
}
if (event.path) {
event.path.forEach((element) => {
if (element.hasOwnProperty("URL") && element.hasOwnProperty("location")) {
currentTab = element.location.pathname;
}
});
}
if (oldTab != currentTab) {
oldTab = currentTab;
if (currentTab.includes("map-maker")) {
setTimeout(doStyles, 0);
if (ENABLE_DELETE_KEY) {
document.addEventListener("keydown", keyDown, true);
}
}
else {
setTimeout(resetStyles, 0);
if (ENABLE_DELETE_KEY) {
document.removeEventListener("keydown", keyDown, true);
}
}
}
}
if (window.location.pathname.includes("map-maker")) {
setTimeout(doStyles, 5);
if (ENABLE_DELETE_KEY) {
document.addEventListener("keydown", keyDown, true);
}
}
})();