JSFiddle - React, Tailwind, and code Playground

by philll_t

HTML

<button id='dummy' aria-label="Delete branch">
Delete
</button>

<a id="link" href="">Delete Branches</a>

JavaScript

function handleClick() {
  alert("clicked")
}


document.getElementById("dummy").addEventListener("click", handleClick);

/*(function () {
    const matchingElements = document.querySelectorAll("[aria-label='Delete branch']");
    if (!matchingElements) {
        alert("No buttons were found.");
        return;
    }
    
    matchingElements.forEach(function (buttonEl){
        buttonEl.click();
        buttonEl.hidden = true;
    })
})() */

const js = `javascript:!function(){let e=document.querySelectorAll("[aria-label='Delete branch']");if(!e){alert("No buttons were found.");return}e.forEach(function(e){e.click(),e.hidden=!0})}();`

document.getElementById("link").href = js;