Skip to content

Instantly share code, notes, and snippets.

@RayBB
Last active December 3, 2023 16:54
Show Gist options
  • Save RayBB/9ee79ce8764be0818ff82d34ff8cb0c0 to your computer and use it in GitHub Desktop.
Save RayBB/9ee79ce8764be0818ff82d34ff8cb0c0 to your computer and use it in GitHub Desktop.
Cleanup domain search results on porkbun
const MAX_RENEWAL = 20;
const MAX_INITIAL = 100;
function isUnavailable(e){return e.innerHTML.includes("unavailable")}
function highRenewalPrice(e){
const container = e.querySelector(".searchResultRowTable .renewsAtContainer");
if (!container) return false;
return (parseInt(container.innerText.match(/\d+/)[0]) || 0) > MAX_RENEWAL;
}
function highInitalPrice(e){
const container = e.querySelector(".searchResultRowTable");
if (!container) return false;
return (parseInt(container.innerText.replace(",", "").match(/\d+/)[0]) || 0) > MAX_INITIAL;
}
// Remove letter section headers
Array.from(document.querySelectorAll(".searchResultsTldLetterBox"))
.forEach(e=>e.remove())
// Select all the removeable wells (results)
Array.from(document.querySelectorAll(".searchResultsSectionContainer .well"))
.filter(e=>{return isUnavailable(e) || highRenewalPrice(e) || highInitalPrice(e)})
.forEach(e=>e.remove())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment