Skip to content

Instantly share code, notes, and snippets.

@inadarei
Forked from anonymous/disable_notifications.rb
Created December 27, 2012 22:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save inadarei/4392471 to your computer and use it in GitHub Desktop.
Save inadarei/4392471 to your computer and use it in GitHub Desktop.
def disable_notifications!
auth_url = "https://twitter.com/login"
notifications_url = "https://twitter.com/settings/notifications"
agent = Mechanize.new
page = agent.get(auth_url)
puts "DISABLING NOTIFICATIONS for #{self.username}"
puts "Logging in..."
page.forms_with(:action => 'https://twitter.com/sessions') do |forms|
f = forms.first
f.set_fields('session[username_or_email]' => self.username, 'session[password]' => self.password)
page = agent.submit(f, f.buttons.first)
end
page = agent.get(notifications_url)
puts "Updating notifications..."
page.forms_with(:action => 'https://twitter.com/settings/notifications/update') do |forms|
form = forms.first
# uncheck ALL the boxes!
form.checkboxes_with(:name => /^user/).each do |field|
field.uncheck
end
page = agent.submit(form, form.buttons.first)
puts "DONE"
end
nil
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment