Deny google precise location question

Block google precise location question popup ("See results closer to you?") by automatically telling it no

  1. // ==UserScript==
  2. // @name Deny google precise location question
  3. // @version 2024-03-08
  4. // @description Block google precise location question popup ("See results closer to you?") by automatically telling it no
  5. // @match *://*.google.com/*
  6. // @license MIT
  7. // @namespace https://gf.qytechs.cn/users/1272292
  8. // ==/UserScript==
  9.  
  10.  
  11. var interval = 2; // ms, how often the loop should run
  12. var maxTime = 5000; // ms, max time to try to run the loop for
  13.  
  14. var startTime = new Date().getTime();
  15. var checkTimer = setInterval(TimeLoop, interval);
  16. checkTimer();
  17.  
  18. function TimeLoop() {
  19. const warning = document.getElementsByClassName("cMeQ8e b9SLDc"); //class of the popup
  20. if (warning[0] !== undefined){ //see if it exists yet
  21. if (warning[0].innerText == ("To get the closest results, let Google use your device's precise location.")) {
  22. document.querySelector('[jsaction="click:O6N1Pb"]').click(); //click the 'Not now' button
  23. clearInterval(checkTimer); //kill the timer once complete
  24. }
  25. }
  26. if (new Date().getTime() - startTime > maxTime) {
  27. clearInterval(checkTimer); //kill the timer if the popup hasnt shown after maxTime milliseconds
  28. }
  29. }

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址