Advertisement
ghiwar

mass delete cloudflare dns

Aug 9th, 2022
817
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.  * 1. open cloudflare dashboard, choose domain, go to DNS section
  3.  * 2. open browser's dev tool (via F12 or inspect or however)
  4.  * 3. in devtool, go to console tab
  5.  * 4. clear all existing messages
  6.  * 5. paste all script below
  7.  * 6. hit enter and watch
  8.  * 7. script only delete records displayed in the screen
  9.  * 8. if want to delete more, refresh browser and run script again
  10.  *
  11.  * credit: edited from https://gist.github.com/AidasK/9550e1eb97b3b121c5122aef0d778608
  12.  */
  13.  
  14. deleteAllRecords();
  15.  
  16. async function deleteAllRecords() {
  17.     let e;
  18.     filterEditButtons().forEach((e) => e.click());
  19.     while (e = filterDeleteButtons()[0]) {
  20.         e.click();
  21.         await confirmDelete();
  22.     }
  23. }
  24. function filterDeleteButtons() {
  25.     return [
  26.         ...[...document.querySelectorAll('a')].filter((e) => e.innerHTML === '<span>Delete</span>'),
  27.         ...[...document.querySelectorAll('button')].filter((e) => e.innerHTML === 'Delete'),
  28.     ];
  29. }
  30. function filterEditButtons() {
  31.     return [
  32.         ...document.querySelectorAll('a'),//old layout
  33.         ...document.querySelectorAll('button')
  34.     ].filter((e) => e.innerHTML.includes('<span>Edit</span>'));
  35. }
  36. function confirmDelete(iteration) {
  37.     iteration = iteration || 1;
  38.     return new Promise((resolve, reject) => {
  39.         setTimeout(async () => {
  40.             let button = [...document.querySelectorAll('button')].filter((e) => e.innerHTML === '<span>Delete</span>')[0];
  41.             if (button) {
  42.                 button.click();
  43.                 await waitConfirmDelete();
  44.                 resolve();
  45.             } else if (iteration > 30) {
  46.                 console.log('failed confirmDelete');
  47.                 reject();
  48.             } else {
  49.                 confirmDelete(iteration + 1)
  50.             }
  51.         }, 100);
  52.     });
  53. }
  54. function waitConfirmDelete() {
  55.     return new Promise((resolve, reject) => {
  56.         let iteration = 1;
  57.         let i = setInterval(() => {
  58.             if (iteration++ > 30) {
  59.                 clearInterval(i);
  60.                 reject();
  61.                 return;
  62.             }
  63.             if ([...document.querySelectorAll('button')].filter((e) => e.innerHTML === '<span>Delete</span>')[0]) {
  64.                 return;
  65.             }
  66.             clearInterval(i);
  67.             resolve();
  68.         }, 100)
  69.     });
  70. }
  71.  
  72. Source : https://gist.github.com/azliabdullah/d5859ec910f0457ca051e3325f81b3b3?fbclid=IwAR2F1RF84tnWCYmIH-rr_MRPEsmXWoy6xqURCB9aw-LvFQOyJQ0aGPq1YWI
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement