您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Adds up all the items on a list giving you a total.
// ==UserScript== // @name Calculate List Total // @namespace http://tampermonkey.net/ // @version 1.1.0 // @description Adds up all the items on a list giving you a total. // @author lemonade.js // @match https://www.amazon.com/hz/wishlist/ls/* // @icon https://www.google.com/s2/favicons?sz=64&domain=amazon.com // @license 0BSD // @grant none // ==/UserScript== (function() { 'use strict'; const allPrices = document.getElementsByClassName('a-offscreen'); let total = 0; function calulateTotal() { total = 0; for (let i = 0; i < allPrices.length; i++) { if (allPrices[i].parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.id == 'g-items') { const priceElement = allPrices[i].innerHTML; const priceString = priceElement.slice(1); const priceFix = priceString.replace(/[()]/g, ''); const priceFloat = parseFloat(priceFix); total += priceFloat; } } } function displayTotal() { const totalPrice = document.getElementById('total-price'); calulateTotal(); totalPrice.innerHTML = `Total: $${total.toFixed(2)}`; } const bar = document.getElementsByClassName('a-row')[0]; const totalDisplay = document.createElement('h1'); totalDisplay.innerHTML = ''; totalDisplay.id = 'total-price'; bar.appendChild(totalDisplay); const pluginWarning = document.createElement('span'); pluginWarning.innerHTML = '[Calulate List Total]<br>You may need to scroll down for all items to calculate.'; pluginWarning.id = 'price-plugin-warning'; pluginWarning.className = 'a-color-secondary'; bar.appendChild(pluginWarning); setInterval(() => { displayTotal(); }, 500); })();