WME Chat Resize

Adds resize buttons to the chat window

As of 2014-11-07. See the latest version.

// ==UserScript==
// @name 			WME Chat Resize
// @description 	Adds resize buttons to the chat window
// @namespace		RickZabel@gmail.com
// @grant			none
// @grant			GM_info
// @version			0.1.4
// @match			https://editor-beta.waze.com/*editor/*
// @match			https://www.waze.com/*editor/*
// @author			Rick Zabel '2014
// @license			MIT/BSD/X11
// ==/UserScript==

var WMEChatResizeVersion = "0.1.4";

/* Changelog
 * 0.1.4 - added an option to auto scroll chat to the bottom
 * 0.1.3 - Minor tweaks to the unread message notification width
 * 0.1.2 - i somehow forgot to fix when the chat is tall with the user list shown with street view open.
 * 0.1.1 - I forgot the text input area and new messages alert. I also found an issue when streetview was open and the users list was shown
 * 0.1.0 - Waze kept sending css updates to the chat so i had to completely rewrite the scrip to handle the CSS differently. Now there is 8 buttons for show hide and 4 functions, one for each of the chatroom sizes. 
 * 0.0.51 - more tweaks applied css for chat jumper buttons
 * 0.0.44 - More css tweaks 
 * 0.0.43 - Working with SeekingSerenity we found out that the tall chat on some resolutions the top of the chat would be unreachable so I switched from px to %
 * 0.0.42 - very minor 4 pixel changes to the normal chat height
 * 0.0.4 - removed the open space on the right of the chat
 * 0.0.3 - few div size corrections
 * 0.0.2 - made the buttons not Interfere with each other
 * 0.0.1 - initial version
 */

var WMEChatResizeVersionUpdateNotes = "WME Chat Resize has been updated to " + WMEChatResizeVersion;
WMEChatResizeVersionUpdateNotes = WMEChatResizeVersionUpdateNotes + "\r\n" + "This script adds buttons to the chat title bar and removes the space on the right of the chat.";
WMEChatResizeVersionUpdateNotes = WMEChatResizeVersionUpdateNotes + "\r\n" + "The buttons will let you hide or show the users list";
WMEChatResizeVersionUpdateNotes = WMEChatResizeVersionUpdateNotes + " " + "and will let you make the chat tall or normal heights.";
WMEChatResizeVersionUpdateNotes = WMEChatResizeVersionUpdateNotes + "\r\n" + "";
WMEChatResizeVersionUpdateNotes = WMEChatResizeVersionUpdateNotes + "\r\n" + "After a week of struggling I think I found a way to keep chat scrolling to the bottom. Next ";
WMEChatResizeVersionUpdateNotes = WMEChatResizeVersionUpdateNotes + "\r\n" + "Next to the chat box on the left there is either a ‘v’ for scroll on alternately ‘-‘ for scroll off. Currently this script checks the chat window every 5 seconds and only when needed scrolls down. The on / off setting is saved and should be reapplied on the next page load. in order to scroll up in chat or to disable click the v button.";
WMEChatResizeVersionUpdateNotes = WMEChatResizeVersionUpdateNotes + "\n" + "As usual let me know if there are any issues -RickZabel";

//alert the user in  WMEChatResize version updates
if (localStorage.getItem('WMEChatResizeVersion') == WMEChatResizeVersion) {
    console.log("UR Comments Version " + WMEChatResizeVersion);
} else {
    alert(WMEChatResizeVersionUpdateNotes);
    localStorage.setItem('WMEChatResizeVersion', WMEChatResizeVersion);
}

//setup some global vars to be used in the functions 
//currently i plan on lettings the chat default to normal on page load
//window.WMEChatResizeHeight = "short"; //short or tall
//window.WMEChatResizeUsers  = "shown";  //shown  or hidden


//setup some global vars to be used in the functions 
//currently i plan on lettings the chat default to normal on page load size
window.WMEChatResizeAutoScrollOnOff = "on";
window.WMEChatResizeAutoScrollChatCount = 0;

function WMEChatResize_bootstrap() {
        var bGreasemonkeyServiceDefined = false;

        try {
            var ver = window.navigator.appVersion.match(/Chrome\/(.*?) /)[1];
        } catch (err) {
            var ver = null;
        }
        if (null !== ver) {
            var itschrome = true;
            ///ver = "27.0.1438.7"; // last old working version
            // example: 32.0.1700.107
            // [0] - major versin
            // [2] - minor version
            ver = ver.split(".");
            ver[0] = parseInt(ver[0]);
            ver[2] = parseInt(ver[2]);
            if (ver[0] > 27) {
                var newmethod = true;
            } else if (ver[0] == 27) {
                if (ver[2] <= 1438) {
                    var newmethod = false;
                } else {
                    var newmethod = true;
                }
            } else {
                var newmethod = false;
            }
        } else {
            var itschrome = false;
            var newmethod = false;
        }

        try {
            if ("object" === typeof Components.interfaces.gmIGreasemonkeyService) // Firefox tells that "Components" is deprecated
            {
                bGreasemonkeyServiceDefined = true;
            }
        } catch (err) {};

        try {
            if ("object" === typeof GM_info) {
                bGreasemonkeyServiceDefined = true;
            }
        } catch (err) {};


        if ("undefined" === typeof unsafeWindow || !bGreasemonkeyServiceDefined) {
            try {
                unsafeWindow = (function() {
                    var dummyElem = document.createElement('p');
                    dummyElem.setAttribute('onclick', 'return window;');
                    return dummyElem.onclick();
                })();
            } catch (err) {
                //Ignore.
            }
        }
    
    /* FIX IT !!!! */
    var itschrome = true;
    var newmethod = true;
    var bGreasemonkeyServiceDefined = false;

    //And check again for new chrome, and no tamper(grease)monkey
    if (itschrome && newmethod && !bGreasemonkeyServiceDefined) {
        //use "dirty" but effective method with injection to document
        var DLscript = document.createElement("script");
        DLscript.textContent = 'unsafeWindow=window; \n' + // need this for compatibility
            WMEChatResize_init.toString() + ' \n' +
            'WMEChatResize_init();';
        DLscript.setAttribute("type", "application/javascript");
        document.body.appendChild(DLscript);
        document.body.removeChild(DLscript);
    } else {
        /* begin running the code! */
        WMEChatResize_init();
        ///setTimeout(WMEChatResize_init,200);
    }
  
    
    
}
    
function WMEChatResize_init() {
    
    WMEChatResize =  { 
        last: new Array(),
        isLast: false,
        isLSsupported: false,
        zoom: false
    };
    
    WMEChatResize.init = function() {
        //add the buttons to the chat title bar to hide/show user list and max and min
        
        //Short Chat Hide Users
        var b = $('<button id="WMEChatResizeShortChatHideUsers" class="WMEChatResize" style="position:absolute;Right:50px;color:#CC0000" title="Short Chat Hide Users" type="button">></button>');
        b.click (WMEChatResize.ShortChatHideUsers);
        $("#chat .header").append(b); 
        
        //Tall Chat Hide Users
        var b = $('<button id="WMEChatResizeTallHideUsers" class="WMEChatResize" style="position:absolute;Right:50px;color:#CC0000" title="Tall Chat Hide Users" type="button">></button>');
        b.click (WMEChatResize.TallHideUsers);
        $("#chat .header").append(b); 
        
        //Short Chat Show Users
        b = $('<button id="WMEChatResizeShortChatShowUsers" class="WMEChatResize" style="position:absolute;Right:50px;color:#CC0000" title="Short Chat Show Users" type="button"><</button>');
        b.click (WMEChatResize.ShortChatShowUsers);
        $("#chat .header").append(b);
        
        //Tall Chat Show Users
        b = $('<button id="WMEChatResizeTallShowUsers" class="WMEChatResize" style="position:absolute;Right:50px;color:#CC0000" title="Tall Chat Show Users" type="button"><</button>');
        b.click (WMEChatResize.TallShowUsers);
        $("#chat .header").append(b);		
        
        //Tall Chat Go Short with Hidden Users
        b = $('<button id="WMEChatResizeShortChatHideUsers2" class="WMEChatResize" style="position:absolute;Right:70px;color:#CC0000" title="Tall Chat Go Short with Hidden Users" 	type="button">v</button>');
        b.click (WMEChatResize.ShortChatHideUsers);
        $("#chat .header").append(b);
        
        //Tall Chat Go Short and Show Users
        b = $('<button id="WMEChatResizeShortChatShowUsers2" class="WMEChatResize" style="position:absolute;Right:70px;color:#CC0000" title="Tall Chat Go Short With Shown Users" 	type="button">v</button>');
        b.click (WMEChatResize.ShortChatShowUsers);
        $("#chat .header").append(b);
        
        //Short Chat Go Tall and Hide Users	   
        b = $('<button id="WMEChatResizeTallHideUsers2" class="WMEChatResize" style="position:absolute;Right:70px;color:#CC0000" title="Short Chat Go Tall and Hide Users" type="button">^</button>');
        b.click (WMEChatResize.TallHideUsers);
        $("#chat .header").append(b); 
        
        //Short Chat Go Tall and Show Users	 
        b = $('<button id="WMEChatResizeTallShowUsers2" class="WMEChatResize" style="position:absolute;Right:70px;color:#CC0000" title="Short Chat Go Tall and Show Users" type="button">^</button>');
        b.click (WMEChatResize.TallShowUsers);
        $("#chat .header").append(b); 
        
        //auto scroll running
        b = $('<button id="WMEChatResizeAutoScrollChatIsRunning" class="WMEChatResizeScrollChat" style="opacity: 100; position:absolute;Left:4px;Right:5px;color:#CC0000; background: #ffffff; border: 0px none !important; padding: 0px 0px 0px 0px;" title="MEChatResize Auto Scroll Running" type="button">v</button>');
        b.click(WMEChatResize.WMEChatResizeAutoScrollChatIsStopped);
        $("#chat .chat-body .messages .new-message").prepend(b);

        //stoped auto scrolling
        b = $('<button id="WMEChatResizeAutoScrollChatIsStopped" class="WMEChatResizeScrollChat" style="opacity: 100; position:absolute;Left:6px;Right:5px;color:#CC0000; background: #ffffff; border: 0px none !important; padding: 0px 0px 0px 0px;" title="MEChatResize Auto Scroll Stopped" type="button">-</button>');
        b.click(WMEChatResize.WMEChatResizeAutoScrollChatGo);
        $("#chat .chat-body .messages .new-message").prepend(b);

        //get the WMEChatResizeAutoScroll option
        window.WMEChatResizeAutoScroll = localStorage.getItem('WMEChatResizeAutoScroll');
        //alert(WMEChatResizeAutoScroll);

        if (WMEChatResizeAutoScroll == "" || WMEChatResizeAutoScroll == null) {
            //alert(WMEChatResizeAutoScroll);
            //} else {
            //alert("UR-Commenst now has multiple User's commnet lists that you may choose from. To select from the lists look under the settings section");
            WMEChatResizeAutoScroll ="Scroll";
            localStorage.setItem('WMEChatResizeAutoScroll', WMEChatResizeAutoScroll);
        }       
        
        //if the user wants the chat scroll on enable auto scroll
        if(WMEChatResizeAutoScroll ==="Scroll"){
            // auto scroll buttons
            document.getElementById('WMEChatResizeAutoScrollChatIsRunning').style.visibility = "visible"; // 
            document.getElementById('WMEChatResizeAutoScrollChatIsStopped').style.visibility = "hidden"; // 
            //delay start auto scroll
            setTimeout( WMEChatResize.WMEChatScrollChatTimeout, 2000);     
        } else {
            document.getElementById('WMEChatResizeAutoScrollChatIsRunning').style.visibility = "hidden"; // 
            document.getElementById('WMEChatResizeAutoScrollChatIsStopped').style.visibility = "visible"; //
        }
        
        //hide my short chat button since the chat loads short
        //document.getElementById('WMEChatResizeShortChatHideUsers').style.visibility="hidden";		// > short hide users
        document.getElementById('WMEChatResizeTallHideUsers').style.visibility="hidden";			// > tall hide users 
        document.getElementById('WMEChatResizeShortChatShowUsers').style.visibility="hidden";		// < short show users
        document.getElementById('WMEChatResizeTallShowUsers').style.visibility="hidden";			// < tall show users 
        document.getElementById('WMEChatResizeShortChatHideUsers2').style.visibility="hidden";		// V short hide users 
        document.getElementById('WMEChatResizeShortChatShowUsers2').style.visibility="hidden";		// V short show users 
        document.getElementById('WMEChatResizeTallHideUsers2').style.visibility="hidden";			// ^ tall hide users
        //document.getElementById('WMEChatResizeTallShowUsers2').style.visibility="hidden";			// ^ tall show users
        
        //chat size buttons			
        /*
        short hide users btn 	
        >	V
        WMEChatResize.ShortChatHideUsers	

        short show users btn	
        <	V
        WMEChatResize.ShortChatShowUsers	


        tall hide users btn	
        >	^
        WMEChatResize.TallHideUsers	

        tall shown users btn	
        <	^
        WMEChatResize.TallShowUsers	

        //button IDs
        WMEChatResizeShortChatHideUsers	
        WMEChatResizeTallHideUsers	
        WMEChatResizeShortChatShowUsers	
        WMEChatResizeTallShowUsers	
        WMEChatResizeShortChatHideUsers2	
        WMEChatResizeShortChatShowUsers2	
        WMEChatResizeTallHideUsers2	
        WMEChatResizeTallShowUsers2	
        */	
        
        
        // since the chat jumper link isn't always present I had to apply the style to the head  
        var g = $('<style type="text/css">#ChatJumper-JUMP.ChatJumper, #ChatJumper-JUMP-clear { font-size: 11px !important; padding-left: 1px !important; padding-right: 1px !important; }</style>');
        $("head").append(g);  
        
        // since sometime waze takes back over i am going to make a custom ccs that i edit the innerhtml
        var h = $('<style type="text/css" id="WMEChatResizeCSS">1234</style>');
        $("head").append(h);
        
        //move the chat all the way to the right 
        document.getElementById('chat-overlay').style.right="0px";
        
        //shrink down the chat title bar stuff to work with chat jumper
        
        //single-room-label
        var divsToModify = document.getElementsByClassName("single-room-label");
        for(var i = 0; i < divsToModify.length; i++) {        
            divsToModify[i].style.fontSize="11px";
            divsToModify[i].style.paddingLeft="8px";
        }
        
        //dropdown-toggle
        var divsToModify = document.getElementsByClassName("dropdown-toggle");
        for(var i = 0; i < divsToModify.length; i++) {        
            divsToModify[i].style.paddingLeft="5px";
            divsToModify[i].style.paddingRight="0px";
        }
        
        //status
        var divsToModify = document.getElementsByClassName("status");
        for(var i = 0; i < divsToModify.length; i++) {        
            divsToModify[i].style.fontSize="11px";
        }   
      
    };
    
    
    WMEChatResize.WMEChatResizeAutoScrollChatIsStopped = function() {
        console.log("WME Chat Resizer -Stopping Auto Scrolling Chat");
        //The button that showed auto scroll is running "V" was clicked turn off autoscroll and hide/ show buttons

        //window.WMEChatResizeAutoScrollOnOff = "Off";
        //WMEChatResizeAutoScrollOnOff == "Off"
    		document.getElementById('WMEChatResizeAutoScrollChatIsRunning').style.visibility = "hidden";
		    document.getElementById('WMEChatResizeAutoScrollChatIsStopped').style.visibility = "visible";

        //save the autoscroll setting
            WMEChatResizeAutoScroll ="NoScroll";
            localStorage.setItem('WMEChatResizeAutoScroll', WMEChatResizeAutoScroll);
    };


    WMEChatResize.WMEChatResizeAutoScrollChatGo = function() {
        //The button that showed auto scroll is off "-" was clicked turn on autoscroll and hide/ show buttons
        console.log("WME Chat Resizer - Clicked Scroll to bottom of chat");

        //auto scroll btns
        //WMEChatResizeAutoScrollOnOff == "On"		
        document.getElementById('WMEChatResizeAutoScrollChatIsRunning').style.visibility = "visible";
        document.getElementById('WMEChatResizeAutoScrollChatIsStopped').style.visibility = "hidden";
        
        //save the autoscroll setting
        WMEChatResizeAutoScroll ="Scroll";
        localStorage.setItem('WMEChatResizeAutoScroll', WMEChatResizeAutoScroll);
		
        //set the timeout to launch the function that does the scrolling of the chat
		    setTimeout( WMEChatResize.WMEChatScrollChatTimeout, 5000);
    };

    
    WMEChatResize.WMEChatScrollChatTimeout = function() {

            if (document.getElementById('WMEChatResizeAutoScrollChatIsRunning').style.visibility == "visible") {
                //scroll the chat to the divs length
                //console.log($("#chat .chat-body .messages .message-list").scrollHeight);
                //console.log($("#chat .chat-body .messages .message-list").scrollTop());

                var elem = $("#chat .chat-body .messages .message-list");
                if (elem[0].scrollHeight - elem.scrollTop() == elem.outerHeight()) {
                    //bottom of chat
                    //console.log("WMEChatResize - Chat is All Ready At The Bottom");
                } else {
                    
                    $("#chat .chat-body .messages .message-list").scrollTop($("#chat .chat-body .messages .message-list")[0].scrollHeight+10000);
                  
                    WMEChatResizeAutoScrollChatCount++;;
                    //$("#WMEChatResizeAutoScrollChatIsRunning").html(WMEChatResizeAutoScrollChatCount);
                    console.log("WMEChatResize - Scrolling Down To The Bottom Of Chat; " + WMEChatResizeAutoScrollChatCount + " Times.");
                }

            }
           setTimeout(WMEChatResize.WMEChatScrollChatTimeout, 5000);
                    /*
                    //send text to the chat message area
                    b = $('<div id="rickzabel" class="message normal-message"><div class="from">RickZabel</div><div class="body"><div style="direction: ltr; text-align: left;">testing</div>');
                    // b.click (WMEChatResize.TallShowUsers);
                    $("#chat .chat-body .messages .message-list").append(b);
                    */
    };

    
    WMEChatResize.ShortChatHideUsers = function() {
        //alert("ShortChatHideUsers");
        
        // adjust my buttons
        document.getElementById('WMEChatResizeShortChatHideUsers').style.visibility="hidden";		// > short hide users
        document.getElementById('WMEChatResizeTallHideUsers').style.visibility="hidden";			// > tall hide users 
        document.getElementById('WMEChatResizeShortChatShowUsers').style.visibility="visible";		// < short show users
        document.getElementById('WMEChatResizeTallShowUsers').style.visibility="hidden";			// < tall show users 
        document.getElementById('WMEChatResizeShortChatHideUsers2').style.visibility="hidden";		// V short hide users
        document.getElementById('WMEChatResizeShortChatShowUsers2').style.visibility="hidden";		// V short show users 
        document.getElementById('WMEChatResizeTallHideUsers2').style.visibility="visible";			// ^ tall hide users
        document.getElementById('WMEChatResizeTallShowUsers2').style.visibility="hidden";			// ^ tall show users
        
        var WMEChatResizeStringer = "";
        
        //hide users list
        WMEChatResizeStringer = WMEChatResizeStringer + ".users {visibility: hidden !important;}";
        
        //document.getElementById('chat').style.width="275px";  //497
        WMEChatResizeStringer = WMEChatResizeStringer + "#chat {width: 275px !important; }";
        
        //chat-body
        WMEChatResizeStringer = WMEChatResizeStringer + ".chat-body {width: 275px !important;}";
        
        //messages
        WMEChatResizeStringer = WMEChatResizeStringer + ".messages {width: 348px !important;}";
        
        //message-list
        //WMEChatResizeStringer = WMEChatResizeStringer + ".message-list {width: 275px; max-height: 246px;}"
        WMEChatResizeStringer = WMEChatResizeStringer + "#chat-overlay #chat .messages .message-list {width: 275px !important; top: 43px !important; bottom: 0px !important; position: absolute !important; max-height: 90% !important;}";
             
        //new-message
        WMEChatResizeStringer = WMEChatResizeStringer + "#chat .messages .new-message {width: 100% !important;}";
        
        //message-input
        WMEChatResizeStringer = WMEChatResizeStringer + ".message-input {width: 100% !important;}";
        
        //unread-messages-notification width
        WMEChatResizeStringer = WMEChatResizeStringer + ".unread-messages-notification {width: 251px !important;}";
        
        document.getElementById("WMEChatResizeCSS").innerHTML = WMEChatResizeStringer;
    };
    
    
    WMEChatResize.ShortChatShowUsers = function() {
        //alert("ShortChatShowUsers");
        // adjust my buttons
        document.getElementById('WMEChatResizeShortChatHideUsers').style.visibility="visible";		// > short hide users
        document.getElementById('WMEChatResizeTallHideUsers').style.visibility="hidden";			// > tall hide users 
        document.getElementById('WMEChatResizeShortChatShowUsers').style.visibility="hidden";		// < short show users
        document.getElementById('WMEChatResizeTallShowUsers').style.visibility="hidden";			// < tall show users 
        document.getElementById('WMEChatResizeShortChatHideUsers2').style.visibility="hidden";		// V short hide users 
        document.getElementById('WMEChatResizeShortChatShowUsers2').style.visibility="hidden";		// V short show users
        document.getElementById('WMEChatResizeTallHideUsers2').style.visibility="hidden";			// ^ tall hide users
        document.getElementById('WMEChatResizeTallShowUsers2').style.visibility="visible";			// ^ tall show users
        
        var WMEChatResizeStringer = "";
        
        //WMEChatResizeStringer = WMEChatResizeStringer + "#chat {height: 357px;}"
        
        //show users
        WMEChatResizeStringer = WMEChatResizeStringer + ".users {visibility: visible !important;}";
        
        //document.getElementById('chat').style.width="497px";  //497
        WMEChatResizeStringer = WMEChatResizeStringer + "#chat {width: 497px !important;}";
        
        //chat-body
        WMEChatResizeStringer = WMEChatResizeStringer + ".chat-body {width: 497px !important;}";
        
        //messages
        WMEChatResizeStringer = WMEChatResizeStringer + ".messages {width: 350px !important;}";
        
        //message-list
        WMEChatResizeStringer = WMEChatResizeStringer + ".message-list {width: 348px !important; max-height: 246px !important;}";
        
        //new-message
        WMEChatResizeStringer = WMEChatResizeStringer + ".new-message {width: 350px !important;}";
        
        //message-input
        WMEChatResizeStringer = WMEChatResizeStringer + ".message-input {width: 100% !important;}";
        
        //unread-messages-notification
        WMEChatResizeStringer = WMEChatResizeStringer + ".unread-messages-notification {width: 322px !important;}";
        
        document.getElementById("WMEChatResizeCSS").innerHTML = WMEChatResizeStringer;
        
        
    };
    
    
    WMEChatResize.TallHideUsers = function() {
        //alert("TallHideUsers");
        //WMEChatResizeHeight = "tall";
        
        // adjust my buttons
        document.getElementById('WMEChatResizeShortChatHideUsers').style.visibility="hidden";		// > short hide users
        document.getElementById('WMEChatResizeTallHideUsers').style.visibility="hidden";			// > tall hide users 
        document.getElementById('WMEChatResizeShortChatShowUsers').style.visibility="hidden";		// < short show users
        document.getElementById('WMEChatResizeTallShowUsers').style.visibility="visible";			// < tall show users 
        document.getElementById('WMEChatResizeShortChatHideUsers2').style.visibility="visible";		// V short hide users
        document.getElementById('WMEChatResizeShortChatShowUsers2').style.visibility="hidden";		// V short show users 
        document.getElementById('WMEChatResizeTallHideUsers2').style.visibility="hidden";			// ^ tall hide users
        document.getElementById('WMEChatResizeTallShowUsers2').style.visibility="hidden";			// ^ tall show users
        
        var WMEChatResizeStringer = "";
        
        //chat 
        WMEChatResizeStringer = WMEChatResizeStringer + "#chat {height: 100% !important; width: 275px !important;}";
        
        //chat-body
        WMEChatResizeStringer = WMEChatResizeStringer + ".chat-body {height: 96% !important; width: 275px !important;}";
        
        //messages 
        WMEChatResizeStringer = WMEChatResizeStringer + "#chat .messages {height: 95% !important; width: 348px !important;}";
        
        //message-list
        //width: 350 px
        //top: 43px
        //bottom: 0px
        //position: absolute
        //no height
        //max-height:90%
        WMEChatResizeStringer = WMEChatResizeStringer + "#chat-overlay #chat .messages .message-list {width: 275px !important; top: 43px !important; bottom: 0px !important; position: absolute !important; max-height: 90% !important;}";
        
        //hide users list
        WMEChatResizeStringer = WMEChatResizeStringer + ".users {visibility: hidden !important;}";
        
        //unread-messages-notification
        WMEChatResizeStringer = WMEChatResizeStringer + ".unread-messages-notification {width: 251px !important;}";
        
        //new-message
        WMEChatResizeStringer = WMEChatResizeStringer + "#chat .messages .new-message {width: 100% !important;}";
        
        //chat-overlay
        WMEChatResizeStringer = WMEChatResizeStringer + "#chat-overlay {bottom: 24px !important; height: 95% !important;}";
        
        // lets build up a string and set that as the innerhtml
        document.getElementById("WMEChatResizeCSS").innerHTML = WMEChatResizeStringer;
        
    };
    
    
    WMEChatResize.TallShowUsers = function() {
        //alert("TallShowUsers");
        //WMEChatResizeHeight = "tall";
        
        // adjust my buttons
        document.getElementById('WMEChatResizeShortChatHideUsers').style.visibility="hidden";		// > short hide users
        document.getElementById('WMEChatResizeTallHideUsers').style.visibility="visible";			// > tall hide users
        document.getElementById('WMEChatResizeShortChatShowUsers').style.visibility="hidden";		// < short show users
        document.getElementById('WMEChatResizeTallShowUsers').style.visibility="hidden";			// < tall show users 
        document.getElementById('WMEChatResizeShortChatHideUsers2').style.visibility="hidden";		// V short hide users
        document.getElementById('WMEChatResizeShortChatShowUsers2').style.visibility="visible";		// V short show users
        document.getElementById('WMEChatResizeTallHideUsers2').style.visibility="hidden";			// ^ tall hide users
        document.getElementById('WMEChatResizeTallShowUsers2').style.visibility="hidden";			// ^ tall show users
        
        var WMEChatResizeStringer = "";
        
        //chat 
        WMEChatResizeStringer = WMEChatResizeStringer + "#chat {width: 497px !important; height: 100% !important;}";
        
        //chat-body
        WMEChatResizeStringer = WMEChatResizeStringer + ".chat-body {width: 497px !important; height: 96% !important;}";
        
        //messages 
        WMEChatResizeStringer = WMEChatResizeStringer + "#chat .messages {width: 350px !important; height: 95% !important;}";
        
        //message-list
        //width: 350 px
        //top: 43px
        //bottom: 0px
        //position: absolute
        //no height
        //max-height:90%
        
        //message-list
        WMEChatResizeStringer = WMEChatResizeStringer + "#chat-overlay #chat .messages .message-list {width: 350px !important; top: 43px !important; bottom: 0px !important; position: absolute !important; max-height: 90% !important;}";
        
        //users
        WMEChatResizeStringer = WMEChatResizeStringer + ".users {height: 99% !important; max-height: 100% !important;}";
        
        //chat-overlay
        WMEChatResizeStringer = WMEChatResizeStringer + "#chat-overlay {bottom: 24px !important; height: 95% !important;}";
        
        //new-message
        WMEChatResizeStringer = WMEChatResizeStringer + ".new-message {width: 350px !important;}";
        
        //message-input
        WMEChatResizeStringer = WMEChatResizeStringer + ".message-input {width: 100% !important;}";
        
        //unread-messages-notification
        WMEChatResizeStringer = WMEChatResizeStringer + ".unread-messages-notification {width: 322px !important;}";
        
        // lets build up a string and set that as the innerhtml
        document.getElementById("WMEChatResizeCSS").innerHTML = WMEChatResizeStringer;
        
    };
  
    
    WMEChatResize.startcode = function () {
        // Check if WME is loaded, if not, waiting a moment and checks again. if yes init WMEChatResize
        try {
            if ("undefined" != typeof unsafeWindow.W.model.chat.rooms._events.listeners.add[0].obj.userPresenters[unsafeWindow.Waze.model.loginManager.user.id] ) {
                console.log("WMEChatResize ready to resize");
                WMEChatResize.init();
            } else {
                setTimeout(WMEChatResize.startcode, 200);
            }
        } catch(err) {
            setTimeout(WMEChatResize.startcode, 200);
        }
    };
    //setTimeout(WMEChatResize.startcode, 5000);
    WMEChatResize.startcode();
}

WMEChatResize_bootstrap();