-
-
Save thevahidal/255c08ef62e98c038f4ff18a4925a76d to your computer and use it in GitHub Desktop.
buynow paid calculator
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
var total = 0; | |
const paid_amounts = document.getElementsByClassName("purchase-amount-number"); | |
var persianNumbers = [/۰/g, /۱/g, /۲/g, /۳/g, /۴/g, /۵/g, /۶/g, /۷/g, /۸/g, /۹/g]; | |
var arabicNumbers = [/٠/g, /١/g, /٢/g, /٣/g, /٤/g, /٥/g, /٦/g, /٧/g, /٨/g, /٩/g]; | |
fixNumbers = function (str) | |
{ | |
if(typeof str === 'string') | |
{ | |
for(var i=0; i<10; i++) | |
{ | |
str = str.replace(persianNumbers[i], i).replace(arabicNumbers[i], i); | |
} | |
} | |
return str; | |
}; | |
for(e of x) | |
{ | |
total += parseInt(fixNumbers(e.innerHTML.trim().replace(",", ""))); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment