Google Maps remember me

Remembers your last used Google (Maps) user

  1. // ==UserScript==
  2. // @name Google Maps remember me
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.3
  5. // @description Remembers your last used Google (Maps) user
  6. // @author JKamsker
  7. // @grant none
  8. // @run-at document-start
  9. // @license MIT
  10.  
  11. // @match *://www.google.com/*
  12. // @match *://www.google.at/*
  13. // @match *://www.google.ad/*
  14. // @match *://www.google.ae/*
  15. // @match *://www.google.com.af/*
  16. // @match *://www.google.com.ag/*
  17. // @match *://www.google.al/*
  18. // @match *://www.google.am/*
  19. // @match *://www.google.co.ao/*
  20. // @match *://www.google.com.ar/*
  21. // @match *://www.google.as/*
  22. // @match *://www.google.com.au/*
  23. // @match *://www.google.az/*
  24. // @match *://www.google.ba/*
  25. // @match *://www.google.com.bd/*
  26. // @match *://www.google.be/*
  27. // @match *://www.google.bf/*
  28. // @match *://www.google.bg/*
  29. // @match *://www.google.com.bh/*
  30. // @match *://www.google.bi/*
  31. // @match *://www.google.bj/*
  32. // @match *://www.google.com.bn/*
  33. // @match *://www.google.com.bo/*
  34. // @match *://www.google.com.br/*
  35. // @match *://www.google.bs/*
  36. // @match *://www.google.bt/*
  37. // @match *://www.google.co.bw/*
  38. // @match *://www.google.by/*
  39. // @match *://www.google.com.bz/*
  40. // @match *://www.google.ca/*
  41. // @match *://www.google.cd/*
  42. // @match *://www.google.cf/*
  43. // @match *://www.google.cg/*
  44. // @match *://www.google.ch/*
  45. // @match *://www.google.ci/*
  46. // @match *://www.google.co.ck/*
  47. // @match *://www.google.cl/*
  48. // @match *://www.google.cm/*
  49. // @match *://www.google.cn/*
  50. // @match *://www.google.com.co/*
  51. // @match *://www.google.co.cr/*
  52. // @match *://www.google.com.cu/*
  53. // @match *://www.google.cv/*
  54. // @match *://www.google.com.cy/*
  55. // @match *://www.google.cz/*
  56. // @match *://www.google.de/*
  57. // @match *://www.google.dj/*
  58. // @match *://www.google.dk/*
  59. // @match *://www.google.dm/*
  60. // @match *://www.google.com.do/*
  61. // @match *://www.google.dz/*
  62. // @match *://www.google.com.ec/*
  63. // @match *://www.google.ee/*
  64. // @match *://www.google.com.eg/*
  65. // @match *://www.google.es/*
  66. // @match *://www.google.com.et/*
  67. // @match *://www.google.fi/*
  68. // @match *://www.google.com.fj/*
  69. // @match *://www.google.fm/*
  70. // @match *://www.google.fr/*
  71. // @match *://www.google.ga/*
  72. // @match *://www.google.ge/*
  73. // @match *://www.google.gg/*
  74. // @match *://www.google.com.gh/*
  75. // @match *://www.google.com.gi/*
  76. // @match *://www.google.gl/*
  77. // @match *://www.google.gm/*
  78. // @match *://www.google.gr/*
  79. // @match *://www.google.com.gt/*
  80. // @match *://www.google.gy/*
  81. // @match *://www.google.com.hk/*
  82. // @match *://www.google.hn/*
  83. // @match *://www.google.hr/*
  84. // @match *://www.google.ht/*
  85. // @match *://www.google.hu/*
  86. // @match *://www.google.co.id/*
  87. // @match *://www.google.ie/*
  88. // @match *://www.google.co.il/*
  89. // @match *://www.google.im/*
  90. // @match *://www.google.co.in/*
  91. // @match *://www.google.iq/*
  92. // @match *://www.google.is/*
  93. // @match *://www.google.it/*
  94. // @match *://www.google.je/*
  95. // @match *://www.google.com.jm/*
  96. // @match *://www.google.jo/*
  97. // @match *://www.google.co.jp/*
  98. // @match *://www.google.co.ke/*
  99. // @match *://www.google.com.kh/*
  100. // @match *://www.google.ki/*
  101. // @match *://www.google.kg/*
  102. // @match *://www.google.co.kr/*
  103. // @match *://www.google.com.kw/*
  104. // @match *://www.google.kz/*
  105. // @match *://www.google.la/*
  106. // @match *://www.google.com.lb/*
  107. // @match *://www.google.li/*
  108. // @match *://www.google.lk/*
  109. // @match *://www.google.co.ls/*
  110. // @match *://www.google.lt/*
  111. // @match *://www.google.lu/*
  112. // @match *://www.google.lv/*
  113. // @match *://www.google.com.ly/*
  114. // @match *://www.google.co.ma/*
  115. // @match *://www.google.md/*
  116. // @match *://www.google.me/*
  117. // @match *://www.google.mg/*
  118. // @match *://www.google.mk/*
  119. // @match *://www.google.ml/*
  120. // @match *://www.google.com.mm/*
  121. // @match *://www.google.mn/*
  122. // @match *://www.google.com.mt/*
  123. // @match *://www.google.mu/*
  124. // @match *://www.google.mv/*
  125. // @match *://www.google.mw/*
  126. // @match *://www.google.com.mx/*
  127. // @match *://www.google.com.my/*
  128. // @match *://www.google.co.mz/*
  129. // @match *://www.google.com.na/*
  130. // @match *://www.google.com.ng/*
  131. // @match *://www.google.com.ni/*
  132. // @match *://www.google.ne/*
  133. // @match *://www.google.nl/*
  134. // @match *://www.google.no/*
  135. // @match *://www.google.com.np/*
  136. // @match *://www.google.nr/*
  137. // @match *://www.google.nu/*
  138. // @match *://www.google.co.nz/*
  139. // @match *://www.google.com.om/*
  140. // @match *://www.google.com.pa/*
  141. // @match *://www.google.com.pe/*
  142. // @match *://www.google.com.pg/*
  143. // @match *://www.google.com.ph/*
  144. // @match *://www.google.com.pk/*
  145. // @match *://www.google.pl/*
  146. // @match *://www.google.pn/*
  147. // @match *://www.google.com.pr/*
  148. // @match *://www.google.ps/*
  149. // @match *://www.google.pt/*
  150. // @match *://www.google.com.py/*
  151. // @match *://www.google.com.qa/*
  152. // @match *://www.google.ro/*
  153. // @match *://www.google.ru/*
  154. // @match *://www.google.rw/*
  155. // @match *://www.google.com.sa/*
  156. // @match *://www.google.com.sb/*
  157. // @match *://www.google.sc/*
  158. // @match *://www.google.se/*
  159. // @match *://www.google.com.sg/*
  160. // @match *://www.google.sh/*
  161. // @match *://www.google.si/*
  162. // @match *://www.google.sk/*
  163. // @match *://www.google.com.sl/*
  164. // @match *://www.google.sn/*
  165. // @match *://www.google.so/*
  166. // @match *://www.google.sm/*
  167. // @match *://www.google.sr/*
  168. // @match *://www.google.st/*
  169. // @match *://www.google.com.sv/*
  170. // @match *://www.google.td/*
  171. // @match *://www.google.tg/*
  172. // @match *://www.google.co.th/*
  173. // @match *://www.google.com.tj/*
  174. // @match *://www.google.tl/*
  175. // @match *://www.google.tm/*
  176. // @match *://www.google.tn/*
  177. // @match *://www.google.to/*
  178. // @match *://www.google.com.tr/*
  179. // @match *://www.google.tt/*
  180. // @match *://www.google.com.tw/*
  181. // @match *://www.google.co.tz/*
  182. // @match *://www.google.com.ua/*
  183. // @match *://www.google.co.ug/*
  184. // @match *://www.google.co.uk/*
  185. // @match *://www.google.com.uy/*
  186. // @match *://www.google.co.uz/*
  187. // @match *://www.google.com.vc/*
  188. // @match *://www.google.co.ve/*
  189. // @match *://www.google.co.vi/*
  190. // @match *://www.google.com.vn/*
  191. // @match *://www.google.vu/*
  192. // @match *://www.google.ws/*
  193. // @match *://www.google.rs/*
  194. // @match *://www.google.co.za/*
  195. // @match *://www.google.co.zm/*
  196. // @match *://www.google.co.zw/*
  197. // @match *://www.google.cat/*
  198. // ==/UserScript==
  199.  
  200. (function () {
  201. "use strict";
  202.  
  203. function getLocalStorageKey() {
  204. if (window.location.href.includes("/maps")) {
  205. return "authuserIdMaps";
  206. } else {
  207. return "authuserIdGoogle";
  208. }
  209. }
  210.  
  211. function getAuthUserId() {
  212. let localStorageKey = getLocalStorageKey();
  213. let authuserId = localStorage.getItem(localStorageKey);
  214. return authuserId;
  215. }
  216.  
  217. function ensureAuthUser() {
  218. let url = new URL(window.location.href);
  219. let authUserIdIsSet = url.search.indexOf("authuser=") !== -1;
  220. if (!authUserIdIsSet) {
  221. let authuserId = getAuthUserId();
  222. if (!authuserId) {
  223. return;
  224. }
  225. url.search += (url.search ? "&" : "?") + "authuser=" + authuserId;
  226. window.location.href = url.toString();
  227. }
  228.  
  229. if (authUserIdIsSet) {
  230. let authuserId = url.searchParams.get("authuser");
  231. let localStorageKey = getLocalStorageKey();
  232. let storedAuthuserId = localStorage.getItem(localStorageKey);
  233. if (authuserId !== storedAuthuserId) {
  234. localStorage.setItem(localStorageKey, authuserId);
  235. }
  236. }
  237. }
  238.  
  239. function applyFixes() {
  240. ensureAuthUser();
  241. }
  242.  
  243. applyFixes();
  244.  
  245. fixGoogleMapsUrl();
  246.  
  247. window.addEventListener("popstate", function () {
  248. applyFixes();
  249. });
  250.  
  251. const originalPushState = history.pushState;
  252. const originalReplaceState = history.replaceState;
  253.  
  254. history.pushState = function () {
  255. originalPushState.apply(this, arguments);
  256. applyFixes();
  257. };
  258.  
  259. history.replaceState = function () {
  260. originalReplaceState.apply(this, arguments);
  261. applyFixes();
  262. };
  263. })();

QingJ © 2025

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