Show Google Maps in EU Search Pages

Bring Maps links to Google Search result pages in the EU once again.

  1. // ==UserScript==
  2. // @name Show Google Maps in EU Search Pages
  3. // @description Bring Maps links to Google Search result pages in the EU once again.
  4. // @namespace http://asleepysamurai.com
  5. // @license BSD Zero Clause License
  6. // @version 1
  7. // @grant none
  8. // @match https://*.google.com/search*
  9. // @match https://*.google.ad/search*
  10. // @match https://*.google.ae/search*
  11. // @match https://*.google.com.af/search*
  12. // @match https://*.google.com.ag/search*
  13. // @match https://*.google.al/search*
  14. // @match https://*.google.am/search*
  15. // @match https://*.google.co.ao/search*
  16. // @match https://*.google.com.ar/search*
  17. // @match https://*.google.as/search*
  18. // @match https://*.google.at/search*
  19. // @match https://*.google.com.au/search*
  20. // @match https://*.google.az/search*
  21. // @match https://*.google.ba/search*
  22. // @match https://*.google.com.bd/search*
  23. // @match https://*.google.be/search*
  24. // @match https://*.google.bf/search*
  25. // @match https://*.google.bg/search*
  26. // @match https://*.google.com.bh/search*
  27. // @match https://*.google.bi/search*
  28. // @match https://*.google.bj/search*
  29. // @match https://*.google.com.bn/search*
  30. // @match https://*.google.com.bo/search*
  31. // @match https://*.google.com.br/search*
  32. // @match https://*.google.bs/search*
  33. // @match https://*.google.bt/search*
  34. // @match https://*.google.co.bw/search*
  35. // @match https://*.google.by/search*
  36. // @match https://*.google.com.bz/search*
  37. // @match https://*.google.ca/search*
  38. // @match https://*.google.cd/search*
  39. // @match https://*.google.cf/search*
  40. // @match https://*.google.cg/search*
  41. // @match https://*.google.ch/search*
  42. // @match https://*.google.ci/search*
  43. // @match https://*.google.co.ck/search*
  44. // @match https://*.google.cl/search*
  45. // @match https://*.google.cm/search*
  46. // @match https://*.google.cn/search*
  47. // @match https://*.google.com.co/search*
  48. // @match https://*.google.co.cr/search*
  49. // @match https://*.google.com.cu/search*
  50. // @match https://*.google.cv/search*
  51. // @match https://*.google.com.cy/search*
  52. // @match https://*.google.cz/search*
  53. // @match https://*.google.de/search*
  54. // @match https://*.google.dj/search*
  55. // @match https://*.google.dk/search*
  56. // @match https://*.google.dm/search*
  57. // @match https://*.google.com.do/search*
  58. // @match https://*.google.dz/search*
  59. // @match https://*.google.com.ec/search*
  60. // @match https://*.google.ee/search*
  61. // @match https://*.google.com.eg/search*
  62. // @match https://*.google.es/search*
  63. // @match https://*.google.com.et/search*
  64. // @match https://*.google.fi/search*
  65. // @match https://*.google.com.fj/search*
  66. // @match https://*.google.fm/search*
  67. // @match https://*.google.fr/search*
  68. // @match https://*.google.ga/search*
  69. // @match https://*.google.ge/search*
  70. // @match https://*.google.gg/search*
  71. // @match https://*.google.com.gh/search*
  72. // @match https://*.google.com.gi/search*
  73. // @match https://*.google.gl/search*
  74. // @match https://*.google.gm/search*
  75. // @match https://*.google.gr/search*
  76. // @match https://*.google.com.gt/search*
  77. // @match https://*.google.gy/search*
  78. // @match https://*.google.com.hk/search*
  79. // @match https://*.google.hn/search*
  80. // @match https://*.google.hr/search*
  81. // @match https://*.google.ht/search*
  82. // @match https://*.google.hu/search*
  83. // @match https://*.google.co.id/search*
  84. // @match https://*.google.ie/search*
  85. // @match https://*.google.co.il/search*
  86. // @match https://*.google.im/search*
  87. // @match https://*.google.co.in/search*
  88. // @match https://*.google.iq/search*
  89. // @match https://*.google.is/search*
  90. // @match https://*.google.it/search*
  91. // @match https://*.google.je/search*
  92. // @match https://*.google.com.jm/search*
  93. // @match https://*.google.jo/search*
  94. // @match https://*.google.co.jp/search*
  95. // @match https://*.google.co.ke/search*
  96. // @match https://*.google.com.kh/search*
  97. // @match https://*.google.ki/search*
  98. // @match https://*.google.kg/search*
  99. // @match https://*.google.co.kr/search*
  100. // @match https://*.google.com.kw/search*
  101. // @match https://*.google.kz/search*
  102. // @match https://*.google.la/search*
  103. // @match https://*.google.com.lb/search*
  104. // @match https://*.google.li/search*
  105. // @match https://*.google.lk/search*
  106. // @match https://*.google.co.ls/search*
  107. // @match https://*.google.lt/search*
  108. // @match https://*.google.lu/search*
  109. // @match https://*.google.lv/search*
  110. // @match https://*.google.com.ly/search*
  111. // @match https://*.google.co.ma/search*
  112. // @match https://*.google.md/search*
  113. // @match https://*.google.me/search*
  114. // @match https://*.google.mg/search*
  115. // @match https://*.google.mk/search*
  116. // @match https://*.google.ml/search*
  117. // @match https://*.google.com.mm/search*
  118. // @match https://*.google.mn/search*
  119. // @match https://*.google.com.mt/search*
  120. // @match https://*.google.mu/search*
  121. // @match https://*.google.mv/search*
  122. // @match https://*.google.mw/search*
  123. // @match https://*.google.com.mx/search*
  124. // @match https://*.google.com.my/search*
  125. // @match https://*.google.co.mz/search*
  126. // @match https://*.google.com.na/search*
  127. // @match https://*.google.com.ng/search*
  128. // @match https://*.google.com.ni/search*
  129. // @match https://*.google.ne/search*
  130. // @match https://*.google.nl/search*
  131. // @match https://*.google.no/search*
  132. // @match https://*.google.com.np/search*
  133. // @match https://*.google.nr/search*
  134. // @match https://*.google.nu/search*
  135. // @match https://*.google.co.nz/search*
  136. // @match https://*.google.com.om/search*
  137. // @match https://*.google.com.pa/search*
  138. // @match https://*.google.com.pe/search*
  139. // @match https://*.google.com.pg/search*
  140. // @match https://*.google.com.ph/search*
  141. // @match https://*.google.com.pk/search*
  142. // @match https://*.google.pl/search*
  143. // @match https://*.google.pn/search*
  144. // @match https://*.google.com.pr/search*
  145. // @match https://*.google.ps/search*
  146. // @match https://*.google.pt/search*
  147. // @match https://*.google.com.py/search*
  148. // @match https://*.google.com.qa/search*
  149. // @match https://*.google.ro/search*
  150. // @match https://*.google.ru/search*
  151. // @match https://*.google.rw/search*
  152. // @match https://*.google.com.sa/search*
  153. // @match https://*.google.com.sb/search*
  154. // @match https://*.google.sc/search*
  155. // @match https://*.google.se/search*
  156. // @match https://*.google.com.sg/search*
  157. // @match https://*.google.sh/search*
  158. // @match https://*.google.si/search*
  159. // @match https://*.google.sk/search*
  160. // @match https://*.google.com.sl/search*
  161. // @match https://*.google.sn/search*
  162. // @match https://*.google.so/search*
  163. // @match https://*.google.sm/search*
  164. // @match https://*.google.sr/search*
  165. // @match https://*.google.st/search*
  166. // @match https://*.google.com.sv/search*
  167. // @match https://*.google.td/search*
  168. // @match https://*.google.tg/search*
  169. // @match https://*.google.co.th/search*
  170. // @match https://*.google.com.tj/search*
  171. // @match https://*.google.tl/search*
  172. // @match https://*.google.tm/search*
  173. // @match https://*.google.tn/search*
  174. // @match https://*.google.to/search*
  175. // @match https://*.google.com.tr/search*
  176. // @match https://*.google.tt/search*
  177. // @match https://*.google.com.tw/search*
  178. // @match https://*.google.co.tz/search*
  179. // @match https://*.google.com.ua/search*
  180. // @match https://*.google.co.ug/search*
  181. // @match https://*.google.co.uk/search*
  182. // @match https://*.google.com.uy/search*
  183. // @match https://*.google.co.uz/search*
  184. // @match https://*.google.com.vc/search*
  185. // @match https://*.google.co.ve/search*
  186. // @match https://*.google.co.vi/search*
  187. // @match https://*.google.com.vn/search*
  188. // @match https://*.google.vu/search*
  189. // @match https://*.google.ws/search*
  190. // @match https://*.google.rs/search*
  191. // @match https://*.google.co.za/search*
  192. // @match https://*.google.co.zm/search*
  193. // @match https://*.google.co.zw/search*
  194. // @match https://*.google.cat/search*
  195. // ==/UserScript==
  196.  
  197. // credits - https://github.com/thomasync/Bring-Back-Maps
  198.  
  199. !(() => {
  200. let loaded = false;
  201. let load_timeout = 2000;
  202.  
  203. function addHyperLinkMap(map, address) {
  204. if (map && address) {
  205. map.style.cursor = 'pointer';
  206. map.addEventListener('click', () => {
  207. window.location.href = address.href;
  208. });
  209. }
  210. }
  211.  
  212. function addHyperLinkLargeMap(map, search) {
  213. if (map && search) {
  214. map.style.cursor = 'pointer';
  215. map.addEventListener('click', () => {
  216. window.location.href = formatSearchLink(search.value);
  217. });
  218. }
  219. }
  220.  
  221. function addMapsToTabs(tabs, address, legacy) {
  222. if (!legacy) {
  223. const mapsTab = document.createElement('a');
  224. mapsTab.innerHTML = `
  225. <div jsname="bVqjv" class="GKS7s">
  226. <span class="FMKtTb UqcIvb" jsname="pIvPIe">Maps</span>
  227. </div>
  228. `;
  229. mapsTab.className = 'nPDzT T3FoJb';
  230. mapsTab.href = address;
  231. tabs.insertBefore(mapsTab, tabs.firstChild);
  232. } else {
  233. const mapsTab = document.createElement('div');
  234. mapsTab.innerHTML = `
  235. <a class="nPDzT T3FoJb" jsname="VIftV" role="link">
  236. <div jsname="bVqjv" class="YmvwI">Maps</div>
  237. </a>
  238. `;
  239. mapsTab.firstElementChild.href = address;
  240. tabs.insertBefore(mapsTab, tabs.children[1]);
  241. }
  242. }
  243.  
  244. function formatSearchLink(search) {
  245. search = encodeURIComponent(search);
  246. return `https://www.google.com/maps/search/${search}`;
  247. }
  248.  
  249. function waitLoaded() {
  250. if (loaded) {
  251. return;
  252. }
  253.  
  254. if (load_timeout <= 0) {
  255. return;
  256. }
  257.  
  258. app();
  259.  
  260. load_timeout -= 100;
  261. setTimeout(waitLoaded, 100);
  262. }
  263.  
  264. function app() {
  265. let legacy = false;
  266. let tabs = document.querySelector('.IUOThf');
  267.  
  268. if (!tabs) {
  269. // Some of the Google domains use old UI
  270. tabs = document.querySelector('.crJ18e');
  271.  
  272. if (!tabs) {
  273. return
  274. }
  275.  
  276. legacy = true;
  277. }
  278.  
  279. const search = document.querySelector('textarea.gLFyf');
  280. const map = document.querySelector('.Ggdpnf');
  281. const address = document.querySelector('.gqkR3b a');
  282. const largeMap = document.querySelector('.o8ebK');
  283.  
  284. if (map && address) {
  285. addHyperLinkMap(map, address);
  286. addMapsToTabs(tabs, address.href, legacy);
  287. loaded = true;
  288. } else if (largeMap && search) {
  289. addHyperLinkLargeMap(largeMap, search);
  290. addMapsToTabs(tabs, formatSearchLink(search.value), legacy);
  291. loaded = true;
  292. }
  293. }
  294.  
  295. waitLoaded();
  296. })();

QingJ © 2025

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