Skip to content

Instantly share code, notes, and snippets.

@deobald
Created September 20, 2011 16:21
Show Gist options
  • Save deobald/1229563 to your computer and use it in GitHub Desktop.
Save deobald/1229563 to your computer and use it in GitHub Desktop.
mark all texts as read in google voice
#!/usr/bin/env ruby
# this script is pretty shit, really, but if you switch it to delete it's an easy way to
# blast through your texts and clean up your inbox. the problem with it is that gvoice
# can get into an inconsistent state after about a dozen pages.
require 'rubygems'
require 'selenium-webdriver'
def signin
user = "WHOEVER_YOU_ARE@gmail.com"
pwd = "WHATEVER_YOUR_PASSWORD_IS"
d = Selenium::WebDriver.for :firefox
d.get "https://www.google.com/voice"
email = d.find_element :name => "Email"
email.send_keys user
pass = d.find_element :name => "Passwd"
pass.send_keys pwd
d.find_element(:name => "signIn").click
d
end
def go_to_page(d, n)
d.get "https://www.google.com/voice/#sms/p#{n}"
sleep 1
d.execute_script("window.confirm = function(msg){return true;};")
end
def click_menu(d, id, text)
d.find_element(:id, id).click
menuitems = d.find_elements(:class_name, "goog-menuitem-content")
menuitems.each { |item| item.click if item.text == text }
end
def mark_page_read(d)
click_menu d, "gc-inbox-select", "Select all"
click_menu d, "gc-inbox-more-actions", "Mark as read"
sleep 0.5
d.find_element(:id, "gc-inbox-page-next").click
end
def kill_page(d)
click_menu d, "gc-inbox-select", "Select all"
d.find_element(:id, "gc-inbox-delete").click
sleep 0.5
end
d = signin
page = 1
go_to_page d, page
while(true) do
begin
mark_page_read d # or kill_page(d)
sleep 0.5
page = d.current_url.split("/").last.gsub("p", "").to_i
rescue Exception => e
puts "oh fuck. we done busted something. retrying from page #{page}"
go_to_page d, page
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment