Greasy Fork is available in English.

GeoGuessr Bigger Map on Map-Maker

Enables the user to have a bigger map when using the map-maker // It also hides the Search Bar and the Sidebar when using the map-maker

// ==UserScript==
// @name         GeoGuessr Bigger Map on Map-Maker
// @namespace    https://bitbucket.org/MrAmericanMike/
// @version      0.3.5
// @description  Enables the user to have a bigger map when using the map-maker // It also hides the Search Bar and the Sidebar when using the map-maker
// @author       MrAmericanMike
// @include      /^(https?)?(\:)?(\/\/)?([^\/]*\.)?geoguessr\.com($|\/.*)/
// @grant        none
// @run-at       document-end
// ==/UserScript==

console.log("GeoGuessr Bigger Map on Map-Maker");

const ENABLE_DELETE_KEY = false; // Enable this (replace false with true) if you want the delete key to delete the current location not having to go click the delete button

function addGlobalStyle(css) {
    var head, style;
    head = document.getElementsByTagName("head")[0];
    if (!head) { return; }
    style = document.createElement("style");
    style.type = "text/css";
    style.innerHTML = css.replace(/;/g, " !important;");
    head.appendChild(style);
}

function doStyles(){

  addGlobalStyle (`

    .container {
      --width: 100%;
    }

    .layout {
      --layout-content-padding-top: 0.5rem;
      --layout-content-padding-bottom: 2.5rem;
      --layout-content-horizontal-padding: 0.5rem;
    }

    .layout--always-show-sidebar-on-large-devices {
      grid-template-columns: 0rem 1fr;
    }

    aside, .title, .header__search-bar {
      display: none;
    }

    .map-maker-map {
      width: 100%;
      height: 90vh;
      padding-bottom: 0%;
      position: relative;
    }

    .streetview-panel {
      width: 50rem;
      height: 100%;
      max-height: 100%;
      right: 0;
      top: 0;
      position: absolute;
    }

  `);

}

function resetStyles(){

  addGlobalStyle (`

    .container {
      --width: 87.5rem;
    }

    .layout {
      --layout-content-padding-top: 0.5rem;
      --layout-content-padding-bottom: 2.5rem;
      --layout-content-horizontal-padding: 0.5rem;
    }

    .layout--always-show-sidebar-on-large-devices {
      grid-template-columns: 18rem 1fr;
    }

    aside, .title, .header__search-bar {
      display: block;
    }

    .map-maker-map {
      width: 100%;
			height: 0;
			padding-bottom: 50%;
			position: relative;
			overflow: hidden;
			box-shadow: var(--shadow-1);
    }

  `);

}


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 = 0; x < 2500; x+=250){
        setTimeout(() => {
            lookForURLChange(event);
        }, x);
    }
});

function lookForURLChange(event) {  
    if(event["explicitOriginalTarget"]["baseURI"]){
      currentTab = event["explicitOriginalTarget"]["baseURI"];
    }
  	else if(event.hasOwnProperty("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.aremoveEventListener("keydown", keyDown, true);
          }
        }
    }
}

if(window.location.pathname.includes("map-maker")){
  setTimeout(doStyles, 5);
    
  if(ENABLE_DELETE_KEY){
    document.addEventListener("keydown", keyDown, true);
  }
}