Bulk Delete Cloudflare DNS in Chrome Browser Console Javascript

First we open all edit dropdowns:

var links = document.querySelectorAll('[href="#!"]');
for (var i = 0; i < links.length; i++) {
    links[i].click();
}

Then we delete all open dialogues:

async function click_first_delete(){
  var buttons  = document.querySelectorAll('button[type="button"]');
  for(var i=0;i<buttons.length;i++){
    //console.log(buttons[i].innerHTML);
    
    if(buttons[i].innerHTML == 'Delete'){             
        buttons[i].click();
        break;
    }
  }
}

async function confirm_delete(){
  await click_first_delete();
  var buttons2  = document.querySelectorAll('button[type="button"]');
  for(var j=0;j<buttons2.length;j++){
    //console.log(buttons2[j].innerHTML);
    if(buttons2[j].innerHTML == '<span>Delete</span>'){
      //console.log(buttons2[j].innerHTML);
      buttons2[j].click();         
    }
  }
}

//count delete buttons
var delete_buttons_count = 0;

var buttons  = document.querySelectorAll('button[type="button"]');
for(var i=0;i<buttons.length;i++){
  //console.log(buttons[i].innerHTML);
  
  if(buttons[i].innerHTML == 'Delete'){             
      delete_buttons_count += 1;
  }
}
console.log(delete_buttons_count);

for ( var i = 0; i < delete_buttons_count; i++ ) {
  confirm_delete();
  console.log(delete_buttons_count);

 

Inspired by https://community.cloudflare.com/t/how-do-i-bulk-delete-records-in-clou…

(() => {
    const deleteTopRecord = () => {
        document.querySelector('a.c_ba.c_mh.c_v.c_mi.c_mj.c_mk.c_ml.c_mm.c_mn.c_mo.c_uc.c_mp.c_al').click();
        setTimeout(() => {
            var tabs = document.querySelectorAll(".c_bh.c_c.c_j.c_tz.c_q.c_d");
            if(tabs.length) {
                tabs[0].firstChild.click();
                setTimeout(() => {
                    document.querySelector('.c_cm.c_tz.c_xi.c_br.c_id.c_xj button.c_xm').click();
                }, 200);
                setTimeout(deleteTopRecord, 500);
            } else {
                setTimeout(deleteTopRecord, 100);
            }
        }, 500);
    };
    deleteTopRecord();
})();

 

Need to make the loop work

function sleep(milliseconds) {
  var start = new Date().getTime();
  for (var k = 0; k < 1e7; k++) {
    if ((new Date().getTime() - start) > milliseconds){
      break;
    }
  }
}

function click_first_delete(){
  var buttons  = document.querySelectorAll('button[type="button"]');
  for(var i=0;i<buttons.length;i++){
    //console.log(buttons[i].innerHTML);
    
    if(buttons[i].innerHTML == 'Delete'){             
        buttons[i].click();
        break;
    }
  }
}

function confirm_delete(){
  click_first_delete();
  var buttons2  = document.querySelectorAll('button[type="button"]');
  for(var j=0;j<buttons2.length;j++){
    //console.log(buttons2[j].innerHTML);
    if(buttons2[j].innerHTML == '<span>Delete</span>'){
      //console.log(buttons2[j].innerHTML);
      buttons2[j].click();         
    }
  }
}

//count delete buttons
var delete_buttons_count = 0;

var buttons  = document.querySelectorAll('button[type="button"]');
for(var i=0;i<buttons.length;i++){
  //console.log(buttons[i].innerHTML);
  
  if(buttons[i].innerHTML == 'Delete'){             
      delete_buttons_count += 1;
  }
}
//console.log(delete_buttons_count);

for ( var i = 0; i < 1; i++ ) {
  confirm_delete();
  //console.log(delete_buttons_count);

 

cloudflare

Last modified
2021-02-11