Skip to content

Instantly share code, notes, and snippets.

@dz0ny
Last active November 2, 2021 12:43
Show Gist options
  • Save dz0ny/d9c9923f6166fc56ddb80aa1ce742ff2 to your computer and use it in GitHub Desktop.
Save dz0ny/d9c9923f6166fc56ddb80aa1ce742ff2 to your computer and use it in GitHub Desktop.
SUM USP on GitHub Projects
// ==UserScript==
// @name Sum User Points
// @match https://github.com/orgs/niteoweb/projects/1/views/*
// @icon https://github.githubassets.com/favicons/favicon.svg
// @namespace https://github.com/orgs/niteoweb/projects/1/views
// @version 0.0.3
// @homepageURL https://gist.github.com/dz0ny/d9c9923f6166fc56ddb80aa1ce742ff2/
// @updateURL https://gist.github.com/dz0ny/d9c9923f6166fc56ddb80aa1ce742ff2/raw/usp.user.js
// @run-at document-end
// ==/UserScript==
(function() {
'use strict';
function updateSUMSP(){
let columnNumber = 4;
let header = document.querySelector(`#memex-app-root #table-portal-root + div div:first-child div:nth-child(1) grid-cell:nth-child(${columnNumber}) div span`);
if(!header||header.innerText.indexOf("Story Points") !== 0){
return;
}
let rows = document.querySelectorAll(`#memex-app-root #table-portal-root + div div:last-child div[role='row'] div:nth-child(${columnNumber})`);
let sumUSP = Array.from(rows).map(el=>Number(el.innerText)).reduce((a, b) => a + b, 0);
header.innerHTML = `Story Points (${sumUSP})`;
}
window.addEventListener('popstate', updateSUMSP);
let app = document.querySelector("body");
app.addEventListener("click",updateSUMSP, true);
app.addEventListener("mouseover",updateSUMSP, true);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment