When you have a huge label with thousands of messages, Gmail can’t handle deleting all of them at a time (it says it can, but for me it’s never worked). This solves the problem.
I wrote it more as a practice to get familiar with FireWatir, so it’s not very pretty or anything and it’s a bit slow. I think WWW::Mechanize would be faster at it (although you wouldn’t have the eye-candy of seeing the live action on the browser ;-). I’ll port it to Mechanize, once I have some time, as a bootstrap into learning that too. I’ll have to subscribe to a few more lists in order to have testing ammo for all that. ;-)
If you have doubts on how to use or suggestions on how to improve it please feel free to contact me. It assumes, by the way, that Gmail is in German. Replace that string with the one that comes up for your language.
P.S.: there’s also a syntax highlighted version. Does anyone know of a way to highlight the code here in WordPress?
def empty_label(label)
ff = Firefox.new
ff.goto('http://mail.google.com/mail/h/x4odcwnm5f5v/?s=l&l=#{label}')
a = []
ff.checkboxes.each {|c| a << c.value}
while a.length > 0 do
c = []
a.each {|v| c << ff.checkbox(:value,v)}
c.each {|e| e.set}
ff.select_list(:name,'tact').select('In den Papierkorb verschieben')
ff.button(:name,'nvp_tbu_go').click
a = []
ff.checkboxes.each {|c| a << c.value}
end
end