Skip to content

Instantly share code, notes, and snippets.

@thevahidal
Forked from mahdizojaji/README.md
Created February 12, 2024 14:10
Show Gist options
  • Save thevahidal/255c08ef62e98c038f4ff18a4925a76d to your computer and use it in GitHub Desktop.
Save thevahidal/255c08ef62e98c038f4ff18a4925a76d to your computer and use it in GitHub Desktop.
buynow paid calculator
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