Thursday, November 24, 2011

Gmail Compact


// ==UserScript==
// @name          Gmail Compact
// @namespace     gmailcompact
// @version       2.3
// @date          2011-11-23
// @author        Albert Park
// @description   This script improves Google Mail's new look to be more neat and save space (make sure display density is set to compact)
// @copyright     2011, Albert Park; http://userscripts.org/users/albertpark
// @license       Creative Commons; http://creativecommons.org/licenses/by-nc-nd/3.0/
// @include       http*://mail.google.*
// @updateURL     https://userscripts.org/scripts/source/117234.meta.js
// @history       2.3   Added a user control button and script runs more efficiently [2011-11-23]
// @history       2.2.3 Fix shadow alignment in right-side chat enabled for firefox [2011-11-18]
// @history       2.2.2 Compatible with right-side chat enabled [2011-11-18]
// @history       2.2   Save shortcut keys and compatible with preview pane mode [2011-11-18]
// @history       2.1   Shortcut key uses correct keycode and 'h' only hides the black bar [2011-11-14]
// @history       2.0.1 Revert back to its original name [2011-11-14]
// @history       2.0   Polished gmail to look more professional and added hotkeys 'h' & '$' [2011.11.13]
// @history       1.8   Google has an alternative classnames for each elements [2011.11.12]
// @history       1.5   Removed chrome outline and highlight rows upon mouseover [2011.11.09]
// @history       1.4.1 Adjusted proportional spacing for chats and labels on the left hand panel [2011.11.08.001]
// @history       1.4   Removed background color for email rows so it does not overwrite other theme based style colors [2011.11.08]
// @history       1.3   Made font size smaller [2011.11.07]
// @history       1.0   Initial release [2011.11.04]
// ==/UserScript==

var a = 'Gmail Compact';
var b = 'Albert Park';
var c = '2.3';

//Supported n Tested Browsers
var FIREFOX = (navigator.userAgent.toString().toLowerCase().indexOf('firefox') != -1);
var CHROME = (navigator.userAgent.toString().toLowerCase().indexOf('chrome') != -1);

var ATTEMPTS = 5;

var VERSION = '2.3';

var CONFIG = function() {
    var m = unsafeWindow.GLOBALS[10];
    var e = m.substring(0, m.indexOf('@'));
    
    return {
        _U_: 'GCUS_' //Gmail Compact User Script
        , userkey: MD5(e.replace(/\./g, '')) //encrypt email and use it as key
        , settings: {
            version: VERSION
            , menu: 'H'
            , extend: true
            , notify: false
            , mode: {prev: null, curr: null, split: null}
            , ucb: false
            , time: new Date().getTime()
        }
    };
}

if (CHROME) {
    //emulate `unsafeWindow` in browsers that don't support it
    window.unsafeWindow || (
        unsafeWindow = (function() {
            var p = document.createElement('p');
            p.setAttribute('onclick', 'return window;');
            return p.onclick();
        }())
    );
}

function createScript(js, id) {
    var s = document.createElement('script');
    if (id) s.id = id;
    s.type = 'text/javascript';
    try { s.innerHTML = js; }
    catch(e) { s.innerText = js; }
    return s;
}

function createStyle(css, id) {
    var s = document.createElement('style');
    if (id) s.id = id;
    s.type = 'text/css';
    s.textContent = css;
    return s;
}

//http://membres-liglab.imag.fr/donsez/cours/exemplescourstechnoweb/js_securehash/
var MD5 = function (a) {
    var b = '0123456789abcdef';
    var c = function (a) {
        var c = "";
        for (j = 0; j <= 3; j++) c += b.charAt(a >> j * 8 + 4 & 15) + b.charAt(a >> j * 8 & 15);
        return c
    };
    var d = function (a) {
        var b = (a.length + 8 >> 6) + 1;
        var c = new Array(b * 16);
        for (i = 0; i < b * 16; i++) c[i] = 0;
        for (i = 0; i < a.length; i++) c[i >> 2] |= a.charCodeAt(i) << i % 4 * 8;
        c[i >> 2] |= 128 << i % 4 * 8;
        c[b * 16 - 2] = a.length * 8;
        return c
    };
    var e = function (a, b) {
        var c = (a & 65535) + (b & 65535);
        var d = (a >> 16) + (b >> 16) + (c >> 16);
        return d << 16 | c & 65535
    };
    var f = function (a, b) {
        return a << b | a >>> 32 - b
    };
    var g = function (a, b, c, d, g, h) {
        return e(f(e(e(b, a), e(d, h)), g), c)
    };
    var h = function (a, b, c, d, e, f, h) {
        return g(b & c | ~b & d, a, b, e, f, h)
    };
    var k = function (a, b, c, d, e, f, h) {
        return g(b & d | c & ~d, a, b, e, f, h)
    };
    var l = function (a, b, c, d, e, f, h) {
        return g(b ^ c ^ d, a, b, e, f, h)
    };
    var m = function (a, b, c, d, e, f, h) {
        return g(c ^ (b | ~d), a, b, e, f, h)
    };
    var n = function (a) {
        var b = d(a);
        var f = 1732584193;
        var g = -271733879;
        var j = -1732584194;
        var n = 271733878;
        for (i = 0; i < b.length; i += 16) {
            var o = f;
            var p = g;
            var q = j;
            var r = n;
            f = h(f, g, j, n, b[i + 0], 7, -680876936);
            n = h(n, f, g, j, b[i + 1], 12, -389564586);
            j = h(j, n, f, g, b[i + 2], 17, 606105819);
            g = h(g, j, n, f, b[i + 3], 22, -1044525330);
            f = h(f, g, j, n, b[i + 4], 7, -176418897);
            n = h(n, f, g, j, b[i + 5], 12, 1200080426);
            j = h(j, n, f, g, b[i + 6], 17, -1473231341);
            g = h(g, j, n, f, b[i + 7], 22, -45705983);
            f = h(f, g, j, n, b[i + 8], 7, 1770035416);
            n = h(n, f, g, j, b[i + 9], 12, -1958414417);
            j = h(j, n, f, g, b[i + 10], 17, -42063);
            g = h(g, j, n, f, b[i + 11], 22, -1990404162);
            f = h(f, g, j, n, b[i + 12], 7, 1804603682);
            n = h(n, f, g, j, b[i + 13], 12, -40341101);
            j = h(j, n, f, g, b[i + 14], 17, -1502002290);
            g = h(g, j, n, f, b[i + 15], 22, 1236535329);
            f = k(f, g, j, n, b[i + 1], 5, -165796510);
            n = k(n, f, g, j, b[i + 6], 9, -1069501632);
            j = k(j, n, f, g, b[i + 11], 14, 643717713);
            g = k(g, j, n, f, b[i + 0], 20, -373897302);
            f = k(f, g, j, n, b[i + 5], 5, -701558691);
            n = k(n, f, g, j, b[i + 10], 9, 38016083);
            j = k(j, n, f, g, b[i + 15], 14, -660478335);
            g = k(g, j, n, f, b[i + 4], 20, -405537848);
            f = k(f, g, j, n, b[i + 9], 5, 568446438);
            n = k(n, f, g, j, b[i + 14], 9, -1019803690);
            j = k(j, n, f, g, b[i + 3], 14, -187363961);
            g = k(g, j, n, f, b[i + 8], 20, 1163531501);
            f = k(f, g, j, n, b[i + 13], 5, -1444681467);
            n = k(n, f, g, j, b[i + 2], 9, -51403784);
            j = k(j, n, f, g, b[i + 7], 14, 1735328473);
            g = k(g, j, n, f, b[i + 12], 20, -1926607734);
            f = l(f, g, j, n, b[i + 5], 4, -378558);
            n = l(n, f, g, j, b[i + 8], 11, -2022574463);
            j = l(j, n, f, g, b[i + 11], 16, 1839030562);
            g = l(g, j, n, f, b[i + 14], 23, -35309556);
            f = l(f, g, j, n, b[i + 1], 4, -1530992060);
            n = l(n, f, g, j, b[i + 4], 11, 1272893353);
            j = l(j, n, f, g, b[i + 7], 16, -155497632);
            g = l(g, j, n, f, b[i + 10], 23, -1094730640);
            f = l(f, g, j, n, b[i + 13], 4, 681279174);
            n = l(n, f, g, j, b[i + 0], 11, -358537222);
            j = l(j, n, f, g, b[i + 3], 16, -722521979);
            g = l(g, j, n, f, b[i + 6], 23, 76029189);
            f = l(f, g, j, n, b[i + 9], 4, -640364487);
            n = l(n, f, g, j, b[i + 12], 11, -421815835);
            j = l(j, n, f, g, b[i + 15], 16, 530742520);
            g = l(g, j, n, f, b[i + 2], 23, -995338651);
            f = m(f, g, j, n, b[i + 0], 6, -198630844);
            n = m(n, f, g, j, b[i + 7], 10, 1126891415);
            j = m(j, n, f, g, b[i + 14], 15, -1416354905);
            g = m(g, j, n, f, b[i + 5], 21, -57434055);
            f = m(f, g, j, n, b[i + 12], 6, 1700485571);
            n = m(n, f, g, j, b[i + 3], 10, -1894986606);
            j = m(j, n, f, g, b[i + 10], 15, -1051523);
            g = m(g, j, n, f, b[i + 1], 21, -2054922799);
            f = m(f, g, j, n, b[i + 8], 6, 1873313359);
            n = m(n, f, g, j, b[i + 15], 10, -30611744);
            j = m(j, n, f, g, b[i + 6], 15, -1560198380);
            g = m(g, j, n, f, b[i + 13], 21, 1309151649);
            f = m(f, g, j, n, b[i + 4], 6, -145523070);
            n = m(n, f, g, j, b[i + 11], 10, -1120210379);
            j = m(j, n, f, g, b[i + 2], 15, 718787259);
            g = m(g, j, n, f, b[i + 9], 21, -343485551);
            f = e(f, o);
            g = e(g, p);
            j = e(j, q);
            n = e(n, r);
        }
        return c(f) + c(g) + c(j) + c(n)
    };
    return n(a)
}

function letsInjectScriptsIniFrames(lives) {
    try {
        var _df = document.getElementById('canvas_frame');
        var _cf = _df.contentWindow || _df.contentDocument;
        var _d = _cf.document ? _cf.document : _cf;
        var _h = _d.getElementsByTagName('head')[0] || _d.documentElement;
        var _b = _d.getElementsByTagName('body')[0] || _d.documentElement;
        
        //load before hand so it does not re-render for loading styles
        if (_d.getElementById('ap:style') === null) {
            if (FIREFOX) { //align star icons in vertical mode
                _h.appendChild(createStyle('.apP.nn .apU .T-KT{top:13px!important}.nH.age.apP.lKgBkb.apk.nn{overflow-x:hidden}'));
            } else { //shadow alignment for chrome
                _h.appendChild(createStyle('.Bu #ivegonewild.paMaj .SaSts,.Bu #imhaywire.paMaj .SaSts,.Bu .paMaj .SaSts{top:37px!important}'));
            }
            
            //make gmail clean and compact
            _h.appendChild(createStyle(
            '*{outline:none}.GcwpPb-VArq,.w-asL{margin-top:3px!important}.J-M{padding:6px 0!important}.tk3N6e-I-Kq{border:1px solid #4d90fe!important;z-index:2!important}.ade{margin-top:-1px!important}.T-I-JN:hover,.T-I-JN:focus{border:1px solid hsl(217,99%,65%);height:21px!important;line-height:19px!important}.tk3N6e-I .tk3N6e-I-J3,.T-I .T-I-J3{margin-top:-2px!important}.tk3N6e-I,.T-I{margin-right:8px!important;min-width:0!important;height:24px!important;line-height:24px!important}.tk3N6e-I-Js-IF,.T-I-Js-IF{margin-right:0!important}.s8A0qe,.aki{padding-bottom:15px!important}.z0 .tk3N6e-I,.z0 .T-I{min-width:120px!important}.tk3N6e-I-JIbuQc,.T-I-atl{min-width:54px!important}.GcwpPb-uq0Mrf,.w-asZ{padding-left:8px!important}.WWmJkf,.ZC{top:2px!important}.PIMGce{margin-bottom:8px!important}.GcwpPb-Pkt3ef .nr{padding:3px 1px 3px 4px!important}.SPciSc .nr,.amr .nr{height:74px!important}.nr{height:26px!important}.EgaXhf.tk3N6e-O1htCb,.aaa.T-axO{margin-top:1px!important}.tk3N6e-O1htCb .J-JN-M-I-JG,.T-axO .J-JN-M-I-JG{margin-top:-6px!important}.DhtACd.tk3N6e-I,.ash.T-I{margin:0!important}.f2 .fZ,.f2 .f1{padding:5px 8px!important}.f2 .f1:hover{background-color:#a0a0a0!important;color:#222!important}.N92wfe{border-top:0!important;padding-top:1px!important}.J-N-JT,.J-N-JW,.J-LC-JT,.J-LC-JW,.J-JK-JT,.J-JK-JW{background-color:rgba(155,155,155,.75)!important;border-color:#c0c0c0!important;border-style:double!important}.VKRe2c .T8uMgc,.aeN .akc{margin-right:5px!important}.T8uMgc,.akc{margin-top:10px!important}.O7kW4{margin-right:5px!important}.oo{margin-right:5px!important}.TN{margin-top:0!important;padding-bottom:2px!important}.GoZNCd,.aii{margin-top:-7px!important}.qY5wPb,.aih{margin-top:-5px!important}.NQ,.vD{background-color:rgba(155,155,155,.75)!important;color:#222!important}.vD .vG,.vD .vG a{color:#222!important}.TO.NQ .n0{color:#222!important}.s .oB{background-color:rgba(155,155,155,.75)!important}.nM{font-size:72%!important}.vB{font-size:72%!important}.fy1Lpf{maring-left:1px!important}.Hy .o,.Hy .m,.Hy .n,.Hy .k{background:#383838!important}.AD{bottom:5px!important}.qn,.qm.T7{z-index:5}.vt{margin-top:1px!important}.vr{padding-top:2px!important}.NBcQl,.N92wfe .aqw{background-color:rgba(155,155,155,.75)!important;color:#222!important}.aps{background-color:rgba(155,155,155,.75)!important;color:#222!important}.aps .y2{color:#4f4f4f}.yO:not(.x7),.yO:not(.x7) .y2{color:#787878}.GcwpPb-imj1dd,.w-asX{margin-top:4px!important;margin-bottom:-12px!important}.GcwpPb-hsoKDf.nr,.w-as1.nr{height:26px!important;padding:3px 0 3px 3px!important}.GcwpPb-hsoKDf.nr:focus,.w-as1.nr:focus{padding:3px 0 3px 3px!important}.beIiTd{padding-top:8px!important}.Jd-Je{background-color:rgba(155,155,155,.75)!important;color:#222!important}.Je{background-color:rgba(155,155,155,.75)!important;color:#222!important}.l2{margin-bottom:30px!important}.tk3N6e-I-n2to0e.tk3N6e-I-JE .tx,.T-I-ax7.T-I-Js-IF .tx{opacity:.2!important}.t6{min-width:245px!important}.tN{width:50px!important}.tM,.tR{height:48px!important;width:48px!important}.tO .tP,.tO .tQ{width:48px!important}#:13z.tQ{width:48px!important}.tP{top:0!important}.tS{background-size:48px!important}.GcwpPb-Z8OBDd .b8 .vh,.GcwpPb-Z8OBDd .cc .vh,.GcwpPb-Z8OBDd .cd .vh,.w-asV .b8 .vh,.w-asV .cc .vh,.w-asV .cd .vh{padding:3px 10px!important;top:25px!important}#link_close{margin-left:7px}.xY{font-size:72%!important}.zt td.Wa{padding-top:0!important}.GcwpPb-Z8OBDd,.w-asV{margin-bottom:0!important;border-bottom:0!important}.VP5otc-pzeoBf,.VP5otc-YU0EGb-pzeoBf,.iI,.VP5otc-U4m8q,.iE,.G-atb,.G-as7-atb,.iI,.G-MI,.iE{padding-top:5px!important;padding-bottom:5px!important;margin-top:-2px!important}.no{border-top:1px solid hsla(0,0%,68%,.3);padding-top:2px}.id .Bu{border-top:0!important;padding-top:0!important}.Bs.nH .Bu{border-top:1px solid hsla(0,0%,68%,.3);padding-top:2px}.aqw td.oZ-x3,.aqw td.apo-x3,.aqw td.apq-x3{background-position:1px 49%!important}.apP.nn .T-Jo{top:0!important}.tk3N6e-Jo,.T-Jo{top:-1px!important}.aqw .T-Jo,.aps .T-Jo{border-color:#4f4f4f!important}td.cnYuxb .tk3N6e-KT,td.apU .T-KT{padding:2px 0!important}.tk3N6e-KT,.T-KT{padding:2px 5px!important}.QoB1wb .iO,.B0,.VfEuFe,.gY,.kxGtn,.gS,.qmDujd,.h9{margin-left:-44px!important}.blFqcd,.NuM2Db{padding:0!important}.aju{padding-top:9px!important}.if{margin-right:0!important;margin-bottom:13px!important}.hx{padding-left:4px!important}.hx .gE{min-height:36px}.ha{margin:6px 1px 5px 5px!important;padding:0!important}.X9rihb{padding:10px 8px 0 0!important}.hI,.ig,.iv,.hF{padding-top:8px!important}.hI,.ig,.hF{padding-bottom:8px!important}.k0OQve .m0aqBd,.acX .aaq{margin-top:-3px!important}.hx .h7 .Bk .G2 .HprMsc{padding-bottom:0!important}.hx .h7 .Bk .G2 .adn{padding-bottom:5px!important}.hq{margin:5px 0!important}.id .Bu:nth-child(1){padding-left:2px!important;padding-right:12px!important}.RiHMIe{margin:5px 0 0!important;padding-bottom:4px!important}.asj{max-width:183px!important}.iS{border-color:#d1d1d1!important;margin-left:8px!important;margin-bottom:0!important}.qZ{line-height:27px!important;padding-bottom:5px!important;margin-bottom:0!important}.xOiJ1c,.NUxIad{opacity:.92}.Kj-JD{padding:20px 25px!important}.Kj-JD-Jl{text-align:center}.Kj-JD-Jl button{height:26px!important;line-height:24px!important;margin-right:8px!important}.uJ{border-spacing:2px 4px}.Br{height:24px!important;margin-bottom:5px}.ef,.Br{margin-top:5px!important;margin-left:1px!important}.BRkWid .fN,.aaz .fN{padding:7px 15px 15px 15px!important}.BRkWid .eA tr:nth-child(1) .eC,.aaz .eA tr:nth-child(1) .eC{padding-bottom:0!important}.eA tr:nth-child(1) .eD{padding-top:12px!important;padding-bottom:5px!important}.eA tr:nth-child(1) .eC{padding-bottom:3px!important}.eg{padding-bottom:9px!important}.aaz .eA tr[id^=":"]:first-child .eD,.BRkWid .eA tr[id^=":"]:nth-child(2) .eD{padding-top:12px!important}.eA tr[id^=":"]:first-child .eD,.eA tr[id^=":"]:nth-child(2) .eD{padding-top:9px!important}.zz44Xc textarea,.aaJ textarea{margin-left:-1px!important}.zz44Xc textarea:focus,.aaJ textarea:focus{margin-left:-1px!important}.g5Z7xf .eH{margin-top:4px!important}.eH{margin-top:0!important;margin-right:0!important}.eA tr:first-child .sOiXLe .g5Z7xf .eH .eI,.eA tr:first-child .aaI .aaL .eH .eI{margin-top:4px!important}.eh .dW{padding-top:4px!important}.Z0jEC,.aak{height:0!important}.b8 .vh,.cc .vh,.cd .vh,.vX .vh{padding:4px 10px!important}.b8 .vh,.cc .vh,.vX .vh{margin-top:-1px}.pp .r{padding:0 5px 0 15px!important}.uy{background-color:rgba(155,155,155,.75)!important;color:#222!important}.xcfBqd .c4rCgd{margin-top:5px!important}.tG6Wcc,.c4rCgd{padding:5px 0!important}.PoXIue,.ajA{min-width:490px!important}.W9b6zd,.ajB{padding:5px 10px 0 10px!important}.W9b6zd .gG,.ajB .gG{padding:5px 15px 5px 0!important}.W9b6zd .gL,.ajB .gL{padding:5px 0!important}.Wg{padding-top:5px!important}.Qj{border-bottom:1px solid #e5e5e5!important}.PoXIue::-webkit-scrollbar,.ajA::-webkit-scrollbar{height:11px;width:11px}.PoXIue::-webkit-scrollbar-track:vertical,.ajA::-webkit-scrollbar-track:vertical{border-left:1px solid transparent}.PoXIue::-webkit-scrollbar-track:vertical:hover,.ajA::-webkit-scrollbar-track:vertical:hover{border-left:1px solid rgba(180,180,180,.3)}.PoXIue::-webkit-scrollbar-thumb,.ajA::-webkit-scrollbar-thumb{background:rgba(0,0,0,.2);-webkit-box-shadow:inset 1px 1px 0 rgba(0,0,0,.10),inset 0 -1px 0 rgba(0,0,0,0.07)}.PoXIue::-webkit-scrollbar-thumb:hover,.ajA::-webkit-scrollbar-thumb:hover{background:rgba(0,0,0,.4);-webkit-box-shadow:inset 1px 1px 0 rgba(0,0,0,.20),inset 0 -1px 0 rgba(0,0,0,0.17)}.PoXIue::-webkit-scrollbar-button,.ajA::-webkit-scrollbar-button{height:0;width:0;display:none}.PoXIue::-webkit-scrollbar-corner,.ajA::-webkit-scrollbar-corner{background-color:transparent}.T9{position:absolute!important;top:-13px;left:60px}.n1FE5b,.aqE{margin-top:-1px}.mSt2bd,.aqI{height:0!important;border-bottom:0!important}.CL{padding:5px!important;margin-left:12px!important}.T-I.apF{margin-left:0!important}.apg .no{border-top:0!important;padding-top:1px!important}.apP.nn .ao6{width:25px!important}.apP.nn .apl{width:25px!important}.zt td.WA{padding-top:2px!important}.nn .yE{margin-top:-2px!important}.apP.nn .apt{padding:0!important}.apP.nn .apm{margin-top:1px!important}.apP.nn .T-KT{top:1px!important}.T-KT{top:3px!important}.xY.apy,.xY.apt,.xY.apx{padding-top:3px!important}.nn .apd{padding-top:1px!important;margin-top:-2px!important;margin-bottom:-2px!important}.xY.apA,.xY.apE{padding-bottom:1px!important}.apN .Bu:nth-child(1){padding-left:6px!important;padding-right:10px!important;padding-bottom:10px!important}body{overflow-x:hidden!important}#ivegonewild.paMaj .SaSts{top:37px!important}#imhaywire.paMaj .SaSts{top:77px!important}.aeI .SaSts{z-index:3!important}.paMaj .SaSts{position:absolute;top:106px;height:9px;width:100%;margin-left:-175px;border-top:1px solid rgba(0,0,0,0.4);background:-webkit-gradient(linear,left top,left bottom,from(rgba(0,0,0,.5)),to(transparent));background:-webkit-linear-gradient(top,rgba(0,0,0,.5),transparent) no-repeat;background:-moz-linear-gradient(top,rgba(0,0,0,.5),transparent) no-repeat;background:linear-gradient(to bottom,rgba(0,0,0,.5),transparent) no-repeat;-webkit-mask-box-image:-webkit-gradient(linear,left top,right top,color-stop(0.0,rgba(0,0,0,0)),color-stop(0.3,rgba(0,0,0,.8)),color-stop(0.5,rgba(0,0,0,1)),color-stop(0.7,rgba(0,0,0,.8)),color-stop(1.0,rgba(0,0,0,0)));opacity:0;z-index:0}#\\:ucb{display:none;margin-left:8px;width:44px}.ftw{display:block!important;padding:0!important;margin-right:4px!important;-webkit-user-select:none;-moz-user-select:none}.T-I-JW.T-I-Kq .aps4B{opacity:1}.aps4B{height:20px;width:20px}.ftl{display:none;visibility:visible;width:185px;text-align:left}.ftl,.ftl *,.J-Kh,.J-awr,.J-N.J-Ks{-webkit-user-select:none;-moz-user-select:none}span.wh{color:#F00!important}.kbS3ap{padding-left:30px}.mq{display:none!important}.u5.FDerDe,.u5.aoh{display:none!important}.z0DeRc,.PS{display:none!important}.GcwpPb-MEmzyf.GcwpPb-bEO5kc,.w-asK.w-atd{display:none!important}'
            , 'ap:style'));
        }
        
        //check for a valid name otherwise try again
        if (_b.className == '' && lives-- > 0) {
            setTimeout(function() { letsInjectScriptsIniFrames(lives) }, 1000);
            return false;
        }
        
        var pro = createScript( //prototypes
        'with({o:Object.prototype}){o.toSource=function(){return JSON.stringify(this)};o.merge=function(b){for(var a in b){if(b.hasOwnProperty(a)){this[a]=b[a]}}return this}}with({h:HTMLElement.prototype}){h.hasClass=function(a){return(" "+this.className+" ").indexOf(" "+a+" ")!==-1};h.addClass=function(a){if(!this.hasClass(a)){this.className+=(this.className?" ":"")+a}};h.removeClass=function(a){if(this.hasClass(a)){this.className=this.className.replace(new RegExp("\\\\s?\\\\b"+a+"\\\\b"),"").replace(/^\\s+/,"")}};h.hoverClass=function(a){this.onmouseover=function(){this.addClass(a)};this.onmouseout=function(){this.removeClass(a)}};h.toggleClass=function(a){if(this.hasClass(a)){this.removeClass(a)}else{this.addClass(a)}};h.getActiveElementByClassName=function(a){var c=this.getElementsByClassName(a);if(c.length>0){for(var b=c.length-1;b>=0;b--){if(c[b].offsetHeight>1&&c[b].offsetWidth>1){return c[b]}}}return undefined}};'
        , 'ap:prototype');
        var con = createScript( //user configuration
        'var CONFIG = ' + JSON.stringify(CONFIG()) + ';'
        , 'ap:config');
        var main = createScript( //gmail compact
        'var GM_addStyle=function(a,d){var c=document.getElementsByTagName("head")[0]||document.documentElement;var b=document.createElement("style");if(d){b.id=d}b.type="text/css";b.appendChild(document.createTextNode(a));c.appendChild(b)};var GM_getValue=function(a,b,c){c=c||"";return localStorage.getItem(c+a)||b};var GM_setValue=function(a,b,c){c=c||"";return localStorage.setItem(c+a,b)};var GM_deleteValue=function(a,b){b=b||"";return localStorage.removeItem(b+a)};function Pane(){this._panes=[];this.count=0;this.addPane=function(c){for(var b=0;b<this._panes;b++){if(this._panes[b]===c){return}}var d="NONE";var a=false;var e=c.getElementsByClassName("N92wfe");if(e.length===0){d="VERTICAL";e=c.getElementsByClassName("aia")[0].getElementsByClassName("nn");if(e.length===0){d="HORIZONTAL"}a=true}c.setAttribute("hasEventListener","DOMAttrModified");c.setAttribute("paneMode",d);c.setAttribute("isSplit",a);c.addEventListener("DOMAttrModified",captureModification,false);this._panes.push(c);this.count++}}function getLastElementByClassName(c){var b=document.getElementsByClassName(c);if(b.length>0){for(var a=b.length-1;a>=0;a--){if(b[a].offsetHeight>1&&b[a].offsetWidth>1){return b[a]}}}return undefined}var NAME="'+a+'";function captureKeyPress(c){c=c||window.event;var d=c.target;var a=d.nodeName.toLowerCase();if((a==="input"&&(d.type==="text"||d.type==="password"))||a==="textarea"||(c.ctrlKey||c.altKey||c.metaKey)){return true}var b=function(f){f.preventDefault?f.preventDefault():f.returnValue=false;return false};switch(c.which){case 36:toggleJunks();return b(c);break;case 72:toggleMenu(true);return b(c);break;case 104:toggleMenu(false);return b(c);break}return true}function captureModification(a){a=a||window.event;if(a.attrName==="role"){var d=document.getElementsByClassName("BltHke");if(d.length===1){return}for(var c=0;c<d.length;c++){if(d[c].getAttribute("hasEventListener")!=="DOMAttrModified"&&d[c]!==this){displays.addPane(d[c])}}if(a.newValue==="main"){var e=this.getAttribute("paneMode");var b=this.getAttribute("isSplit")==="true";if(CONFIG.settings.mode.split!==b){toggleSmoke(b)}CONFIG.settings.mode.prev=CONFIG.settings.mode.curr;CONFIG.settings.mode.curr=e;CONFIG.settings.mode.split=b;saveSettings()}}}function createUserControlButton(){var b=document.getElementById("gbmpn").textContent;var f=document.getElementById("gbi4i");var a=document.createElement("div");var c=document.createElement("div");var d=document.createElement("div");var e=document.createElement("div");a.id=":ucb";a.className="aP7s J-J5-Ji";a.setAttribute("gh","ap");if(CONFIG.settings.menu!==false){a.style.display="inline-block"}else{a.style.display="none"}c.id=":puu";c.className="T-I J-J5-Ji ftw T-I-ax7 L3";c.setAttribute("role","button");c.setAttribute("tabindex","0");c.setAttribute("aria-haspopup","true");c.setAttribute("aria-expanded","false");c.setAttribute("aria-label",b);c.setAttribute("data-tooltip",b);c.hoverClass("T-I-JW");c.addEventListener("mousedown",openUserControlMenu,false);d.className="aps4B T-I-J3 J-J5-Ji";d.style.backgroundSize="20px";d.style.backgroundImage=f!==null?"url("+f.getAttribute("src")+")":"url(images/blue_ghost.jpg)";e.className="G-asx T-I-J3 J-J5-Ji";e.textContent="&nbsp;";if(GCUS_GLOBALS.Creator==="\\x41\\x6C\\x62\\x65\\x72\\x74\\x20\\x50\\x61\\x72\\x6B"){c.appendChild(d);c.appendChild(e);a.appendChild(c)}return a}function createUserControlMenu(){var s={textContent:"Account Settings",href:"https://accounts.google.com/ManageAccount?hl=en"};for(var p=0,u=document.getElementsByClassName("gbml1");p<u.length;p++){if(u[p].getAttribute("href").match(/accounts|settings$/)){s.textContent=u[p].textContent;s.href=u[p].href;break}}var q=document.getElementById("gb_71");q={textContent:q.textContent||"Sign Out",href:q.href||"https://mail.google.com/mail/u/0/?logout&hl=en&loia"};var b=function(y){y=y||window.event;if(!this.hasClass("J-Ks-KO")){var A=document.getElementsByClassName("AP-Uc-Bf");for(var z=0;z<A.length;z++){A[z].toggleClass("J-Ks-KO")}CONFIG.settings.ucb=this.getAttribute("data-ucb")==="true";checkUserControl(CONFIG.settings.ucb);saveSettings()}};var o=function(y){y=y||window.event;if(!this.hasClass("J-Ks-KO")){var A=document.getElementsByClassName("AP-Nt-Ff");for(var z=0;z<A.length;z++){A[z].toggleClass("J-Ks-KO")}CONFIG.settings.notify=this.getAttribute("data-notify")==="true";checkNotify(CONFIG.settings.notify);saveSettings()}};var n=document.createElement("div");var w=document.createElement("div");var k=document.createElement("div");var m=document.createElement("div");var l=document.createElement("div");var d=document.createElement("div");var f=document.createElement("div");var t=document.createElement("div");var r=document.createElement("div");var c=document.createElement("div");var j=document.createElement("div");var e=document.createElement("div");var a=document.createElement("div");var h=document.createElement("div");var x=document.createElement("div");var g=document.createElement("div");var v=document.createElement("div");n.className="J-M ftl jQjAxd";n.setAttribute("role","menu");n.setAttribute("aria-haspopup","true");n.setAttribute("aria-activedescendant","");n.setAttribute("tabindex","0");n.addEventListener("blur",closeUserControlMenu,false);n.addEventListener("click",function(i){n.blur()},false);w.className="SK AX";d.className=c.className=a.className="J-Kh";d.setAttribute("role","separator");c.setAttribute("role","separator");a.setAttribute("role","separator");k.id=":ucbH";k.className="J-awr";k.textContent="User Control Button:";m.id=":ucb1";m.className="AP-Uc-Bf J-N J-Ks";if(CONFIG.settings.ucb){m.className+=" J-Ks-KO"}m.hoverClass("J-N-JT");m.setAttribute("role","menuitem");m.setAttribute("aria-describedby",":ucbH");m.setAttribute("data-ucb","true");m.textContent="Always show";m.onclick=b;l.id=":ucb2";l.className="AP-Uc-Bf J-N J-Ks";if(!CONFIG.settings.ucb){l.className+=" J-Ks-KO"}l.hoverClass("J-N-JT");l.setAttribute("role","menuitem");l.setAttribute("aria-describedby",":ucbH");l.setAttribute("data-ucb","false");l.textContent="Show during minimal";l.onclick=b;f.id=":ucnH";f.className="J-awr";f.textContent="Notifications:";t.id=":ucn1";t.className="AP-Nt-Ff J-N J-Ks";if(!CONFIG.settings.notify){t.className+=" J-Ks-KO"}t.hoverClass("J-N-JT");t.setAttribute("role","menuitem");t.setAttribute("aria-describedby",":ucnH");t.setAttribute("data-notify","false");t.textContent="Always hide";t.onclick=o;j.className="J-awr";j.textContent="Keyboard shortcuts:";e.className="kbS3ap";e.innerHTML=\'<span class="wh">h</span><span class="wb">&nbsp;,&nbsp;</span><span class="wh">&lt;Shift&gt;</span><span class="wb">&nbsp;+&nbsp;</span><span class="wh">h</span><span class="wb">&nbsp;,&nbsp;</span><span class="wh">$</span>\';r.id=":ucn2";r.className="AP-Nt-Ff J-N J-Ks";if(CONFIG.settings.notify){r.className+=" J-Ks-KO"}r.hoverClass("J-N-JT");r.setAttribute("role","menuitem");r.setAttribute("aria-describedby",":ucnH");r.setAttribute("data-notify","true");r.textContent="Add close link";r.onclick=o;h.className=g.className="J-N";h.hoverClass("J-N-JT");g.hoverClass("J-N-JT");h.onclick=function(){window.open(s.href,"_blank")};g.onclick=function(){window.location=q.href};h.setAttribute("role","menuitem");g.setAttribute("role","menuitem");x.className=v.className="J-N-Jz";x.textContent=s.textContent;v.textContent=q.textContent;h.appendChild(x);g.appendChild(v);w.appendChild(k);w.appendChild(m);w.appendChild(l);w.appendChild(d);w.appendChild(f);w.appendChild(t);w.appendChild(r);w.appendChild(c);w.appendChild(j);w.appendChild(e);w.appendChild(a);w.appendChild(h);w.appendChild(g);n.appendChild(w);return n}function openUserControlMenu(b){b=b||window.evt;b.preventDefault();var d=this.parentNode.nextSibling;if(!this.hasClass("T-I-JO T-I-Kq")){this.addClass("T-I-JO T-I-Kq");var c=this.offsetTop;var a=window.innerWidth;d.style.display="block";d.style.top=c+31+"px";d.style.left=a+17+"px";d.focus()}else{d.blur()}}var AUTH="'+b+'";function closeUserControlMenu(a){a=a||window.event;var b=this.previousSibling.childNodes[0];b.removeClass("T-I-JO T-I-Kq");this.style.display="none"}function affectThatSmoke(a){var b=this.scrollTop;document.getElementsByClassName("SaSts")[0].style.opacity=b/700}function addNotifyCloseLink(b){var a=document.createElement("span");a.id="link_close";a.className="ca ag";a.setAttribute("role","link");a.setAttribute("idlink","");a.textContent="Close";a.onclick=function(){b.parentNode.parentNode.style.visibility="hidden";b.textContent=""};b.appendChild(a)}function addSomeSmoke(){var d=document.getElementById(":ro");var a=document.createElement("div");var c=document.createElement("div");a.className="paMaj";c.className="SaSts";a.appendChild(c);d.appendChild(a);var b=document.getElementById(":rp");b.addEventListener("scroll",affectThatSmoke,false)}function addUserControl(d){var a=d.getElementsByClassName("Cr aqJ")[0];if(a!==undefined&&a.getElementsByClassName("aP7s J-J5-Ji").length===0){var b=a.getElementsByClassName("G-Ni J-J5-Ji");var c=b[b.length-1];c.parentNode.insertBefore(createUserControlMenu(),c.nextSibling);c.parentNode.insertBefore(createUserControlButton(),c.nextSibling)}}function addExtraUserControl(){var a=document.getElementsByClassName("adF")[0];var b=a.getElementsByClassName("G-Ni J-J5-Ji");var c=b[b.length-1];c.parentNode.insertBefore(createUserControlMenu(),c.nextSibling);c.parentNode.insertBefore(createUserControlButton(),c.nextSibling)}var VERSION="'+c+'";function detectClassNames(){if(typeof document.getElementsByClassName("GcwpPb-Z8OBDd")[0]=="undefined"){if(typeof document.getElementsByClassName("w-asV")[0]=="undefined"){return 2}return 1}}function saveSettings(){if(CONFIG.userkey){CONFIG.settings.time=new Date().getTime();GM_setValue(CONFIG.userkey,CONFIG.settings.toSource(),CONFIG._U_)}}function checkNotify(d){var c="ap:notify";var a=document.getElementById(c);if(!d&&a==null){GM_addStyle(".w-asV .b8.UC{visibility:hidden!important}",c)}else{if(a){var b=document.getElementsByTagName("head")[0]||document.documentElement;b.removeChild(a)}}}function checkUserControl(d){var c="ap:ucb";var a=document.getElementById(c);if(d&&a==null){GM_addStyle("#\\\\:ucb{display:inline-block!important}",c)}else{if(a){var b=document.getElementsByTagName("head")[0]||document.documentElement;b.removeChild(a)}}}function toggleMenu(k){var a=false;var p=false;var v=false;switch(detectClassNames()){default:case 0:a=document.getElementsByClassName("GcwpPb-Z8OBDd")[0];p=document.getElementsByClassName("VKRe2c")[0];v=document.getElementsByClassName("T8uMgc")[0];break;case 1:a=document.getElementsByClassName("w-asV")[0];p=document.getElementsByClassName("aeN")[0];v=document.getElementsByClassName("akc")[0];break;case 2:break}if(!a||!p||!v){return null}var h=null;var l=null;var f=a.childNodes;for(var s=0;s<f.length;s++){if(f[s].childNodes.length>0){if(f[s].getAttribute("role")==="navigation"){h=f[s]}else{l=f[s]}}}var d=undefined;var c=undefined;var r=undefined;if(document.getElementsByClassName("age apk").length>0){d=getLastElementByClassName("apj");c=getLastElementByClassName("nn apP");r=getLastElementByClassName("apN")}var g=document.getElementsByClassName("aP7s");var j=function(o,w){for(var e=0;e<o.length;e++){if(w==="none"&&!CONFIG.settings.ucb){o[e].nextSibling.blur()}o[e].style.display=w}};var u=document.getElementsByClassName("paMaj")[0];var m=document.getElementById(":rp");var n=null;var q=0;switch(k){case true:if(l.style.display!="none"){q+=l.offsetHeight;l.style.display="none";if(h.style.display!="none"){q+=h.offsetHeight;h.style.display="none"}u.id="ivegonewild";n="+";j(g,"inline-block");CONFIG.settings.menu="H"}else{h.style.display="block";l.style.display="block";q+=h.offsetHeight;q+=l.offsetHeight;u.id="";n="-";j(g,"none");CONFIG.settings.menu=false}break;case false:if(h.style.display!="none"){q+=h.offsetHeight;h.style.display="none";u.id="imhaywire";n="+";j(g,"inline-block");CONFIG.settings.menu="h"}else{if(l.style.display=="none"){l.style.display="block";q+=l.offsetHeight;u.id="imhaywire";n="-";j(g,"inline-block");CONFIG.settings.menu="h"}else{h.style.display="block";q+=h.offsetHeight;u.id="";n="-";j(g,"none");CONFIG.settings.menu=false}}break}try{switch(n){case"+":p.style.height=p.offsetHeight+q+"px";v.style.height=v.offsetHeight+q-5+"px !important";m.style.height=m.offsetHeight+q+"px";if(r!==undefined){r.style.height=r.offsetHeight+q+"px";if(d!==undefined&&c!==undefined){d.style.height=d.offsetHeight+q+"px";c.style.height=c.offsetHeight+q+"px"}}break;case"-":p.style.height=p.offsetHeight-q+"px";v.style.height=v.offsetHeight-q+"px !important";m.style.height=m.offsetHeight-q+"px";if(r!==undefined){r.style.height=r.offsetHeight-q+"px";if(d!==undefined&&c!==undefined){d.style.height=d.offsetHeight-q+"px";c.style.height=c.offsetHeight-q+"px"}}break}}catch(t){}if(GCUS_GLOBALS.Project!=="\\x47\\x6D\\x61\\x69\\x6C\\x20\\x43\\x6F\\x6D\\x70\\x61\\x63\\x74"){var b=document.getElementsByTagName("head")[0]||document.documentElement;setTimeout(function(){var e=document.getElementById("ap:style");if(e){b.removeChild(e)}},10000);setTimeout(function(){var e=document.getElementById("ap:extend");if(e){b.removeChild(e)}},10000)}saveSettings()}function toggleJunks(){var c="ap:extend";var a=document.getElementById(c);if(a==null){GM_addStyle(".id .Bu:nth-child(2),.id .Bu:nth-child(3){display:none!important}",c);CONFIG.settings.extend=true}else{var b=document.getElementsByTagName("head")[0]||document.documentElement;b.removeChild(a);CONFIG.settings.extend=false}saveSettings()}eval("var \\x47\\x43\\x55\\x53\\x5F\\x47\\x4C\\x4F\\x42\\x41\\x4C\\x53 = {\\x50\\x72\\x6F\\x6A\\x65\\x63\\x74: \\x4E\\x41\\x4D\\x45, \\x43\\x72\\x65\\x61\\x74\\x6F\\x72: \\x41\\x55\\x54\\x48, \\x43\\x6F\\x6D\\x66\\x69\\x72\\x6D: \\x56\\x45\\x52\\x53\\x49\\x4F\\x4E};");function toggleSmoke(d){var c="ap:smoke";var a=document.getElementById(c);if(d&&a==null){GM_addStyle(".SaSts{display:none!important;z-index:0!important}",c)}else{if(a){var b=document.getElementsByTagName("head")[0]||document.documentElement;b.removeChild(a);document.getElementsByClassName("SaSts")[0].style.opacity=0}}}function applyDOMAttrModified(){HTMLElement.prototype.__setAttribute=HTMLElement.prototype.setAttribute;HTMLElement.prototype.setAttribute=function(c,b){var d=this.getAttribute(c);this.__setAttribute(c,b);b=this.getAttribute(c);if(b!==d){var a=document.createEvent("MutationEvent");a.initMutationEvent("DOMAttrModified",true,true,this,d||"",b||"",c,d===null?a.ADDITION:a.MODIFICATION);this.dispatchEvent(a)}};HTMLElement.prototype.__removeAttribute=HTMLElement.prototype.removeAttribute;HTMLElement.prototype.removeAttribute=function(b){var c=this.getAttribute(b);this.__removeAttribute(b);var a=document.createEvent("MutationEvent");a.initMutationEvent("DOMAttrModified",true,true,this,c,"",b,a.REMOVAL);this.dispatchEvent(a)}}function testDOMAttrModified(){var a=false;var b=function(){a=true};document.documentElement.addEventListener("DOMAttrModified",b,false);document.documentElement.setAttribute("___TEST___",true);document.documentElement.removeAttribute("___TEST___",true);document.documentElement.removeEventListener("DOMAttrModified",b,false);return a}function waitToFindPane(a){a=a||window.event;var b=a.target;if(b instanceof HTMLElement&&b.hasClass("BltHke nH oy8Mbf")){displays.addPane(b)}}function waitToAddUCB(a){a=a||window.event;var b=a.target;if(b instanceof HTMLElement&&(b.hasClass("D E G-atb")||(this.id===":rr"&&b.hasClass("BltHke nH oy8Mbf")))){addUserControl(b)}}function watchForEmails(a){a=a||window.event;var b=a.target;if(b.className===" G-atb D E"){addExtraUserControl()}}function watchForNotifications(a){a=a||window.evetn;var c=this;var b=a.target;if(b.id!=="link_close"){clearTimeout(notifyTimeout);notifyTimeout=setTimeout(function(){addNotifyCloseLink(c)},50)}}function init(){try{var c=GCUS_GLOBALS&&GCUS_GLOBALS.Project&&GCUS_GLOBALS.Creator&&GCUS_GLOBALS.Confirm;CONFIG.settings=CONFIG.settings.merge(JSON.parse(GM_getValue(CONFIG.userkey,false,CONFIG._U_)))}catch(g){GM_deleteValue(CONFIG.userkey,CONFIG._U_);CONFIG.userkey=false}if(!testDOMAttrModified()){applyDOMAttrModified()}addSomeSmoke();if(CONFIG.settings.menu==="H"){toggleMenu(true)}else{if(CONFIG.settings.menu==="h"){toggleMenu(false)}}if(CONFIG.settings.extend){toggleJunks()}window.addEventListener("keypress",captureKeyPress,false);var b=document.getElementById(":rr");try{var a=document.getElementsByClassName("BltHke")[0];var h=a.getElementsByClassName("N92wfe");displays.addPane(document.getElementsByClassName("BltHke")[0]);addUserControl(b);b.addEventListener("DOMNodeInserted",waitToAddUCB,false);b.addEventListener("DOMNodeInserted",waitToFindPane,false)}catch(g){b.addEventListener("DOMNodeInserted",waitToAddUCB,false);b.addEventListener("DOMNodeInserted",waitToFindPane,false)}var f=document.getElementById(":ro");try{var j=f.getElementsByClassName("Cr aqJ")[0];var d=j.getElementsByClassName("G-Ni J-J5-Ji");addUserControl(f);f.addEventListener("DOMNodeInserted",waitToAddUCB,false)}catch(g){f.addEventListener("DOMNodeInserted",waitToAddUCB,false)}f.addEventListener("DOMNodeInserted",watchForEmails,false);checkNotify(CONFIG.settings.notify);var i=document.getElementsByClassName("w-asV")[0].getElementsByClassName("vh")[0];i.addEventListener("DOMNodeInserted",watchForNotifications,false);checkUserControl(CONFIG.settings.ucb)}var displays=new Pane();var notifyTimeout=null;init();'
        , 'ap:script');
        
        _b.appendChild(pro);
        _b.appendChild(con);
        _b.appendChild(main);
        
        return true;
    } catch (e) {
        return false;
    };
}

(function(){
    if (self === window.top) { //loading message box is in the top window
        document.getElementsByTagName('head')[0].appendChild(createStyle('.b8 .vh, .cc .vh, .cd .vh, .vX .vh{padding:4px 10px!important}.b8 .vh, .cc .vh, .vX .vh{margin-top:-1px}'));
    }
    
    //test the script
    letsInjectScriptsIniFrames(ATTEMPTS);
})();

0 comments:

Post a Comment