Last active
May 11, 2017 15:07
-
-
Save vsemozhetbyt/d21811a61ab35a44f7d8b92e3c46c5ee to your computer and use it in GitHub Desktop.
Check if comment authors in PRs are Node.js collaborators
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
javascript: { | |
getCollaboratorsUsernames(); | |
function getCollaboratorsUsernames() { | |
const xhr = new XMLHttpRequest(); | |
xhr.open('GET', 'https://github.com/nodejs/node/blob/master/README.md', true); | |
xhr.responseType = 'document'; | |
xhr.withCredentials = true; | |
xhr.onload = markAuthorsLinks; | |
xhr.ontimeout = xhr.onerror = (evt) => { console.log(evt); }; | |
xhr.send(null); | |
} | |
function markAuthorsLinks(evt) { | |
const xhrDoc = evt.target.response; | |
const collaboratorsUsernames = Array.from( | |
xhrDoc.body.querySelectorAll('h3 + ul > li > a[href^="https://github.com/"]'), | |
link => link.textContent.trim() | |
); | |
const authorsLinks = [...document.body.querySelectorAll('a[href].author')]; | |
authorsLinks.forEach((link) => { | |
link.style.backgroundColor = | |
collaboratorsUsernames.includes(link.textContent.trim()) ? | |
'LightGreen' : 'LightGray'; | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Tampermonkey header example: