Are you sure you want to go to an external site to donate a monetary value?
WARNING: Some countries laws may supersede the payment processors policy such as the GDPR and PayPal. While it is highly appreciated to donate, please check with your countries privacy and identity laws regarding privacy of information first. Use at your utmost discretion.
This is my attempt to apply your solution on another website:
//regex = '/^\s*\n/gm' // .replace(regex, ''); function sumUp() { //sumUp = (function sumUp(){ //sumUp = (function(){ // Uncaught TypeError: sumUp is not a function let tag, fee, sum; const // /questions/1183903/regex-using-javascript-to-return-just-numbers regex = /[-]{0,1}[\d]*[.]{0,1}[\d]+/g, prices = [], selectors = [ '.a-price-whole', '.a-price-fraction', '.a-size-base.a-color-secondary', ], priceConfig = { minimumFractionDigits: 2, maximumFractionDigits: 2 }; for (let i = 0; i < selectors.length; i++) { try { prices[i] = document .querySelector(selectors[i]) .textContent .trim(); } catch { console.log(`No ${selectors[i]}`); } } tag = prices[0] + prices[1]; tag = tag.match(regex).join(''); tag = parseFloat(tag); fee = parseFloat(prices[2].match(regex).join('')); sum = tag + fee // Method .toFixed(2) might be preferable. See raingart. sum = sum.toLocaleString(navigator.language, priceConfig); priceSum = document.createElement('span'); priceSum.style.fontWeight = 'bold'; priceSum.style.padding = '6px'; priceSum.style.margin = '20px'; priceSum.style.outline = 'auto'; priceSum.innerHTML = `∑${sum}`; document.querySelector('.priceToPay > span:nth-child(2)').append(priceSum); //for (const val of document.querySelectorAll('.a-price-whole')) { // val.innerHTML = `${sum}<b>∑</b><sup><sup>(<sup>$</sup>${tag} + <sup>$</sup>${fee})</sup></sup>`; //} //})(); } sumUp() /* // define the target node var targetNode = document.querySelector('.a-price-whole'); // configuration of the observer const config = { childList: false, characterData: true, subtree: true, attributes: false, }; // callback function const callback = function (mutationsList, observer) { console.log('Changes Detected'); if (!targetNode.outerText.includes(' + ')) { sumUp(); } }; // Create observer instance const observer = new MutationObserver(callback); // pass in the target node and configuration observer.observe(targetNode, config); observer.observe(targetNode, config); */ const observerConfig = { childList: false, characterData: true, subtree: true, attributes: false, }; new window.MutationObserver(sumUp).observe(document.querySelector('.a-price-whole'), observerConfig);
Sorry for the late reply. Sites (openuserjs.org) don't notify me of new posts if I'm logged in via github
I know of at least 2 other alternatives
https://github.com/AndShy/Ali-Total-Price
https://greasyfork.org/en/scripts/6119-aliexpress-plus