Skip to content

Instantly share code, notes, and snippets.

@rosston
Last active October 20, 2021 17:59
Show Gist options
  • Save rosston/6d4178c7e7dd91583625fe59183518f3 to your computer and use it in GitHub Desktop.
Save rosston/6d4178c7e7dd91583625fe59183518f3 to your computer and use it in GitHub Desktop.
A quick and dirty bit of JS to run in the console to quickly unwatch repos in GitHub one page at a time
// WARNING: this script is very brittle and may not do what you intend.
//
//
// To run:
// 1. On github.com/watching, copy/paste the function into the console
// 2. Call the function, passing a function to filter repos to unwatch, e.g.,
// unfollowMatches((repoName) => repoName.startsWith('rosston'))
// 3. Check the output of the function to make sure it looks right
// 4. Run the function again with `true` at the end to really for real make the changes, e.g.,
// unfollowMatches((repoName) => repoName.startsWith('rosston'), true)
// Full version
function unfollowMatches(f, unfollow = false) {
const matches = Array.from($$('.repo-list a')).filter((a) => f(a.textContent));
if (!unfollow) {
console.log("Matches that would be unfollowed are below. To actually unfollow them, pass `true` as the second argument to this function.");
console.log(matches.map((a) => a.textContent));
return;
}
matches.forEach((a) => a.parentElement.nextSibling.nextSibling.querySelectorAll('button')[1].click());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment