WME ShowTown

Moves the UR and place update windows down and to the right so the town name and FUME buttons are not covered up

// ==UserScript==
// @name          WME ShowTown
// @description   Moves the UR and place update windows down and to the right so the town name and FUME buttons are not covered up
// @namespace     TxAgBQ
// @grant         none
// @grant         GM_info
// @version       20250802
// @match         https://beta.waze.com/*editor/*
// @match         https://www.waze.com/*editor/*
// @author        Rick Zabel (ShowTown) and TxAgBQ (update to shift UR right)
// @license       MIT/BSD/X11
// ==/UserScript==

function ShowTown() {
    try {
        // Directly target the panel element that needs to be moved.
        var panelElement = $('#panel-container .panel');

        // Check if the panel element exists and has a length greater than 0.
        // This ensures jQuery found the element on the page.
        if (typeof panelElement !== "undefined" && panelElement.length > 0) {
            // Define the CSS rules to apply.
            // margin-top:25px !important; moves the element down by 25 pixels.
            // margin-left505px !important; moves the element to the right by 5060 pixels.
            // The !important flag helps ensure these rules override Waze's default styles.
            var cssRules = '#panel-container .panel { margin-top:25px !important; margin-left:60px !important;}';

            // Check if our custom style tag already exists.
            // We append it only once to avoid cluttering the <head> with duplicate tags.
            if (!$('style#showtown-style').length) {
                $("head").append($('<style type="text/css" id="showtown-style">' + cssRules + '</style>'));
                console.log("ShowTown: Injected custom CSS for panel adjustment.");
            } else {
                // If the style tag already exists, ensure its content is correct.
                // This helps in case of re-runs or dynamic changes.
                $('style#showtown-style').html(cssRules);
            }
        }

        // Set a timeout to re-run this function regularly.
        // This is crucial for dynamically loaded pages like Waze Map Editor.
        // It ensures the styles are applied even if the elements load later or if
        // Waze's own JavaScript tries to override them after initial load.
        // Running every 1 second provides a good balance without excessive overhead.
        setTimeout(ShowTown, 1000);

    } catch (err) {
        // If an error occurs (e.g., jQuery not yet loaded), log it and
        // still try to re-run the function after a delay.
        console.error("ShowTown script error:", err);
        setTimeout(ShowTown, 1000);
    }
}

// Initial call to ShowTown to start the process.
// This will kick off the continuous checking loop.
setTimeout(ShowTown, 1000);