// ==UserScript==
// @name          Gmail Uncluttered
// @namespace     http://www.brentmuir.com/
// @description	  Removes ads, logo, redundant buttons and more to unclutter Gmail's interface.
// @version       1.4.0
// @date          2011-07-02
// @creator       bmuir
// @author        Brent Muir
// @orig_author   amio for ad block and quick link button redesign in Gmail Air Skin 2 (with ads-block)
// @include       http://mail.google.com/*
// @include       https://mail.google.com/*
// @include       http://*.mail.google.com/*
// @include       https://*.mail.google.com/*
// ==/UserScript==

(function() {

    var cssTweaks =
        // remove stuff
        " div.mn, " + // ads
        " div.pY, " + // invite box 
        " td.GcwpPb-Pkt3ef.GcwpPb-uq0Mrf div, " + // search buttons
        " div.GcwpPb-VArq.Z4b7Xb, " + // logo
        " div.GcwpPb-VArq.Rgky9, " + // logo
        " div.D.E.VP5otc-U4m8q " + // bottom buttons on list
        "   { display: none !important }" +

        // thread list: smaller right side date td
        " col.xX { width: 75px !important; padding-left: 0 !important }" +

        // shrink the div around the logo - leave some space for padding in Gmail
        " div[class=\"nH GcwpPb-Z8OBDd\"] div[class=\"nH oy8Mbf nn\"] " +
        "   { width: 5px !important; height: 45px !important }" +

        // add some padding to the right of the search box (for normal Gmail)
        " td.GcwpPb-Pkt3ef.GcwpPb-uq0Mrf { padding-left: 8px } " +

        // float the search bar left so that messages can appear to the right of the search box
        " table[class=\"cf GcwpPb-imj1dd\"] { float:left !important }" +

        // position top messages to the right of the search box
        " div.nH div.nH div.nH div.nH div.no div[class=\"nH nn\"] div.nH div[class=\"b8 UC\"] " +
        "   { position: absolute !important; left: 410px; padding: 1px 0 !important; margin-right: 10px; }" +

        // move and recolor the "Manage this domain" link
        " div[class=\"GcwpPb-MEmzyf GcwpPb-bEO5kc\"] { position:absolute; top: 3px; right:220px; z-index:1000 } " +
        " a[class=\"e GcwpPb-tOAp0c\"] { color: #36C !important; text-decoration: none; } " +

        // collapse bottom messages into a sentence
        " div[class=\"l2 ov nH oy8Mbf\"] div[class=\"md mj\"] div, " +
        " div[class=\"l2 ov nH oy8Mbf\"] div.l6 div " +
        "   { display: inline !important; padding-right: 8px }" +

        // hide policy links
        " div.yAeSuc " +
        "   { display: none }" +
        " div.svirc, div.KkMbSe " +
        "   { width: auto; text-align: left }" +

        // *************** Conversation view
        // remove ads
        " div.oM, .u8 { display: none !important }" +

        // remove quick reply box
        " div[class=\"ip iq\"] {  display: none !important }" +

        // hide right sidebar (people widget) and display on hover
        " table.Bs.nH.iY td.Bu:nth-child(2) > div.nH" +
        "   { width: 1px !important }" +
        " table.Bs.nH.iY td.Bu:nth-child(3) > div.nH" +
        "   { width:10px !important; overflow: hidden; background: #F2F2F2 }" +
        " table.Bs.nH.iY td.Bu:nth-child(3) > div.nH > div" +
        "   { opacity: 0; -webkit-transition: opacity 350ms ease-out; }" +
        " table.Bs.nH.iY td.Bu:nth-child(3) > div.nH:hover" +
        "   { width:225px !important; background: white }" +
        " table.Bs.nH.iY td.Bu:nth-child(3) > div.nH > div:hover" +
        "   { opacity: 1 }" +

        // remove bottom button bar
        " div[class=\" iE D E\"] { display: none !important }" ;

    // *************** Insert  CSS
    if (typeof addStyle != "undefined") {
        addStyle(cssTweaks);
    } else {
        var heads = document.getElementsByTagName("head");
        if (heads.length > 0) {
            var node = document.createElement("style");
            node.type = "text/css";
            node.appendChild(document.createTextNode(cssTweaks));
            heads[0].appendChild(node);
        }
    }
	
})();
