|
/*jshint esversion: 6 */ |
|
|
|
/* |
|
Run this snippet in your browser devtools JavaScript console to follow everyone in a GitHub organization. |
|
It only works for the current page, so wait for it to finish, navigate to the next page, and run it again. |
|
NOTE: Using this too much might trigger a rate-limited from GitHub. |
|
*/ |
|
|
|
;(function() { |
|
'use strict'; |
|
|
|
const followPage = () => { |
|
/* NOTE: GitHub could change their markup at any point */ |
|
let followButtonSelector = [ |
|
'#js-pjax-container', |
|
'.user-following-container >', |
|
'form:not([hidden="hidden"])', |
|
'input.btn.btn-sm', |
|
].join(' '); |
|
|
|
/* milliseconds */ |
|
let randRange = (min=750, max=1750) => ( |
|
Math.floor(Math.random()*(max - min + 1) + min) |
|
); |
|
|
|
let delay = (ms=0) => ( |
|
/* ms: wait this many milliseconds before resolving */ |
|
new Promise(resolve => setTimeout(resolve, ms)) |
|
); |
|
|
|
let followButtons = document.querySelectorAll(followButtonSelector); |
|
let toFollow = Array.from(followButtons) |
|
/* let's not unfollow people we already follow */ |
|
.filter((b) => (b.getAttribute("value") === "Follow")); |
|
|
|
console.group(`β³ Following ${toFollow.length} users... π€`); |
|
toFollow.reduce((acc, b, i) => { |
|
return acc |
|
.then(() => { |
|
const ms = randRange(500,2500); |
|
return delay(ms) |
|
.then(() => { |
|
b.click(); |
|
console.info([ |
|
`β
π${(i+1).toString().padStart(3, ' ')}πβ
`, |
|
`ππ${Math.abs(i-toFollow.length).toString().padStart(3, ' ')}ππ`, |
|
`β³π${ms.toString().padStart(7,' ')}msπβοΈ`, |
|
].join(' | ')); |
|
}) |
|
.catch((e) => console.error(e)); |
|
}); |
|
}, delay(0)) |
|
|
|
.then(() => { |
|
console.info(`β° Done! βπΎ`); |
|
console.groupEnd(); |
|
}) |
|
.catch((e) => console.error(e)); |
|
}; |
|
|
|
followPage(); |
|
})(); |