Last Updated: February 25, 2016
·
704
· camachgk

Turn off Meetup.js Group Settings

I recently moved to San Francisco and joined a bunch of new Meetup groups to get involved in the local dev community. Unfortunately, my inbox was soon overrun with emails. There was no easy way to turn off the notifications for all groups at once, instead requiring loading a form for each one and then clicking a series of checkboxes and radio buttons, and submitting the form, which would reload the entire page.

I decided to make it a little faster with a simple bookmarklet to run on http://www.meetup.com/account/comm/

(->
 return unless /^(www\.)?meetup\.com$/.test window.location.host
 turnOffNotifications = ($el) ->
 $el
 # Deselect all checkboxes
 .find('.commSettings form input[type="checkbox"]')
 .attr('checked', false)
 .end()
 # How often do you want to receive Meetup reminders? (never)
 .find('fieldset label:last-child input[type="radio"][name="evRemind"]')
 .attr('checked', true)
 .end()
 # Block settings submit
 .find('.commSettings > form')
 .one 'submit', (e) ->
 e.preventDefault()
 $form = $ e.target
 $.ajax
 type: $form.attr 'method'
 url: $form.attr 'action'
 data: $form.serialize()
 success: -> console.log 'success'
 fail: -> console.log 'fail'
 .end()
 # Submit the form
 .find('input[type="submit"][name="submitButton"]')
 .click()
 .end()

 isFormLoaded = ($el) -> $el.find('.formContent').children().length

 $('ul#activeMemberships > li')
 .each ->
 $el = $ @
 ready = $.Deferred()

 if isFormLoaded $el
 ready.resolve()
 else
 # Load the form
 $el.find('a.editInPlace').click()
 interval = setInterval (-> ready.resolve() if isFormLoaded $el), 100
 timeout = setTimeout (-> 
 clearInterval interval
 ready.reject()
 ), 3000

 ready.done -> 
 clearInterval interval
 clearTimeout timeout
 turnOffNotifications $el

 ready.fail -> console.log 'failed to load form'
)()

To add it to your bookmarks, just past the following code as the "URL" attribute:

"javascript:(function()%7B(function()%20%7Bvar%20isFormLoaded%2C%20turnOffNotifications%3Bif%20(!%2F%5E(www%5C.)%3Fmeetup%5C.com%24%2F.test(window.location.host))%20return%3BturnOffNotifications%20%3D%20function(%24el)%20%7Breturn%20%24el.find('.commSettings%20form%20input%5Btype%3D%22checkbox%22%5D').attr('checked'%2C%20false).end().find('fieldset%20label%3Alast-child%20input%5Btype%3D%22radio%22%5D%5Bname%3D%22evRemind%22%5D').attr('checked'%2C%20true).end().find('.commSettings%20%3E%20form').one('submit'%2C%20function(e)%20%7Bvar%20%24form%3Be.preventDefault()%3B%24form%20%3D%20%24(e.target)%3Breturn%20%24.ajax(%7Btype%3A%20%24form.attr('method')%2Curl%3A%20%24form.attr('action')%2Cdata%3A%20%24form.serialize()%2Csuccess%3A%20function()%20%7Breturn%20console.log('success')%3B%7D%2Cfail%3A%20function()%20%7Breturn%20console.log('fail')%3B%7D%7D)%3B%7D).end().find('input%5Btype%3D%22submit%22%5D%5Bname%3D%22submitButton%22%5D').click().end()%3B%7D%3BisFormLoaded%20%3D%20function(%24el)%20%7Breturn%20%24el.find('.formContent').children().length%3B%7D%3Breturn%20%24('ul%23activeMemberships%20%3E%20li').each(function()%20%7Bvar%20%24el%2C%20interval%2C%20ready%2C%20timeout%3B%24el%20%3D%20%24(this)%3Bready%20%3D%20%24.Deferred()%3Bif%20(isFormLoaded(%24el))%20%7Bready.resolve()%3B%7D%20else%20%7B%24el.find('a.editInPlace').click()%3Binterval%20%3D%20setInterval((function()%20%7Bif%20(isFormLoaded(%24el))%20return%20ready.resolve()%3B%7D)%2C%20100)%3Btimeout%20%3D%20setTimeout((function()%20%7BclearInterval(interval)%3Breturn%20ready.reject()%3B%7D)%2C%203000)%3B%7Dready.done(function()%20%7BclearInterval(interval)%3BclearTimeout(timeout)%3Breturn%20turnOffNotifications(%24el)%3B%7D)%3Breturn%20ready.fail(function()%20%7Breturn%20console.log('failed%20to%20load%20form')%3B%7D)%3B%7D)%3B%7D)()%7D)()"