GeoGuessr Background Replacer

Replaces the background of the geoguessr homepage with your own image

当前为 2023-05-17 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name GeoGuessr Background Replacer
  3. // @description Replaces the background of the geoguessr homepage with your own image
  4. // @version 1.1
  5. // @author Tyow#3742
  6. // @match *://*.geoguessr.com/
  7. // @license MIT
  8. // @run-at document-start
  9. // @namespace https://greasyfork.org/users/1011193
  10. // ==/UserScript==
  11.  
  12. //Add image links in this list
  13. const imgList = ["https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Fcdn.wallpapersafari.com%2F6%2F80%2F9ZbpYo.jpg&f=1&nofb=1&ipt=ddb30ffb037e46ee933b0e3a566175f927faf57e5162b27bb15a5d71cf6e888d&ipo=images",
  14. "https://sites.breakingmedia.com/uploads/sites/3/2022/11/iStock-1333071678-e1669760260420.jpg",
  15. "https://natureconservancy-h.assetsadobe.com/is/image/content/dam/tnc/nature/en/photos/Zugpsitze_mountain.jpg?crop=0%2C214%2C3008%2C1579&wid=1200&hei=630&scl=2.506666666666667"];
  16.  
  17. /* ############################################################################### */
  18. /* ##### DON'T MODIFY ANYTHING BELOW HERE UNLESS YOU KNOW WHAT YOU ARE DOING ##### */
  19. /* ############################################################################### */
  20.  
  21. let imgURL = imgList[Math.floor((Math.random()*imgList.length))];
  22.  
  23. let done = false;
  24. let observing = false;
  25.  
  26. let c = 0;
  27. let mutated = false;
  28. let m = new MutationObserver(async (mutations) => {
  29. updateImage();
  30. console.log(mutations);
  31. mutated = true;
  32. });
  33. const updateImage = () => {
  34. console.log("fire " + c++);
  35. const imgEl = document.querySelector('.signed-in-start-page_backgroundImage__IR0w5');
  36. if (!imgEl) return;
  37. imgEl.src = imgURL;
  38. done = true;
  39. if (!observing) {
  40. observing = true;
  41. m.observe(imgEl, { attributes: true });
  42. }
  43. if (mutated) {
  44. m.disconnect();
  45. }
  46. }
  47.  
  48. updateImage()
  49. while (!done) {
  50. updateImage()
  51. }