Skip to content

Instantly share code, notes, and snippets.

@elemeNtk0
Created March 23, 2016 06:11
Show Gist options
  • Save elemeNtk0/be470398a70a99a736a7 to your computer and use it in GitHub Desktop.
Save elemeNtk0/be470398a70a99a736a7 to your computer and use it in GitHub Desktop.
(function showReaction(username, reaction){
var elts = document.querySelectorAll('.js-details-container.outdated-diff-comment-container');
var total = [];
for (var i = elts.length - 1; i>=0; i--) {
var elt = elts[i];
var table = elt.querySelector('.js-inline-comments-container');
if (!table || elt.classList.contains('open')) {
continue;
}
var lastComment = table.children[table.children.length - 1];
/* TODO: improve selection. This fails if several people reacted */
var btns = lastComment.querySelectorAll('.reaction-summary-item[aria-label="'+ username +'"]');
var flag = true;
for (var j = btns.length - 1; j>=0; j--) {
var labels = btns[j].value.split(' ');
if (labels.indexOf(reaction) >= 0) {
flag = false;
}
}
if (!flag) {
continue;
}
total.push(elt);
var hdr = elt.querySelector('.discussion-item-header');
var toggle = hdr.querySelector('.discussion-item-toggle-closed');
hdr.style.backgroundColor = '#DD3535';
toggle.click();
}
if (total.length) {
alert(total.length+' comments were opened');
} else {
alert('nothing to open');
}
})('elemeNtk0','tada'); /* your GitHub username && favorite reaction */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment