DEV Community

loading...

Automagically un-collapse Jira comments

moopet profile image Ben Sinclair ・1 min read

If you use Jira, you probably know that you can order ticket comments either wrongly (reverse-chronological, like Twitter) or rightly (the way humans read English).

The default setting is "wrongly1"

If you fix it, then you're left with a different problem. You see, you, as a user, want to be able to read the comments in the correct order, but you're also most likely to be interested in the latest one. Only Atlassian have decided you shouldn't be allowed to read it until a period of several time-units has passed, in which you've scrolled down and clicked "View x newer comments" a gazillion times2.

So a made an exceptionally dumb Chrom(e|ium) extension to fix it, which periodically mashes the button on your behalf.

const swonk = function() {
  const buttonNodes = document.querySelectorAll('[data-test-id="issue.views.issue-details.issue-layout.left-most-column"] button');
  const buttonElements = [...buttonNodes].filter(e => e.innerText.match(/^View\s+\d+\s+remaining\snewer\scomments$/));

  buttonElements.forEach(e => e.click());
}

setInterval(swonk, 100);
Enter fullscreen mode Exit fullscreen mode

Why don't I use a MutationObserver you ask? Well, it's because in longer than the two minutes it took to type that out, I couldn't find anything useful to observe, since Jira's HTML is complete div soup.

If you are lazy, like me, you can grab this. I put it on GitHub for a change: moopet/jira-comment-uncollapser


  1. I may be using Alternative Words for Added Effect. 

  2. Hyperbole is good, ok, it's got "hyper" in it so it must be. 

Discussion (0)

Forem Open with the Forem app