Last active
September 8, 2022 15:38
-
-
Save adrianbienias/42339b3802bd6fdcef6e88d4a1eebc2a to your computer and use it in GitHub Desktop.
Get domain list available to register at OVH with their prices
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
// 1. Visit https://www.ovh.pl/order/webcloud/?form_id=domain_search_form#/webCloud/domain/select?selection=~() | |
// 2. Automate listing all domains (clicking button to show more domain extensions) | |
const intervalClick = setInterval(() => { | |
const button = document.querySelector(`[data-on-click="$ctrl.doSearchOtherExtensions()"] button`) | |
if (button) { | |
button.scrollIntoView() | |
button.click() | |
} | |
}, 1000) | |
// 3. Wait until all domains will be listed (no spinning icon) and stop running interval | |
clearInterval(intervalClick) | |
// 4. Copy filtered domain list to clipboard | |
const domains = [...document.querySelectorAll(".table__row")].map(row => { | |
const domainExt = row | |
.querySelector(".name--full") | |
.textContent | |
.replace("undefined.", "") | |
if (domainExt.includes(".")) { | |
return null | |
} | |
if (domainExt.length > 5) { | |
return null | |
} | |
const registerPrice = parseFloat(row | |
.querySelector('[data-navi-id="results-price"]') | |
.textContent | |
.replace(/\s/g, "") | |
.replace("zł", "") | |
.replace(",", ".") | |
) | |
if (registerPrice > 200) { | |
return null | |
} | |
const renewalElem = row | |
.querySelector('[data-navi-id="results-price-renew"]') | |
if (renewalElem === null) { | |
return null | |
} | |
const renewalPrice = parseFloat( | |
renewalElem | |
.textContent | |
.replace(/\s/g, "") | |
.replace("następnie", "") | |
.replace("zł/rok", "") | |
.replace(",", ".") | |
) | |
if (renewalPrice > 200) { | |
return null | |
} | |
return [domainExt, registerPrice, renewalPrice] | |
}).filter(item => item !== null) | |
copy(domains) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment