Skip to content

Instantly share code, notes, and snippets.

@EldonMcGuinness
Last active July 22, 2024 12:36
Show Gist options
  • Save EldonMcGuinness/4068f8523b480802bfff210e5a5010ec to your computer and use it in GitHub Desktop.
Save EldonMcGuinness/4068f8523b480802bfff210e5a5010ec to your computer and use it in GitHub Desktop.
nextDNS Block TLDs
# This script is to be used on nextdns.io => Security => Block Top-Level Domains (TLDs) => Add a TLD
# Once the modal window is open, in the console you can run the below code to block all TLDs that are
# not in the validTLD array.
const delay = ms => new Promise(res => setTimeout(res, ms));
const blocker = async () => {
// List of TLDs that should not be blocked
let validTLD = [
'com',
'net',
'org'
]
// Use this line to unblock domains
//for (let item of document.querySelectorAll("body > div.modal.show > div > div > div.p-0.modal-body button.btn-danger")){
// Use this line to block domains
for (let item of document.querySelectorAll("body > div.modal.show > div > div > div.p-0.modal-body button.btn-primary")){
await delay(250);
let tld = item.parentElement.previousSibling.firstChild.firstChild.innerText.substring(1);
if ( validTLD.includes( tld ) ){
// console.log(tld+" Skipped");
continue;
}
console.log(tld+" Blocked");
item.click();
}
console.log("Done!");
}
blocker();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment