AH price calc

Calculates the total price of your AH delivery and shows it on the "mijn lijst" page

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         AH price calc
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Calculates the total price of your AH delivery and shows it on the "mijn lijst" page
// @author       Maarten
// @match        https://www.ah.nl/mijnlijst
// @grant        none
// ==/UserScript==

setTimeout(calc, 2500)

function calc() {
    var total = 0;

    var item = document.querySelectorAll('.shoppinglist-lane article');
    for (var i = 0; item[i]; i++) {
        var price = 0;

        if (typeof item[i].childNodes[0].childNodes[3].childNodes[1] !== 'undefined') {
            price = item[i].childNodes[0].childNodes[3].childNodes[1].outerText;
        } else {
            price = item[i].childNodes[0].childNodes[3].outerText;
        }

        var quantity = item[i].childNodes[1].childNodes[1].childNodes[2].value;

        total += quantity * price; 
    }

    total = Math.round(total * 100) / 100;

    var header = document.querySelectorAll('.edc-heading.heading--10')[0];
    header.innerHTML = header.innerHTML + ' € '+total.toLocaleString();
}