Target Cart Summary

Summarize Target Cart

20.11.2025 itibariyledir. En son verisyonu görün.

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

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

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

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

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

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.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name        Target Cart Summary
// @namespace   nikhilweee
// @match       https://www.target.com/cart
// @grant       none
// @version     1.0
// @author      nikhilweee
// @description Summarize Target Cart
// ==/UserScript==

function allElementsLoaded() {
  const detailsCards = document.querySelectorAll('[data-test="cartItem"]');
  return detailsCards.length > 0;
}

function runScriptWhenReady() {
  if (allElementsLoaded()) {
    const detailsCards = document.querySelectorAll('[data-test="cartItem"]');
    const table = document.createElement("table");
    table.style = "width: 100%; text-align: left;";
    table.innerHTML = "<th>Price</th><th>Item</th>";

    detailsCards.forEach((card) => {
      const itemName =
        card
          .querySelector('[data-test="cartItem-title"]')
          ?.textContent.trim() || "";
      const quantity = card.querySelector("select")?.value || "1";
      const itemPrice =
        card
          .querySelector('[data-test="cartItem-price"]')
          ?.textContent.trim() || "";
      let unitPrice =
        card
          .querySelector('[data-test="cartItem-unitPrice"]')
          ?.textContent.trim() || "";
      unitPrice = unitPrice.replace("each ", "") || itemPrice;
      const [itemNameShort, _] = itemName.split(" - ");
      const row = table.insertRow();
      row.innerHTML = `<td>${itemPrice}</td><td>(${quantity}) ${itemNameShort}</td>`;
    });

    const invoiceMetaElement = document.querySelector(
      '[data-test="cart-item-groups"]'
    );
    console.log(table);
    invoiceMetaElement.insertBefore(table, invoiceMetaElement.firstChild);
  } else {
    setTimeout(runScriptWhenReady, 100);
  }
}

window.addEventListener("load", runScriptWhenReady);