您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Ensure authuser=n is always present in Google Maps URLs
当前为
// ==UserScript== // @name Google Maps Authuser Modifier // @namespace http://tampermonkey.net/ // @version 1.1 // @description Ensure authuser=n is always present in Google Maps URLs // @author JKamsker // @match *://www.google.at/maps* // @grant none // @run-at document-start // @license MIT // ==/UserScript== (function () { "use strict"; function getAuthUserId() { // Check if the authuserId is stored in localStorage let authuserId = localStorage.getItem("authuserId"); // If not present or user wants to change it (by adding ?changeAuthUser=true in the URL) let urlParams = new URLSearchParams(window.location.search); if (!authuserId || urlParams.get("changeAuthUser") === "true") { // Prompt the user to enter their authuserId authuserId = prompt( "Please enter your authuserId for Google Maps:", authuserId || "" ); if (authuserId) { // If provided, save it localStorage.setItem("authuserId", authuserId); } else { // If not provided, use a default or exit alert("authuserId not set. Using default or existing value."); return null; } } return authuserId; } function ensureAuthUser() { let url = new URL(window.location.href); // if (url.searchParams.get('authuser') !== authuserId) { // url.searchParams.set('authuser', authuserId); // window.location.href = url.toString(); // } let authUserIdIsSet = url.search.indexOf("authuser=") !== -1; // Only set if not already set if (!authUserIdIsSet) { let authuserId = getAuthUserId(); if (!authuserId) { return; } url.search += (url.search ? "&" : "?") + "authuser=" + authuserId; window.location.href = url.toString(); } // If the URL has a different authuser than the one stored in localStorage, update the localStorage value if (authUserIdIsSet) { let authuserId = url.searchParams.get("authuser"); let storedAuthuserId = localStorage.getItem("authuserId"); if (authuserId !== storedAuthuserId) { localStorage.setItem("authuserId", authuserId); } } } // Run the function on script load ensureAuthUser(); window.addEventListener("popstate", function (event) { ensureAuthUser(); }); const originalPushState = history.pushState; const originalReplaceState = history.replaceState; history.pushState = function () { originalPushState.apply(this, arguments); ensureAuthUser(); }; history.replaceState = function () { originalReplaceState.apply(this, arguments); ensureAuthUser(); }; })();