Created
March 23, 2016 06:11
-
-
Save elemeNtk0/be470398a70a99a736a7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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