Skip to content

Instantly share code, notes, and snippets.

@evilensky
Forked from anonymous/disable_notifications.rb
Created March 12, 2013 14:50
Show Gist options
  • Save evilensky/5143518 to your computer and use it in GitHub Desktop.
Save evilensky/5143518 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