google location auto update

update google location automatically

目前為 2024-08-19 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         google location auto update
// @namespace    http://tampermonkey.net/
// @version      0.4.2
// @description  update google location automatically
// @author       Door Ma
// @match        https://www.google.com/search?q=*
// @match        https://bard.google.com/chat*
// @match        https://gemini.google.com/app*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=google.com
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // 对于 search 的提交时间间隔
    setInterval(function() {
        if (window.location.href.includes('www.google.com/search?q=')) {
            let element_search = document.querySelector('update-location');
            if (element_search) {
                element_search.click();
            } else {
                console.log('未找到更新按钮');
                alert('未找到更新按钮');
            }
        }
    }, 600000); // 毫秒,执行一次位置提交

    // 对于 gemini 的提交时间间隔
    setInterval(function() {
        if (window.location.href.includes('gemini.google.com/app')) {
            let element_gemini = document.querySelector('.update-location-text.location-clickable');
            if (element_gemini) {
                element_gemini.click();
            } else {
                console.log('未找到更新按钮');
                alert('未找到更新按钮');
            }
        }
    }, 3600000); // 毫秒,执行一次位置提交

})();