2019-10-22

Open all links in Gerrit

Newer versions of Gerrit, somewhat insanely, lack the old "Open All" button to open each file in its own tab. Here's a bookmarklet that does so:
javascript: (
  function() {
    var n_to_open = 0;
    var dl = document.querySelectorAll(".pathLink");
    var dll = dl.length;
    if (!dll) {
      alert('no links');
    } else {
      if (confirm('Open ' + dll + ' links in new windows?')) {
        for (i = 0; i < dll; ++i) {
          window.open(dl[i].href);
        }
      }
    }
  }
)();
(Add the above as the "Location" of a bookmark.)

No comments: