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

目前為 2020-08-08 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==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);
  }
}