Initial commit

This commit is contained in:
Sijmen 2018-01-16 00:20:28 +01:00
commit 685d3eba55
3 changed files with 83 additions and 0 deletions

14
manifest.json Executable file
View file

@ -0,0 +1,14 @@
{
"manifest_version": 2,
"name": "Pivotal Improvements",
"version": "1.0.2",
"content_scripts":
[
{
"matches": ["*://*.pivotaltracker.com/n/projects/*"],
"js": ["project.js"],
"css": ["project.css"]
}
]
}

20
project.css Executable file
View file

@ -0,0 +1,20 @@
.story.owned > .preview {
font-weight: bold;
}
.story > .preview {
transition: background-color 0.2s;
}
.story.highlighted.planned > .preview {
background-color: #dfdfdf;
}
.story.highlighted.started > .preview,
.story.highlighted.finished > .preview {
background-color: #e3e3c1;
}
.story.highlighted.accepted > .preview {
background-color: #cadbbf;
}

49
project.js Executable file
View file

@ -0,0 +1,49 @@
const root = document.querySelector('#root');
let fullName = '';
function updateFullName() {
const avatar = document.querySelector('[data-aid="Avatar__image"]');
if (avatar)
fullName = avatar.getAttribute('alt');
}
function setClassOnStoriesWithOwner(name, className) {
const owners = document.querySelectorAll('.owner');
for (const owner of owners) {
const story = owner.parentElement.parentElement.parentElement.parentElement;
if (owner.getAttribute('title') === name)
story.classList.add(className);
else
story.classList.remove(className);
}
}
function callback() {
if (!fullName) {
// Grab the full name from the avatar alt-text.
updateFullName();
}
setClassOnStoriesWithOwner(fullName, 'owned');
}
root.addEventListener('mouseover', event => {
if (event.target.className === 'owner') {
const name = event.target.getAttribute('title');
setClassOnStoriesWithOwner(name, 'highlighted');
}
});
root.addEventListener('mouseout', event => {
if (event.target.className === 'owner')
setClassOnStoriesWithOwner('', 'highlighted');
});
const observer = new MutationObserver(callback);
const config = { childList: true, subtree: true };
observer.observe(root, config);