AH price calc

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

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

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

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

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

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

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

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==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();
}