Created
March 1, 2026 17:11
-
-
Save pedrolamas/debcf696ed94890e083595eff5276f96 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==UserScript== | |
| // @name Show Totals | |
| // @namespace http://tampermonkey.net/ | |
| // @version 2026-02-23 | |
| // @description show totals | |
| // @author Pedro Lamas | |
| // @match https://www.johnpyeauctions.co.uk/Event/LotDetails/* | |
| // @match https://www.johnpyeauctions.co.uk/Browse* | |
| // @match https://www.johnpyeauctions.co.uk/Account/Bidding/Watching | |
| // @icon https://www.google.com/s2/favicons?sz=64&domain=johnpyeauctions.co.uk | |
| // @grant none | |
| // ==/UserScript== | |
| (function () { | |
| 'use strict'; | |
| const getValue = (x) => +(/£(\d+\.\d+)/.exec(x.innerText)[1]); | |
| const shippingTableElement = document.getElementsByClassName("shipping-table")[0]; | |
| const shippingCost = shippingTableElement ? getValue(shippingTableElement) : 7.99; | |
| const calculateTotal = (value) => (value * 1.25 + shippingCost) * 1.2; | |
| const bidAmountElement = document.getElementById("BidAmount"); | |
| if (bidAmountElement && bidAmountElement.type != "hidden") { | |
| const updateBidAmountTotal = () => { | |
| bidAmountElement.nextElementSibling.innerText = calculateTotal(+bidAmountElement.value).toFixed(2); | |
| } | |
| bidAmountElement.oninput = updateBidAmountTotal; | |
| updateBidAmountTotal(); | |
| } | |
| const elementsToObserve = document.getElementsByClassName("NumberPart"); | |
| const updateObservedElementTotal = (element) => { | |
| element.nextElementSibling.innerText = ` // £${calculateTotal(+element.innerText).toFixed(2)}`; | |
| } | |
| for (let element of elementsToObserve) { | |
| element.insertAdjacentHTML("afterEnd", "<span></span>"); | |
| updateObservedElementTotal(element); | |
| } | |
| const process = () => { | |
| for (let element of elementsToObserve) { | |
| updateObservedElementTotal(element); | |
| } | |
| } | |
| const observer = new MutationObserver(process); | |
| observer.observe(elementsToObserve, { childList: true }); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment