echandler / Geoguessr-better-guess-map-closer

Close the guess map better.
GNU General Public License v3.0
0 stars 0 forks source link

Not working well #1

Open HugoBarjot opened 2 years ago

HugoBarjot commented 2 years ago

Hello, It was not working well i found for me, so i make a other version so that it be really reactive on mouseover and on mouseleave on the minimap, i did this code below using your work base :)

image below : image

code below : // ==UserScript== // @name Geoguess better map closer. // @namespace geoguessr user scripts // @version 1.0 // @description Better map closer. // @author echandler / HugoBarjot // @match https://www.geoguessr.com/* // @icon https://www.google.com/s2/favicons?sz=64&domain=geoguessr.com // @updateURL https://github.com/echandler/Geoguessr-better-guess-map-closer/raw/main/GeoguessrBetterGuessMapCloser.user.js // @grant none // ==/UserScript==

(function () { "use strict";

let int = setInterval(() => {
  let sticky_element = document.querySelector(".guess-map__control--sticky");
  let map = document.body.querySelectorAll(".guess-map");
  clearInterval(int);
  map.forEach((canvas) => {
    canvas.addEventListener("mouseleave", function (e) {
      if (
        sticky_element.matches(".guess-map__control--sticky-active") === true
      ) {
        document
          .querySelector(".guess-map")
          .classList.add("guess-map--active");
      } else {
        document
          .querySelector(".guess-map")
          .classList.remove("guess-map--active");
      }
    });
  });
  map.forEach((canvas) => {
    canvas.addEventListener("mouseover", function (e) {
      document.querySelector(".guess-map").classList.add("guess-map--active");
    });
  });
}, 1000);

})();

HugoBarjot commented 2 years ago

edit : i notice i need to do a reload after each round so that it work well currently, need some adjustment yet :)

echandler commented 2 years ago

That looks good, but I wanted the map to close only when pressing the mouse button on the canvas, do you want to make a competing script because I think players may like your script as an alternative option.

HugoBarjot commented 2 years ago

ah okay in that case work intented then 👍 competing ? what do you mean :)

yeah, i try make it really reactive open and close at mouseover, i feel there is a delay to close the map bit useless in the game 👍

HugoBarjot commented 2 years ago

i fix the issue to make it works without any reload, i put a function loop into a function loop, not sure that's the best way to do but work 👍

`// ==UserScript== // @name Geoguessr fastermap opener/closer // @namespace geoguessr user scripts // @version 1.0 // @description Open and Close the minimap on mouseover and mouseleave in a faster way ! // @author Base work from echandler / Edit from HugoBarjot // @match https://www.geoguessr.com/* // @icon https://www.google.com/s2/favicons?sz=64&domain=geoguessr.com // @grant none // ==/UserScript==

setInterval(() => { const url = location.href; if (url.startsWith("https://www.geoguessr.com/game/") || url.startsWith("https://www.geoguessr.com/battle-royale/")|| url.startsWith("https://www.geoguessr.com/duels/")|| url.startsWith("https://www.geoguessr.com/team-duels/")|| url.startsWith("https://www.geoguessr.com/challenge/")|| url.startsWith("https://www.geoguessr.com/live-challenge/")) { (function () { "use strict";

let int = setInterval(() => { let sticky_element = document.querySelector(".guess-map__control--sticky"); let map = document.body.querySelectorAll(".guess-map"); clearInterval(int); map.forEach((canvas) => { canvas.addEventListener("mouseleave", function (e) { if ( sticky_element.matches(".guess-map__control--sticky-active") === true ) { document .querySelector(".guess-map") .classList.add("guess-map--active"); } else { document .querySelector(".guess-map") .classList.remove("guess-map--active"); } }); }); map.forEach((canvas) => { canvas.addEventListener("mouseover", function (e) { document.querySelector(".guess-map").classList.add("guess-map--active"); }); }); }, 1000); })(); } }, 500);

`

HugoBarjot commented 2 years ago

https://greasyfork.org/fr/scripts/449946-geoguessr-faster-map https://pastebin.com/ejm5YYuT