SLAMP CPT

Universal Heatmap for Egypt, KSA, and UAE. No red if New Orders = 0.

Tento skript by neměl být instalován přímo. Jedná se o knihovnu, kterou by měly jiné skripty využívat pomocí meta příkazu // @require https://update.greasyfork.org/scripts/574274/1801204/SLAMP%20CPT.js

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

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

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

v// ==UserScript==
// @name         SLAMP CPT
// @namespace    http://tampermonkey.net/
// @version      2.8
// @description  Universal Heatmap for Egypt, KSA, and UAE. No red if New Orders = 0.
// @author       Gemini
// @match        https://eu.central.df.amazon.dev/slam*
// @grant        none
// @downloadURL  https://raw.githubusercontent.com/YOUR_USERNAME/YOUR_REPO/main/slam_heatmap.user.js
// @updateURL    https://raw.githubusercontent.com/YOUR_USERNAME/YOUR_REPO/main/slam_heatmap.user.js
// ==/UserScript==

(function() {
    'use strict';

    function applyHeatmap() {
        const headers = Array.from(document.querySelectorAll('th, [role="columnheader"]'));
        const cptIndex = headers.findIndex(h => h.textContent.includes('1st Cpt Date'));
        const newIndex = headers.findIndex(h => h.textContent.trim() === 'New');

        if (cptIndex === -1) return;

        const rows = document.querySelectorAll('tbody tr, [role="row"]');
        const now = new Date();

        rows.forEach(row => {
            if (row.querySelector('th')) return;
            const cells = Array.from(row.querySelectorAll('td, [role="gridcell"]'));
            const cptCell = cells[cptIndex];
            const newCell = (newIndex !== -1) ? cells[newIndex] : null;

            if (!cptCell) return;

            const cptText = cptCell.textContent.trim();
            const newCount = newCell ? (parseInt(newCell.textContent.trim()) || 0) : 1;

            if (!cptText || cptText === 'N/A' || !cptText.includes('T')) return;

            const cptDate = new Date(cptText);
            const diffInHours = (cptDate - now) / (1000 * 60 * 60);

            let bgColor = "";
            let borderColor = "";

            if (newCount === 0) {
                bgColor = "#e8f5e9"; // Done
                borderColor = "#388e3c";
            } else {
                if (diffInHours < 0) {
                    bgColor = "#fce4ec"; 
                    borderColor = "#e91e63";
                } else if (diffInHours <= 1) {
                    bgColor = "#ffcccc"; // RED
                    borderColor = "#d32f2f";
                } else if (diffInHours <= 2.5) {
                    bgColor = "#fff3e0"; // ORANGE
                    borderColor = "#f57c00";
                } else {
                    bgColor = "#e8f5e9"; // GREEN
                    borderColor = "#388e3c";
                }
            }

            cells.forEach(cell => {
                cell.style.setProperty('background-color', bgColor, 'important');
                cell.style.setProperty('border-bottom', `1px solid ${borderColor}`, 'important');
                cell.style.setProperty('color', '#000000', 'important');
            });
        });
    }

    function addHighlightButton() {
        if (document.getElementById('cpt-highlight-btn')) return;
        const btn = document.createElement('button');
        btn.id = 'cpt-highlight-btn';
        btn.innerText = '📊 Apply MENA Heatmap';
        btn.style.cssText = `position:fixed; top:15px; right:15px; z-index:10000; padding:10px 20px; background:#232f3e; color:#ffffff; border:2px solid #ff9900; border-radius:4px; font-weight:bold; cursor:pointer;`;
        btn.onclick = (e) => { e.preventDefault(); applyHeatmap(); };
        document.body.appendChild(btn);
    }

    document.addEventListener('click', () => setTimeout(applyHeatmap, 500));
    setInterval(applyHeatmap, 15000); 
    setTimeout(addHighlightButton, 2000);
})();