Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save refack/d6cea6115ccde111a109ea99acba7588 to your computer and use it in GitHub Desktop.
Save refack/d6cea6115ccde111a109ea99acba7588 to your computer and use it in GitHub Desktop.
Check if comment authors in PRs are Node.js collaborators
javascript: {
const collaboratorsUsernames = [];
function getPage(url) {
return fetch(url, {mode: 'same-origin', credentials: 'same-origin'}).then(r => {
return r.text();
}).then(text => {
const x = /itemprop="name"\>(\w+)\<\/span>/g;
let r;
while ((r = x.exec(text)) !== null) {
r[1] && collaboratorsUsernames.push(r[1].trim().toLowerCase());
}
const m = /http.+after=[^"]+/.exec(text);
if (m) return getPage(m[0]);
else return collaboratorsUsernames;
});
}
getPage('https://github.com/orgs/nodejs/teams/collaborators').then(collabs => {
console.log(collabs);
[...document.body.querySelectorAll('a[href].author')].forEach((link) => {
link.style.backgroundColor = collabs.includes(link.textContent.trim().toLowerCase()) ? 'LightGreen' : 'LightGray';
link.classList.remove('nostrum-visited');
});
}).catch(e => console.log(e));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment