sentinel sat

Adds a green "senti" button next to the Partnerhub report button without overlapping.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name            sentinel sat
// @description     Adds a green "senti" button next to the Partnerhub report button without overlapping.
// @namespace       https://greasyfork.org/en/users/715686-aseele-h
// @version         2026.02.17.7
// @author          aseele
// @include         https://www.waze.com/editor*
// @include         https://www.waze.com/*/editor*
// @include         https://beta.waze.com/editor*
// @include         https://beta.waze.com/*/editor*
// @grant           none
// @run-at          document-end
// ==/UserScript==

(function() {
    'use strict';

    function toWGS84(x, y) {
        var lon = (x * 180) / 20037508.34;
        var lat = (Math.atan(Math.exp((y * Math.PI) / 20037508.34)) * 360) / Math.PI - 90;
        return { lon: lon.toFixed(6), lat: lat.toFixed(6) };
    }

    function generateURL() {
        var zoom = W.map.getZoom();
        var center = W.map.getCenter();
        var coords = toWGS84(center.lon, center.lat);
        return `https://livingatlas.arcgis.com/sentinel2explorer/#mapCenter=${coords.lon}%2C${coords.lat}%2C${zoom}`;
    }

    function init_SENTI_TOOL() {
        if (typeof W === 'undefined' || !W.map || !W.map.getCenter) {
            setTimeout(init_SENTI_TOOL, 500);
            return;
        }

        // Target the WME permalink group
        var toolbarWrap = document.querySelector('.WazeControlPermalink');

        if (toolbarWrap !== null) {
            // Check if THIS specific button already exists to prevent duplicates
            if (document.getElementById("btn-senti")) return;

            var container = document.createElement('div');
            container.id = "WME_PH_SENTI_CONTAINER";
            container.style.display = "inline-block";
            container.style.marginLeft = "10px"; // Spacing to separate it from the Purple button
            container.style.verticalAlign = "middle";

            container.innerHTML = `
                <a href="#" id="btn-senti" style="
                    display: flex;
                    align-items: center;
                    background-color: #33cc33;
                    color: white;
                    padding: 5px 14px;
                    border-radius: 20px;
                    text-decoration: none;
                    font-family: 'Rubik', sans-serif;
                    font-weight: 500;
                    font-size: 13px;
                    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
                    transition: none;
                ">
                    <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" style="margin-right: 7px;">
                        <path d="M21 10c0 7-9 13-9 13s-9-6-9-13a9 9 0 0 1 18 0z"></path>
                        <circle cx="12" cy="10" r="3"></circle>
                    </svg>
                    senti
                </a>
            `;

            // We use 'after' but because the IDs are different, they will stack side-by-side
            toolbarWrap.parentNode.appendChild(container);

            var btn = document.getElementById("btn-senti");

            // Static green - no hover effects as requested
            btn.addEventListener("click", function(e) {
                e.preventDefault();
                window.open(generateURL(), "_blank");
            }, false);

            console.info('Senti Button: Positioned next to Report button');
        } else {
            setTimeout(init_SENTI_TOOL, 1000);
        }
    }

    init_SENTI_TOOL();
})();