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 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name GeoGuessr Bigger Map on Map-Maker
  3. // @namespace https://bitbucket.org/MrAmericanMike/
  4. // @version 0.3.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
  6. // @author MrAmericanMike
  7. // @include /^(https?)?(\:)?(\/\/)?([^\/]*\.)?geoguessr\.com($|\/.*)/
  8. // @grant none
  9. // @run-at document-end
  10. // ==/UserScript==
  11.  
  12. console.log("GeoGuessr Bigger Map on Map-Maker");
  13.  
  14. const ENABLE_DELETE_KEY = false; // Enable this if you want the delete key to delete the current location not having to go click the delete button
  15.  
  16. function addGlobalStyle(css) {
  17. var head, style;
  18. head = document.getElementsByTagName("head")[0];
  19. if (!head) { return; }
  20. style = document.createElement("style");
  21. style.type = "text/css";
  22. style.innerHTML = css.replace(/;/g, " !important;");
  23. head.appendChild(style);
  24. }
  25.  
  26. function doStyles(){
  27.  
  28. addGlobalStyle (`
  29.  
  30. .container {
  31. --width: 100%;
  32. }
  33.  
  34. .layout {
  35. --layout-content-padding-top: 0.5rem;
  36. --layout-content-padding-bottom: 2.5rem;
  37. --layout-content-horizontal-padding: 0.5rem;
  38. }
  39.  
  40. .layout--always-show-sidebar-on-large-devices {
  41. grid-template-columns: 0rem 1fr;
  42. }
  43.  
  44. aside, .title, .header__search-bar {
  45. display: none;
  46. }
  47.  
  48. .map-maker-map {
  49. width: 100%;
  50. height: 90vh;
  51. padding-bottom: 0%;
  52. position: relative;
  53. }
  54.  
  55. .streetview-panel {
  56. width: 50rem;
  57. height: 100%;
  58. max-height: 100%;
  59. right: 0;
  60. top: 0;
  61. position: absolute;
  62. }
  63.  
  64. `);
  65.  
  66. }
  67.  
  68. function resetStyles(){
  69.  
  70. addGlobalStyle (`
  71.  
  72. .container {
  73. --width: 87.5rem;
  74. }
  75.  
  76. .layout {
  77. --layout-content-padding-top: 0.5rem;
  78. --layout-content-padding-bottom: 2.5rem;
  79. --layout-content-horizontal-padding: 0.5rem;
  80. }
  81.  
  82. .layout--always-show-sidebar-on-large-devices {
  83. grid-template-columns: 18rem 1fr;
  84. }
  85.  
  86. aside, .title, .header__search-bar {
  87. display: block;
  88. }
  89.  
  90. .map-maker-map {
  91. width: 100%;
  92. height: 0;
  93. padding-bottom: 50%;
  94. position: relative;
  95. overflow: hidden;
  96. box-shadow: var(--shadow-1);
  97. }
  98.  
  99. .streetview-panel {
  100. width: 35rem;
  101. height: 100%;
  102. max-height: 30rem;
  103. right: 0;
  104. top: 0;
  105. position: absolute;
  106. background: var(--color-grey-0);
  107. display: flex;
  108. flex-direction: column;
  109. transform: translateX(100%);
  110. transition: transform .2s ease;
  111. box-shadow: var(--shadow-1);
  112. }
  113.  
  114. `);
  115.  
  116. }
  117.  
  118.  
  119. function keyDown(event){
  120. console.log(event);
  121. if(event.key == "Delete"){
  122. let buttons = document.getElementsByClassName("button--danger");
  123. for(let x = 0; x < buttons.length; x++){
  124. if(buttons[x].textContent == "Delete"){
  125. buttons[x].click();
  126. }
  127. }
  128. }
  129. }
  130.  
  131.  
  132. // LISTEN FOR PAGE CHANGES
  133. let currentTab = "";
  134. let oldTab = "";
  135.  
  136. window.addEventListener("click", (event) => {
  137. for (let x = 0; x < 2500; x+=250){
  138. setTimeout(() => {
  139. lookForURLChange(event);
  140. }, x);
  141. }
  142. });
  143.  
  144. function lookForURLChange(event) {
  145. if(event["explicitOriginalTarget"]["baseURI"]){
  146. currentTab = event["explicitOriginalTarget"]["baseURI"];
  147. }
  148. else if(event.hasOwnProperty("path")){
  149. event.path.forEach((element) => {
  150. if(element.hasOwnProperty("URL") && element.hasOwnProperty("location")){
  151. currentTab = element.location.pathname;
  152. }
  153. });
  154. }
  155. if(oldTab != currentTab){
  156. oldTab = currentTab;
  157. if(currentTab.includes("map-maker")){
  158. setTimeout(doStyles, 0);
  159. if(ENABLE_DELETE_KEY){
  160. document.addEventListener("keydown", keyDown, true);
  161. }
  162. }
  163. else{
  164. setTimeout(resetStyles, 0);
  165. if(ENABLE_DELETE_KEY){
  166. document.aremoveEventListener("keydown", keyDown, true);
  167. }
  168. }
  169. }
  170. }
  171.  
  172. if(window.location.pathname.includes("map-maker")){
  173. setTimeout(doStyles, 5);
  174. if(ENABLE_DELETE_KEY){
  175. document.addEventListener("keydown", keyDown, true);
  176. }
  177. }
  178.