Skip to content

Instantly share code, notes, and snippets.

@Glavin001
Last active August 29, 2015 14:27
Show Gist options
  • Save Glavin001/a74a40dc33421191ad7d to your computer and use it in GitHub Desktop.
Save Glavin001/a74a40dc33421191ad7d to your computer and use it in GitHub Desktop.
Bulk change Facebook Application Notification Settings

About

I strongly dislike receiving application notifications on Facebook. I wanted to disable them. All of them. Here is the little script I wrote that does that in bulk for me.

Usage Instructions

  1. Go to https://www.facebook.com/settings?tab=notifications&section=on_facebook&view
  2. Copy the script.js code
  3. Open your web browser's JavaScript console. If you do not know how, see http://webmasters.stackexchange.com/a/77337
  4. Paste the code from script.js into your JavaScript console
  5. Wait a few seconds and then magically every single one of your appliction notification settings will be "Off". You should see a message in your JavaScript console saying that it is done.

Enjoy.

/**
Go to address:
https://www.facebook.com/settings?tab=notifications&section=on_facebook&view
Paste this script into your JavaScript Developer Console.
*/
// Set your desired state
var desiredState = "Off"; // "On"
// Get and click the application notification edit button
var editBtn = document.querySelector('a[href="/ajax/settings/notifications/type/dialog?section=application_notification"]')
editBtn.click()
// Wait until the modal has loaded
var delay = 2000;
setTimeout(function() {
// Get "Show More" button
var showMore = document.querySelector('div._4t2a a.uiMorePagerPrimary');
showMore.click();
// Get all toggles
var $toggles = document.querySelectorAll('form[ajaxify="/ajax/settings/notifications/update_app"] div._6a._6b.uiPopover a')
// Convert to Array
var toggles = Array.prototype.slice.call($toggles);
// Iterate over each
toggles.forEach(function(toggle) {
// Open toggle menu
toggle.click();
// Get popover menu
var ownsId = toggle.getAttribute('aria-owns');
var $as = document.querySelectorAll('#'+ownsId+' ._54nc')
var as = Array.prototype.slice.call($as);
// Find "Off" button
// as[0].querySelector('span span').innerHTML
var offBtn = as.find(function(el) { return el.querySelector('span span').innerHTML === desiredState; });
offBtn.click();
});
// Let the user know it is done!
console.log('Done! All of your Facebook application notification settings have been set to '+desiredState);
}, delay);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment