Skip to content

Instantly share code, notes, and snippets.

@matthewpoer
Last active March 1, 2017 14:41
Show Gist options
  • Save matthewpoer/656366fd32ab7e2ad192a8bc38716e23 to your computer and use it in GitHub Desktop.
Save matthewpoer/656366fd32ab7e2ad192a8bc38716e23 to your computer and use it in GitHub Desktop.
Click all of the "View trimmed content" buttons in a single Gmail thread. Alternatively, just open the Print view for the thread.
// note that the on-screen JS has a $ but it is not true jQuery
function findButton(){
button = $('[data-tooltip="Show trimmed content"]');
if(typeof button != 'undefined' && button.id){
return button;
} else {
return FALSE;
}
}
// clicks a button if it finds one
function clickButton(){
button = findButton();
if(button) button.click();
}
// cycle through 100 times. Gmail limites messages in a single thread
// to 100 so this should be a safe cap
for(var i=0;i<100;i++){
clickButton();
}
// note that the on-screen JS has a $ but it is not true jQuery
function findHideButton(){
button = $('[data-tooltip="Hide expanded content"]');
if(typeof button != 'undefined' && button.id){
return button;
} else {
return FALSE;
}
}
// if we find the expand button, remove it from the DOM. Also finds and
// removes a related whitespace element to keep things as clean as
// possible.
function killHideButton(){
button = findHideButton();
if(button){
buttonClass = button.getAttribute('class');
whiteSpaceArea = $('div[class="' + buttonClass + ' h4"]');
if(typeof button != 'undefined' && whiteSpaceArea.id){
whiteSpaceArea.parentElement.remove();
}
button.parentElement.remove();
}
}
// cycle through 100 times. Gmail limites messages in a single thread
// to 100 so this should be a safe cap
for(var i=0;i<100;i++){
killHideButton();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment