Forked from vsemozhetbyt/node-check-collaborators.js
Last active
May 11, 2017 20:37
-
-
Save refack/d6cea6115ccde111a109ea99acba7588 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: { | |
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