Last active
May 27, 2024 07:23
-
-
Save SamadiPour/44f9dfe9ec8918c04dd86b2c055baa4c to your computer and use it in GitHub Desktop.
ADSL TCI plan sorter
This file contains 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
const planCards = document.querySelectorAll('#service-list .uk-card'); | |
const cardDetails = []; | |
function convertPersianNumbersToEnglish(text) { | |
return text.replace(/[۰-۹]/g, (char) => String.fromCharCode(char.charCodeAt(0) - '۰'.charCodeAt(0) + '0'.charCodeAt(0))); | |
} | |
planCards.forEach(card => { | |
const title = convertPersianNumbersToEnglish(card.querySelector('.uk-card-title').textContent.trim()); | |
const description = convertPersianNumbersToEnglish(card.querySelector('.uk-card-body p').textContent.trim()); | |
const price = convertPersianNumbersToEnglish(card.querySelector('.price h3').textContent.trim()); | |
const numericPrice = Number(price.replace(/[^\d.]/g, '')) / 10; | |
const gb = Number(title.replace(/[^\d.]/g, '')); | |
const monthMatch = description.match(/(\d+)\s*ماهه/); | |
const months = monthMatch ? Number(monthMatch[1]) : null; | |
const ratio = numericPrice / gb; | |
const gbPerMonth = gb / months; | |
cardDetails.push({ card, ratio, numericPrice, gb, months, gbPerMonth }); | |
}); | |
text = '' | |
cardDetails.sort((a, b) => a.ratio - b.ratio); | |
cardDetails.forEach(({ card, ratio, numericPrice, gb, months, gbPerMonth }) => { | |
text += `Ratio: ${ratio}\n`; | |
text += `Price: ${numericPrice}\n`; | |
text += `GB: ${gb}\n`; | |
text += `Months: ${months} (${gbPerMonth} per month)\n`; | |
text += `---------------------------\n`; | |
}); | |
console.log(text); |
Dec 17, 2023 for FTTH:
Ratio: 558
Price: 3348000
GB: 6000
Months: 12 (500 per month)
---------------------------
Ratio: 582
Price: 1746000
GB: 3000
Months: 6 (500 per month)
---------------------------
Ratio: 600
Price: 900000
GB: 1500
Months: 3 (500 per month)
---------------------------
Ratio: 600
Price: 300000
GB: 500
Months: 1 (500 per month)
---------------------------
Ratio: 664.2857142857143
Price: 2790000
GB: 4200
Months: 12 (350 per month)
---------------------------
Ratio: 669.6666666666666
Price: 2009000
GB: 3000
Months: 12 (250 per month)
---------------------------
Ratio: 692.8571428571429
Price: 1455000
GB: 2100
Months: 6 (350 per month)
---------------------------
Ratio: 698.6666666666666
Price: 1048000
GB: 1500
Months: 6 (250 per month)
---------------------------
Ratio: 714.2857142857143
Price: 750000
GB: 1050
Months: 3 (350 per month)
---------------------------
Ratio: 714.2857142857143
Price: 250000
GB: 350
Months: 1 (350 per month)
---------------------------
Ratio: 720
Price: 540000
GB: 750
Months: 3 (250 per month)
---------------------------
Ratio: 720
Price: 180000
GB: 250
Months: 1 (250 per month)
---------------------------
Ratio: 837.0370370370371
Price: 1808000
GB: 2160
Months: 12 (180 per month)
---------------------------
Ratio: 842.7083333333334
Price: 1618000
GB: 1920
Months: 12 (160 per month)
---------------------------
Ratio: 873.1481481481482
Price: 943000
GB: 1080
Months: 6 (180 per month)
---------------------------
Ratio: 879.1666666666666
Price: 844000
GB: 960
Months: 6 (160 per month)
---------------------------
Ratio: 900
Price: 486000
GB: 540
Months: 3 (180 per month)
---------------------------
Ratio: 900
Price: 162000
GB: 180
Months: 1 (180 per month)
---------------------------
Ratio: 906.25
Price: 435000
GB: 480
Months: 3 (160 per month)
---------------------------
Ratio: 906.25
Price: 145000
GB: 160
Months: 1 (160 per month)
---------------------------
Ratio: 929.7619047619048
Price: 1562000
GB: 1680
Months: 12 (140 per month)
---------------------------
Ratio: 970.2380952380952
Price: 815000
GB: 840
Months: 6 (140 per month)
---------------------------
Ratio: 1000
Price: 420000
GB: 420
Months: 3 (140 per month)
---------------------------
Ratio: 1000
Price: 140000
GB: 140
Months: 1 (140 per month)
---------------------------
Ratio: 1046.5277777777778
Price: 1507000
GB: 1440
Months: 12 (120 per month)
---------------------------
Ratio: 1091.6666666666667
Price: 786000
GB: 720
Months: 6 (120 per month)
---------------------------
Ratio: 1125
Price: 405000
GB: 360
Months: 3 (120 per month)
---------------------------
Ratio: 1125
Price: 135000
GB: 120
Months: 1 (120 per month)
---------------------------
Ratio: 1279.1666666666667
Price: 1228000
GB: 960
Months: 12 (80 per month)
---------------------------
Ratio: 1333.3333333333333
Price: 640000
GB: 480
Months: 6 (80 per month)
---------------------------
Ratio: 1375
Price: 330000
GB: 240
Months: 3 (80 per month)
---------------------------
Ratio: 1375
Price: 110000
GB: 80
Months: 1 (80 per month)
---------------------------
May 27, 2024 for ADSL:
Ratio: 712.1031746031746
Price: 3589000
GB: 5040
Months: 12 (420 per month)
---------------------------
Ratio: 742.4603174603175
Price: 1871000
GB: 2520
Months: 6 (420 per month)
---------------------------
Ratio: 765.0793650793651
Price: 964000
GB: 1260
Months: 3 (420 per month)
---------------------------
Ratio: 765.4761904761905
Price: 321500
GB: 420
Months: 1 (420 per month)
---------------------------
Ratio: 775
Price: 1116000
GB: 1440
Months: 12 (120 per month)
---------------------------
Ratio: 801.6908212560387
Price: 3319000
GB: 4140
Months: 12 (345 per month)
---------------------------
Ratio: 808.3333333333334
Price: 582000
GB: 720
Months: 6 (120 per month)
---------------------------
Ratio: 833.3333333333334
Price: 300000
GB: 360
Months: 3 (120 per month)
---------------------------
Ratio: 833.3333333333334
Price: 100000
GB: 120
Months: 1 (120 per month)
---------------------------
Ratio: 836.231884057971
Price: 1731000
GB: 2070
Months: 6 (345 per month)
---------------------------
Ratio: 860.8695652173913
Price: 297000
GB: 345
Months: 1 (345 per month)
---------------------------
Ratio: 861.8357487922706
Price: 892000
GB: 1035
Months: 3 (345 per month)
---------------------------
Ratio: 930.2083333333334
Price: 893000
GB: 960
Months: 12 (80 per month)
---------------------------
Ratio: 968.75
Price: 465000
GB: 480
Months: 6 (80 per month)
---------------------------
Ratio: 1000
Price: 480000
GB: 480
Months: 12 (40 per month)
---------------------------
Ratio: 1000
Price: 240000
GB: 240
Months: 3 (80 per month)
---------------------------
Ratio: 1000
Price: 80000
GB: 80
Months: 1 (80 per month)
---------------------------
Ratio: 1023.8738738738739
Price: 2273000
GB: 2220
Months: 12 (185 per month)
---------------------------
Ratio: 1041.6666666666667
Price: 625000
GB: 600
Months: 12 (50 per month)
---------------------------
Ratio: 1041.6666666666667
Price: 250000
GB: 240
Months: 6 (40 per month)
---------------------------
Ratio: 1067.5675675675675
Price: 1185000
GB: 1110
Months: 6 (185 per month)
---------------------------
Ratio: 1075
Price: 129000
GB: 120
Months: 3 (40 per month)
---------------------------
Ratio: 1086.6666666666667
Price: 326000
GB: 300
Months: 6 (50 per month)
---------------------------
Ratio: 1100
Price: 203500
GB: 185
Months: 1 (185 per month)
---------------------------
Ratio: 1100.900900900901
Price: 611000
GB: 555
Months: 3 (185 per month)
---------------------------
Ratio: 1120
Price: 168000
GB: 150
Months: 3 (50 per month)
---------------------------
Ratio: 1120
Price: 56000
GB: 50
Months: 1 (50 per month)
---------------------------
Ratio: 1540.4761904761904
Price: 647000
GB: 420
Months: 12 (35 per month)
---------------------------
Ratio: 1607.142857142857
Price: 337500
GB: 210
Months: 6 (35 per month)
---------------------------
Ratio: 1657.142857142857
Price: 174000
GB: 105
Months: 3 (35 per month)
---------------------------
Ratio: 1657.142857142857
Price: 58000
GB: 35
Months: 1 (35 per month)
---------------------------
Ratio: 1965.909090909091
Price: 519000
GB: 264
Months: 12 (22 per month)
---------------------------
Ratio: 2045.4545454545455
Price: 270000
GB: 132
Months: 6 (22 per month)
---------------------------
Ratio: 2113.6363636363635
Price: 46500
GB: 22
Months: 1 (22 per month)
---------------------------
Ratio: 2121.212121212121
Price: 140000
GB: 66
Months: 3 (22 per month)
---------------------------
Ratio: 2458.3333333333335
Price: 29500
GB: 12
Months: 1 (12 per month)
---------------------------
I suggest using IIFE
to be able to run over and over.
Just put the above code in this block:
(function() {
# CODE
})()
`
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Open the browser console on this page and run this script