Skip to content

Instantly share code, notes, and snippets.

@Darkle
Last active September 13, 2021 19:26
Show Gist options
  • Save Darkle/02986dcecf347c44434677c7d7d3ffe3 to your computer and use it in GitHub Desktop.
Save Darkle/02986dcecf347c44434677c7d7d3ffe3 to your computer and use it in GitHub Desktop.
Sorts the namecheap domain name search by price (the regular price, not the special)
function getLiItemPrice(element){
var specialPrice = element.querySelector('.price .domain-dollar-value')
var regPrice = element.querySelector('.reg-price>div')
if(regPrice){
return Number(regPrice.childNodes[7].textContent)
}
else if(specialPrice){
return Number(specialPrice.childNodes[1].textContent)
}
}
var liItems = Array.from(document.querySelectorAll('.ga-event-ul li'))
liItems
.sort((prevElem, nextElem) => getLiItemPrice(prevElem) - getLiItemPrice(nextElem))
.forEach(elem => {
document.querySelector('.ga-event-ul').appendChild(elem)
})
@BoQsc
Copy link

BoQsc commented Sep 13, 2021

@BoQsc
Copy link

BoQsc commented Sep 13, 2021

Note: This gist is very old, 2016 year. Probably no longer works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment