Browse Source

Add labels to comments by OP (#376)

master
Jonas Gierer 8 years ago
committed by Sindre Sorhus
parent
commit
5a86c08fe6
  1. 9
      extension/content.css
  2. 28
      extension/content.js
  3. 1
      readme.md

9
extension/content.css

@ -565,3 +565,12 @@ td.blob-code.blob-code-deletion:before {
.gist-copy-btn {
margin: 0 10px 0 0;
}
/* multiple comment labels margin */
.timeline-comment .timeline-comment-label + .timeline-comment-label {
margin-right: -5px;
}
.review-comment .timeline-comment-label + .timeline-comment-label {
margin-left: 5px;
}

28
extension/content.js

@ -278,6 +278,26 @@ function addDiffViewWithoutWhitespaceOption(type) {
}
}
function addOPLabels(type) {
const label = `
<span class="timeline-comment-label tooltipped tooltipped-multiline tooltipped-s" aria-label="This user submitted this ${type}.">
Original Poster
</span>
`;
const comments = $('div.js-comment').toArray();
const commentAuthor = comment => $(comment).find('.author').text();
const op = commentAuthor(comments[0]);
const newComments = comments.slice(1).filter(comment => !$(comment).hasClass('refined-github-op'));
const opComments = newComments.filter(comment => commentAuthor(comment) === op);
$(opComments).filter('.timeline-comment').find('.timeline-comment-actions').after(label);
$(opComments).filter('.review-comment').find('.comment-body').before(label);
$(newComments).addClass('refined-github-op');
}
function addMilestoneNavigation() {
$('.repository-content').before(`
<div class="subnav">
@ -427,6 +447,14 @@ document.addEventListener('DOMContentLoaded', () => {
markUnread.setup();
}
if (pageDetect.isIssue()) {
addOPLabels('issue');
}
if (pageDetect.isPR()) {
addOPLabels('pull request');
}
if (pageDetect.isMilestone()) {
addMilestoneNavigation();
}

1
readme.md

@ -27,6 +27,7 @@ Our hope is that GitHub will notice and implement some of these much needed impr
- [Adds links to patch and diff for each commit](https://cloud.githubusercontent.com/assets/737065/13605562/22faa79e-e516-11e5-80db-2da6aa7965ac.png)
- [Differentiates merge commits from regular commits](https://cloud.githubusercontent.com/assets/170270/14101222/2fe2c24a-f5bd-11e5-8b1f-4e589917d4c4.png)
- [Adds a `Copy` button to gist files](https://cloud.githubusercontent.com/assets/170270/21074840/5dc37578-bf03-11e6-9fd9-501d73edef87.png)
- [Adds labels to comments by the original poster](https://cloud.githubusercontent.com/assets/4331946/25075520/d62fbbd0-2316-11e7-921f-ab736dc3522e.png)
- [Adds navigation to milestone pages](https://cloud.githubusercontent.com/assets/170270/25217211/37b67aea-25d0-11e7-8482-bead2b04ee74.png)
- Easier copy-pasting from diffs by making +/- signs unselectable
- Shows the reactions popover on hover instead of click

Loading…
Cancel
Save