GeoGuessr Background Replacer

Replaces the background of the Geoguessr pages with your own image

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

  1. // ==UserScript==
  2. // @name GeoGuessr Background Replacer
  3. // @description Replaces the background of the Geoguessr pages with your own image
  4. // @version 1.2
  5. // @author Tyow#3742
  6. // @match *://*.geoguessr.com/*
  7. // @license MIT
  8. // @run-at document-start
  9. // @namespace https://greasyfork.org/users/1011193
  10. // @grant GM_addStyle
  11. // ==/UserScript==
  12.  
  13. //Add image links for the homePage in this list. If left blank, the default image will be shown
  14. const homePageImageList = ["https://cdn.wallpapersafari.com/6/80/9ZbpYo.jpg",
  15. "https://cdn.wallpapersafari.com/25/72/dtkc16.jpg",
  16. "https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Fwww.hdwallpapers.in%2Fdownload%2Fcolorful_texture_4k_hd_abstract-HD.jpg&f=1&nofb=1&ipt=e2c589746450fa0ac70e46511b9335bc3e2a377962dfc7cdfaa968d0215f9255&ipo=images"];
  17.  
  18. // Add image links for the rest of the pages here. If left blank, the default image will be shown
  19. const restOfThePagesImageList = ["https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Fimages.wallpapersden.com%2Fimage%2Fdownload%2Fminimalist-black-digital-blend_a2pnam2UmZqaraWkpJRobWllrWdma2U.jpg&f=1&nofb=1&ipt=8140d488ce7fa560a021b53bf042bc5e62475fe8524ab07d6b20e0befba675f5&ipo=images"];
  20.  
  21. /* ############################################################################### */
  22. /* ##### DON'T MODIFY ANYTHING BELOW HERE UNLESS YOU KNOW WHAT YOU ARE DOING ##### */
  23. /* ############################################################################### */
  24.  
  25. let homePageImgURL;
  26.  
  27. if(homePageImageList.length) {
  28. homePageImgURL = homePageImageList[Math.floor((Math.random()*homePageImageList.length))];
  29. }
  30.  
  31. let restOfPagesImgURL;
  32.  
  33. if(restOfThePagesImageList.length) {
  34. restOfPagesImgURL = restOfThePagesImageList[Math.floor((Math.random()*restOfThePagesImageList.length))];
  35. }
  36.  
  37. let css = `.customBackground { bottom: 0;
  38. display: block;
  39. height: 100%;
  40. object-fit: cover;
  41. pointer-events: none;
  42. position: fixed;
  43. right: 0;
  44. transition: .2s ease-in-out;
  45. width: 100% }`;
  46.  
  47.  
  48. const otherpages = () => {
  49. if (document.querySelector('.customBackground')) return;
  50. let el = document.querySelector("[class^='background_wrapper']");
  51. if (!el || !restOfPagesImgURL) return;
  52. let img = document.createElement("img")
  53. img.className = "customBackground";
  54. img.src = restOfPagesImgURL;
  55. GM_addStyle(css);
  56. el.appendChild(img);
  57. }
  58.  
  59. const updateImage = () => {
  60. let imgEl = document.querySelector('.signed-in-start-page_backgroundImage__IR0w5');
  61. if (!imgEl) {
  62. otherpages();
  63. return;
  64. };
  65. if (!homePageImgURL) return;
  66. imgEl.src = homePageImgURL;
  67. }
  68.  
  69.  
  70.  
  71. new MutationObserver(async (mutations) => {
  72. updateImage()
  73. }).observe(document.body, { subtree: true, childList: true });