Greasy Fork is available in English.

Deny google precise location question

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         Deny google precise location question
// @version      2024-03-08
// @description  Block google precise location question popup ("See results closer to you?") by automatically telling it no
// @match        *://*.google.com/*
// @license      MIT
// @namespace https://greasyfork.org/users/1272292
// ==/UserScript==


var interval = 2; // ms, how often the loop should run
var maxTime = 5000; // ms, max time to try to run the loop for

var startTime = new Date().getTime();
var checkTimer = setInterval(TimeLoop, interval);
checkTimer();

function TimeLoop() {
    const warning = document.getElementsByClassName("cMeQ8e b9SLDc"); //class of the popup
    if (warning[0] !== undefined){ //see if it exists yet
        if (warning[0].innerText == ("To get the closest results, let Google use your device's precise location.")) {
            document.querySelector('[jsaction="click:O6N1Pb"]').click(); //click the 'Not now' button
            clearInterval(checkTimer); //kill the timer once complete
        }
    }
    if (new Date().getTime() - startTime > maxTime) {
        clearInterval(checkTimer); //kill the timer if the popup hasnt shown after maxTime milliseconds
    }
}