sentinel sat

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

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 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();
})();