I have been working with Firebase a lot in the last year, we make heavy use of anonymous users. I have noticed that the system generates a lot of anonymous users each time I open new browser sessions.

I needed to remove some of these over time but found there was no easy way of doing so. The Firebase Authentication console allows you to remove these users one by one. But as a developer, I wanted to remove these programmatically.

Here is a snippet I came up with to remove them using the Firebase Authentication console.

tableBtns = document.querySelectorAll(
  '.table-row-actions [aria-label="Delete account"]'
)

function delayd(amount) {
  return new Promise(resolve => {
    setTimeout(resolve, amount)
  })
}

async function loop(array, callback) {
  for (let index = 0; index < array.length; index++) {
    await callback(array[index], index, array)
  }
}

loop(tableBtns, async btn => {
  btn.click()
  await delayd(200)
  document.querySelector(".fb-dialog .md-warn").click()
  await delayd(500)
})

How to use this

  • Open your browser and visit the Firebase Authentication console
  • Open your browser console window
  • Paste the snippet above and run it

Do note that this will only work for the number of records you are currently viewing and you should not browse from this page while its in progress.

I am certain this snippet and process can be improved, but for now, this works well enough for me.