Automagically un-collapse Jira comments

moopet

Ben Sinclair

Posted on May 12, 2021

Automagically un-collapse Jira comments

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.ย โ†ฉ

๐Ÿ’– ๐Ÿ’ช ๐Ÿ™… ๐Ÿšฉ
moopet
Ben Sinclair

Posted on May 12, 2021

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

ยฉ TheLazy.dev

About