Last active
August 25, 2019 17:04
-
-
Save zzmp/00d0cf4a126e252a2c62 to your computer and use it in GitHub Desktop.
Filter out your unwanted Watched repos
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
/* 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