// Copyright © 2013 Olegs Jeremejevs <olegs@jeremejevs.com>
// This work is free. You can redistribute it and/or modify it under the
// terms of the Do What The Fuck You Want To Public License, Version 2,
// as published by Sam Hocevar. See the COPYING file for more details.

function untrim()
{
    $('.ajV, .ajU').click().remove();
    $('.im').css('cssText', 'color: ' + $('.hx').css('color') + ' !important');
    $('.gmail_extra > br:first-child:not(.leave-alone)').remove();
    $('.gmail_extra > br:first-child').addClass('leave-alone');
}

function untrimForSure()
{
    untrim();
    window.setTimeout(untrim, 1000);
}

function untrimNotSure(event)
{
    var target = $(event.target);

    if (!target.is('.ajV, .ajU'))
        untrimForSure();
}

$(window).bind('hashchange', untrimForSure);
$(document).click(untrimNotSure);
untrimForSure();

@@ -413,27 +413,50 @@
 portant');%0D%0A
+%0D%0A
    
+ var firstLineBreak =
  $('.gmail_e
@@ -500,83 +500,155 @@
 e)')
-.remove();%0D%0A    $('.gmail_extra %3E br:first-child').addClass('leave-alone');
+;%0D%0A%0D%0A    if (firstLineBreak.length %3E 0)%0D%0A    %7B%0D%0A        firstLineBreak.next('br').addClass('leave-alone');%0D%0A        firstLineBreak.remove();%0D%0A    %7D
 %0D%0A%7D%0D
@@ -779,21 +779,13 @@
     
-var target = 
+if (!
 $(ev
@@ -799,28 +799,8 @@
 get)
-;%0D%0A%0D%0A    if (!target
 .is(

improve line break removal performance