-
-
Save flyingwebie/9fdc10fb686786c881dfaf1276f34b67 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.
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
// 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')].filter((e) => e.innerText === 'Edit'); | |
} | |
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); | |
}); | |
} | |
async function waitConfirmDelete() { | |
return new Promise((resolve, reject) => { | |
let iteration = 1; | |
let i = setInterval(() => { | |
if (iteration++ > 30) { | |
clearInterval(i); | |
reject(); | |
} | |
if ([...document.querySelectorAll('button')].filter((e) => e.innerHTML === '<span>Delete</span>')[0]) { | |
return; | |
} | |
clearInterval(i); | |
resolve(); | |
}, 100) | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment