Jira done count

Adds done-count to sprint description.

이 스크립트를 설치하려면 Tampermonkey, Greasemonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

You will need to install an extension such as Tampermonkey to install this script.

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Userscripts와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 유저 스크립트 관리자 확장 프로그램이 필요합니다.

(이미 유저 스크립트 관리자가 설치되어 있습니다. 설치를 진행합니다!)

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

(이미 유저 스타일 관리자가 설치되어 있습니다. 설치를 진행합니다!)

// ==UserScript==
// @name        Jira done count
// @namespace   urn://https://www.georgegillams.co.uk/api/greasemonkey/jira_done_count
// @include     *gojira.*
// @exclude     none
// @version     2
// @grant    		none
// @description	Adds done-count to sprint description.
// ==/UserScript==

let doneCount = -1;

function getDoneCount() {
  const columns = document.getElementsByClassName('ghx-column ui-sortable');
  if (columns.length < 1) {
    return;
  }
  const doneColumn = columns[columns.length - 1];
  return doneColumn.childNodes.length;
}

function updateDoneCount(newValue) {
  if (doneCount === newValue) {
    return;
  }

  doneCount = newValue;

  const sprintDescriptionElement = document.getElementById('ghx-sprint-goal');
  const currentValue = sprintDescriptionElement.innerHTML;
  const newTextValue = `${currentValue.split(' • ')[0]} • ${doneCount} ticket${
    doneCount === 1 ? '' : 's'
  } done`;
  sprintDescriptionElement.innerHTML = newTextValue;
}

function updateCount() {
  const newDoneCount = getDoneCount();
  updateDoneCount(newDoneCount);
}

function worker() {
  try {
    updateCount();
  } catch (e) {
    // eslint-disable-next-line no-console
    console.log(e);
  }
}

setInterval(worker, 1500);