Hide Street View Road Names

Useful for guessr style games

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name        Hide Street View Road Names
// @namespace   Violentmonkey Scripts
// @match       *://www.google.com/maps/embed/v1/streetview*
// @match       *://openguessr.com/*
// @grant       none
// @version     1.3
// @author      Evan Boehs
// @description Useful for guessr style games
// @license     MIT
// @resource    script https://maps.gstatic.com/maps-api-v3/embed/js/60/2/init_embed.js
// @grant       GM_getResourceText
// ==/UserScript==

(function () {
  const targetScript = "init_embed.js";
  // Attempt to prevent original script from loading
  if (typeof Element !== "undefined" && Element.prototype) {
    const originalAppChild = Element.prototype.appendChild;
    Element.prototype.appendChild = function () {
      if (arguments[0].src && arguments[0].src.includes(targetScript)) {
        return arguments[0];
      }
      return originalAppChild.apply(this, arguments);
    };
  }

  const embedPreload = document.querySelector(`link[href*="${targetScript}"]`);

  if (embedPreload) {
    embedPreload.parentNode.removeChild(embedPreload);

    const modifiedScript = GM_getResourceText("script").replace(
      '};b.dir="";',
      '};b.dir="";a.showRoadLabels=false;console.log("Successful Hijack");'
    );
    window.addEventListener("load", function () {
      const int = setInterval(() => {
        if (!window.google) {
          console.warn('window.google not defined despite load event.')
        }
        const newScript = document.createElement("script");
        newScript.textContent = modifiedScript;
        document.body.appendChild(newScript);
        clearInterval(int)
      },50)
    });
  }
})();