Link Map in Google Search to Google Maps

Try to re-add the link to Google Maps when Google Search returns a map (was removed due to EU DSA)

  1. // ==UserScript==
  2. // @name Link Map in Google Search to Google Maps
  3. // @namespace https://tante.cc/
  4. // @version 1.0
  5. // @description Try to re-add the link to Google Maps when Google Search returns a map (was removed due to EU DSA)
  6. // @author tante <tante@tante.cc>
  7. // @license GPL-3
  8. // @match https://www.google.com/search*
  9. // @match https://google.com/search*
  10. // @grant none
  11. // @run-at document-end
  12. // ==/UserScript==
  13.  
  14. (function() {
  15. 'use strict';
  16. let mapNode = document.getElementById("lu_map");
  17. let query = document.evaluate("//*[@name='q']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.value;
  18.  
  19. // wrap iamge in link to maps search with the same query as the google search
  20. let parent = mapNode.parentNode;
  21. let link = document.createElement('a');
  22. link.href = 'https://www.google.com/maps/search/?api=1&query='+ query.replaceAll(" ", "+");
  23. link.appendChild(mapNode.cloneNode(true));
  24. parent.replaceChild(link, mapNode);
  25. })();

QingJ © 2025

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