Skip to content

Instantly share code, notes, and snippets.

@AidasK
Last active June 11, 2026 18:15
Show Gist options
  • Select an option

  • Save AidasK/9550e1eb97b3b121c5122aef0d778608 to your computer and use it in GitHub Desktop.

Select an option

Save AidasK/9550e1eb97b3b121c5122aef0d778608 to your computer and use it in GitHub Desktop.
Cloudflare delete all DNS records. Just go to cloudflare dns zones, open your browers developer console and paste this javascript code.
// paste all of this in your browser developer console
deleteAllRecords();
async function deleteAllRecords() {
let e;
filterEditButtons().forEach((e) => e.click());
while (e = filterDeleteButtons()[0]) {
e.click();
await confirmDelete();
}
}
function filterDeleteButtons() {
return [
...[...document.querySelectorAll('a')].filter((e) => e.innerHTML === '<span>Delete</span>'),
...[...document.querySelectorAll('button')].filter((e) => e.innerHTML === 'Delete'),
];
}
function filterEditButtons() {
return [
...document.querySelectorAll('a'),//old layout
...document.querySelectorAll('button')
].filter((e) => e.innerHTML.indexOf('<span>Edit</span>') != -1 );
}
function confirmDelete(iteration) {
iteration = iteration || 1;
return new Promise((resolve, reject) => {
setTimeout(async () => {
let button = [...document.querySelectorAll('button')].filter((e) => e.innerHTML === '<span>Delete</span>')[0];
if (button) {
button.click();
await waitConfirmDelete();
resolve();
} else if (iteration > 30) {
console.log('failed confirmDelete');
reject();
} else {
confirmDelete(iteration + 1)
}
}, 100);
});
}
function waitConfirmDelete() {
return new Promise((resolve, reject) => {
let iteration = 1;
let i = setInterval(() => {
if (iteration++ > 30) {
clearInterval(i);
reject();
return;
}
if ([...document.querySelectorAll('button')].filter((e) => e.innerHTML === '<span>Delete</span>')[0]) {
return;
}
clearInterval(i);
resolve();
}, 100)
});
}

image

Real developers are not used to clicking, it's allways easier to write a script to do it for you.
@iRajatDas

Copy link
Copy Markdown

Wow, thanks a lot!!

@informdev

Copy link
Copy Markdown

You Cadillac of men!

@rycasestorable

Copy link
Copy Markdown

The only truly functional method. I will create a local script for the API, however this is great thank you for contributing!

@WizCraker

Copy link
Copy Markdown

Quick and dirty in the browser is so much easier than trying to use the API for a handful of domains.

ghost commented Aug 25, 2023

Copy link
Copy Markdown

Nice

@Ehsanghodrati

Copy link
Copy Markdown

thanks

@ali-farhad

Copy link
Copy Markdown

still works. thank you so much <3

@diegoweb

Copy link
Copy Markdown

Doesn't work anymore :(

@iRajatDas

Copy link
Copy Markdown

Doesn't work anymore :(

Cloudflare now officially supports bulk deletions.

@diegoweb

Copy link
Copy Markdown

Doesn't work anymore :(

Cloudflare now officially supports bulk deletions.

Ohhh, I totally missed that.
Thanks!

@AidasK

AidasK commented Mar 31, 2026

Copy link
Copy Markdown
Author

Sorry, I should probably update this gist to a prompt which automates clicking the delete all button. If anyone could help would be nice.

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