Greasy Fork

Greasy Fork is available in English.

WME HN Highlighter

A House Number script that highlights the native HN from white in yellow colour.

当前为 2025-01-29 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name          WME HN Highlighter
// @description   A House Number script that highlights the native HN from white in yellow colour.  
// @namespace     http://greasyfork.icu/users/1087400-kid4rm90s
// @version       2025.01.29.02
// @include       /^https:\/\/(www|beta)\.waze\.com\/(?!user\/)(.{2,6}\/)?editor\/?.*$/
// @author        kid4rm90s
// @license       MIT
// @grant         GM_addStyle
// @require       http://greasyfork.icu/scripts/24851-wazewrap/code/WazeWrap.js
// ==/UserScript==

/* global W */
/* global WazeWrap */

(function main() {
  "use strict";

  const scriptName = GM_info.script.name;
  const { version } = GM_info.script;

  console.log(`${scriptName}: Loading `);

  // Display change log immediately as it has no dependencies on waze itself.
  const changeLog = [
    { version: "1.0", message: "Initial Version" },
    { version: "1.1", message: "Removed unneccessary lines" },	
    { version: "2025.01.29.02", message: "Removed unneccessary lines" },
  ];

  async function checkVersion() {
    if (!WazeWrap?.Ready && !WazeWrap?.Interface?.ShowScriptUpdate) {
      setTimeout(checkVersion, 200);
      return;
    }

    const versionKey = `${scriptName.replace(/\s/g, "")}Version`;
    const previousVersion = window.localStorage.getItem(versionKey);

    if (previousVersion === version) {
      return;
    }

    let announcement = "";
    let startIndex = 0;

    // Find the index of the previous version in the change log
    if (previousVersion) {
      startIndex = changeLog.findIndex(log => log.version === previousVersion);
      if (startIndex === -1) {
        startIndex = 0; // If not found, start from the beginning
      }
    }
    announcement += "<ul>";
    // Build the announcement message from the change log
    for (let i = startIndex + 1; i < changeLog.length; i++) {
      const msg = `<li> V${changeLog[i].version}: ${changeLog[i].message} </li>\n`;
      announcement += msg;
    }
    announcement += "</ul>";

    console.group(`${scriptName} v${version} changelog:`);
    changeLog.slice(startIndex + 1).forEach(log => console.log(`V${log.version}: ${log.message}`));
    console.groupEnd();
    const title = startIndex > 0 ? `V${changeLog[startIndex].version} -> V${version}` : `Welcome to HNH V${version}`;
    console.log("ShwowScriptUpdate", scriptName, title, announcement);
    WazeWrap.Interface.ShowScriptUpdate(
      scriptName,
      title,
      announcement,
      "http://greasyfork.icu/en/scripts/",
    );
    window.localStorage.setItem(versionKey, version);
  }
  checkVersion();

  // Initialize RHN once Waze has been loaded.
  function initialize() {
    console.log(`${scriptName} initializing.`);

    W.map.registerMapEvent(
      "zoomend",
      event => {
        enableDisableControls(rapidHNtoolbarButton, event.object.zoom < 18);
      },
      this,
    );
    console.log(`${scriptName} initialized.`);
  }
     // Function to apply styles dynamically in case elements load later
    function updateHouseNumberMarkers() {
        document.querySelectorAll('.house-number-marker').forEach(marker => {
            marker.style.backgroundColor = '#FFFF00'; // Yellow color
        });
    }

    // Observe DOM changes to apply the style dynamically
    const observer = new MutationObserver(updateHouseNumberMarkers);
    observer.observe(document.body, { childList: true, subtree: true });

    // Initial call in case markers are already present
    updateHouseNumberMarkers();
})();

GM_addStyle(`
.house-number-marker {
            background-color: #FFFF00 !important; /* Change to yellow */
        }
`);