Skip to content

Instantly share code, notes, and snippets.

@tb0yd
Created June 19, 2017 14:25
Show Gist options
  • Save tb0yd/a8ecc5505e372a47e476a2c1be1608b9 to your computer and use it in GitHub Desktop.
Save tb0yd/a8ecc5505e372a47e476a2c1be1608b9 to your computer and use it in GitHub Desktop.
GHOpenAllExpanders.js
function simulateClick(el){
var evt = document.createEvent("MouseEvents");
evt.initMouseEvent("click", true, true, window,
0, 0, 0, 0, 0, false, false, false, false, 0, null);
el.dispatchEvent(evt);
}
function clickAllExpanders() {
var els = document.getElementsByClassName('diff-expander');
for(var i = 0; i < els.length; i++) {
simulateClick(els[i]);
}
setTimeout(function() {
if(document.getElementsByClassName('diff-expander').length > 0) {
clickAllExpanders();
}
}, 100);
}
clickAllExpanders();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment