Skip to content

Instantly share code, notes, and snippets.

@phillipalexander
Forked from zzmp/repoUnwatcher.js
Created August 7, 2014 17:50
Show Gist options
  • Save phillipalexander/429c2155c3f210e9bdcb to your computer and use it in GitHub Desktop.
Save phillipalexander/429c2155c3f210e9bdcb to your computer and use it in GitHub Desktop.
/* REPO UNWATCHER
*
* This unwatches any repo that you don't specify.
* It must be run from the console while you are at https://github.com/watching
*
* *No need to edit any code - the instructions will prompt you to list out the repos you'd like to keep watching!*
*/
var repo;
var repos = [];
var instr = 'Enter the user/org you would like to retain notifications for. Enter only one at a time. Hit OK when you are through.'
while (repo = window.prompt(instr))
repos.push(repo);
console.info(repos.join(', ') + ' are being retained);
Array.prototype.forEach.call(document.querySelectorAll('.subscription-row'), function(row) {
var name = row.querySelectorAll('span')[1].innerText;
if (!~repos.indexOf(name)) {
var request = new XMLHttpRequest();
var formdata = new FormData();
var inputs = {};
Array.prototype.forEach.call(row.querySelectorAll('form.js-unsubscribe-form input[name]'), function(input) {
formdata.append(input.attributes.name.value, input.attributes.value.value)
});
request.open('POST', '/notifications/subscribe', true);
request.send(formdata);
}
});
console.info('These unsubscribe requests are asynchronous - make sure you give the GitHub a few minutes to receive them all!');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment