Bulk deleting Gmail contacts

I’m migrating from a hosted Zimbra email setup to Gmail. When importing my contact data I had some glitches, and wanted an easy way to delete all the Gmail contacts. But no! Gmail only allows you to delete 500 at a time. And to do that, you have to click-click 500 times to select the contacts you want deleted. That wasn’t good for me.

After searching the net and trying a couple of things from posts, I was going to do some major bash scripting. I went out and plowed the driveway, and got a good idea. I’ll just make a little GreaseMonkey script to check off the boxes for me.

I signed into the Gmail account, and clicked the link at the bottom of the page marked “basic HTML”. Then I clicked “Contacts”, then “All Contacts”. I loaded the greasemonkey script shown below, and refreshed the page. The first 400 checkboxes were checked off, so all I had to do was press the Delete button. The page reloads automatically with the next 400 boxes checked. In about a minute, all the contacts were deleted!

Note: I’m using Google Apps for Gmail, your “namespace” below might be different for regular Gmail, I’m not sure.

// ==UserScript==
// @name           Select 400 Checkboxes
// @namespace      https://mail.google.com/a/
// @description    Checks off the first 400 checkboxes; good for removing Gmail contacts
// @include        https://addons.mozilla.org/en-US/firefox/addon/748
// ==/UserScript==

var allCheckboxes, thisCheckbox;
allCheckboxes = document.evaluate(
    "//input[@type='checkbox']",
    document,
    null,
    XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
    null);

for (var i = 0; i < 400; i++) {
    thisCheckbox = allCheckboxes.snapshotItem(i);
    thisCheckbox.checked=true
}
Advertisements

10 Comments

  1. jimcooncat said,

    January 3, 2013 at 6:37 am

    Thanks so much for the update, rawk!

  2. rawc kee said,

    December 27, 2012 at 6:48 pm

    hey there, here’s an update to use on current html gmail.

    // ==UserScript==
    
    // @name           Select 400 Checkboxes
    
    // @namespace      https://mail.google.com/mail/h
    // @description    Checks off the first 400 checkboxes; good for removing Gmail contacts
    
    // @include        https://addons.mozilla.org/en-US/firefox/addon/748
    
    // @grant	   none
    // ==/UserScript==
    
    
    
    var allCheckboxes, thisCheckbox;
    
    allCheckboxes = document.evaluate(
    
    	"//input[@type='checkbox']",
    
    	document,
    	null,
    
    	XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
    	null);
    
    
    
    for (var i = 0; i < 500; i++) {
    
    	thisCheckbox = allCheckboxes.snapshotItem(i);
    	thisCheckbox.checked=true
    }
    
  3. jimcooncat said,

    February 3, 2009 at 6:15 pm

    Not sure, Robert. I don’t see the need for limiting the namespace more than http://mail.google.com/a/. Make sure you’re looking at the html version, not the Ajax version. Enable the greasemonkey script, and reload the page. The first 400 checkboxes should be checked.

    It’s a very generic script, and should work on any html page with checkboxes.

  4. Robert Ralph said,

    February 2, 2009 at 3:15 pm

    Same situation here. I downloaded grease monkey and have tried to duplicate your script. I changed the namespace to http://mail.google.com/a/ombexpress.com/h/itde22p5nbvz/?v=cl&pnl=a and also tried http://mail.google.com/a/ombexpress.com/h/ but it doesn’t seem to work. Any ideas?

  5. jimcooncat said,

    December 23, 2008 at 12:47 pm

    We were using a hosted Zimbra, so there’s no trust issue in my eyes. I’m afraid I haven’t the time to host myself, as I used to do years ago with my first Gentoo server. If I went back to running a mail server, I would probably use Zimbra.

    I’m finding that Gmail’s spam filters are better than either the ones I set up before or my Zimbra host’s. There are probably better filters nowadays: I used razor, pyzor, and rules-du-jour. My Zimbra host is very expensive, and their smtp servers are slow.

  6. brousch said,

    December 23, 2008 at 11:52 am

    If you don’t mind my asking, why are you moving from Zimbra to Gmail? I recently looked at both of them, and decided to stay with Zimbra (in-house, not hosted) because I did not like giving all of our data to Google.

  7. jimcooncat said,

    December 23, 2008 at 5:41 am

    Seems to be intermittent. I still have Full Text RSS specified. I’ve contacted wordpress.com support for help. Thanks for letting me know.

  8. Tiago Faria said,

    December 22, 2008 at 6:06 pm

    Your feed is not displaying full text, which is something required for the Planet Ubuntu Users. Please get in contact if you want something done on my side.

    Thank you.

  9. jimcooncat said,

    December 22, 2008 at 5:26 pm

    Jeremy, that only works if you have 500 or less. I think my method works better than manual if you have 600 or more. Download and setup being worth 100 clicks…

  10. Jeremy Pyne said,

    December 22, 2008 at 1:34 pm

    … Or jsut click teh word all, one single click to select all 500 …


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: