Amazon Orders - Stats

Counts the number of orders and the total spent on Amazon.fr

2025-09-18 या दिनांकाला. सर्वात नवीन आवृत्ती पाहा.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name         Amazon Orders - Stats
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Counts the number of orders and the total spent on Amazon.fr
// @author       MERCRED
// @match        https://www.amazon.fr/your-orders/orders*
// @match        https://www.amazon.us/your-orders/orders*
// @match        https://www.amazon.de/your-orders/orders*
// @match        https://www.amazon.it/your-orders/orders*
// @match        https://www.amazon.es/your-orders/orders*
// @match        https://www.amazon.nl/your-orders/orders*
// @match        https://www.amazon.se/your-orders/orders*
// @match        https://www.amazon.pl/your-orders/orders*
// @match        https://www.amazon.in/your-orders/orders*
// @match        https://www.amazon.com/your-orders/orders*
// @match        https://www.amazon.com.mx/your-orders/orders*
// @match        https://www.amazon.co.uk/your-orders/orders*
// @match        https://www.amazon.co.jp/your-orders/orders*
// @match        https://www.amazon.com.au/your-orders/orders*
// @match        https://www.amazon.com.be/your-orders/orders*
// @grant        none
// @icon         https://upload.wikimedia.org/wikipedia/commons/d/de/Amazon_icon.png
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    function parsePrice(text) {
        if (!text) return 0;
        if (!text.includes("€")) return 0;
        let cleaned = text.replace(/[^\d,,-]/g, "").replace(",", ".");
        let value = parseFloat(cleaned);
        return isNaN(value) ? 0 : value;
    }

    function analyzeOrders() {
        let orders = document.querySelectorAll("div.order-card.js-order-card");
        let total = 0;
        orders.forEach(order => {
            let priceEl = Array.from(order.querySelectorAll("span.a-size-base.a-color-secondary.aok-break-word"))
                .find(el => el.innerText.includes("€"));
            if (priceEl) {
                total += parsePrice(priceEl.innerText);
            }
        });
        return { count: orders.length, total };
    }

    function createUI(stats) {
        let ui = document.createElement("div");
        ui.id = "amazon-orders-stats";
        ui.style.position = "fixed";
        ui.style.top = "150px";
        ui.style.left = "10px";
        ui.style.background = "white";
        ui.style.border = "2px solid #232f3e";
        ui.style.borderRadius = "8px";
        ui.style.padding = "10px";
        ui.style.zIndex = "9999";
        ui.style.boxShadow = "0 2px 6px rgba(0,0,0,0.3)";
        ui.style.fontSize = "14px";
        ui.style.fontFamily = "Arial, sans-serif";
        ui.innerHTML = `
            <b>📦 Amazon Stats</b><br>
            Orders : ${stats.count}<br>
            Total : ${stats.total.toFixed(2)} €
        `;
        document.body.appendChild(ui);
    }

    function init() {
        let tries = 0;
        let timer = setInterval(() => {
            let orders = document.querySelectorAll("div.order-card.js-order-card");
            if (orders.length > 0) {
                clearInterval(timer);
                let stats = analyzeOrders();
                createUI(stats);
            } else {
                tries++;
                if (tries > 40) {
                    clearInterval(timer);
                }
            }
        }, 500);
    }

    init();
})();