Last active
April 12, 2017 17:20
-
-
Save juanca/403d4ef5bbfe826a2cefd3455e4b47c9 to your computer and use it in GitHub Desktop.
Github PR bookmarklet: button to toggle height on file diff
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript: | |
document.querySelectorAll('.file').forEach(function (fileDiff) { | |
var div, fa; | |
div = document.createElement('div'); | |
div.className = 'btn btn-sm'; | |
div.textContent = 'TOGGLE'; | |
div.addEventListener('click', function (event) { | |
const fileActions = event.target.parentElement; | |
const fileHeader = fileActions.parentElement; | |
const file = fileHeader.parentElement; | |
const blobWrapper = file.querySelector('.blob-wrapper'); | |
console.log('Toggle height on', blobWrapper); | |
blobWrapper.style.height = (blobWrapper.style.height === '' ? '0px' : ''); | |
}); | |
fa = fileDiff.querySelector('.file-actions'); | |
fa.insertBefore(div, fa.children[0]); | |
}); |
Well well well, looks like github released their own "expand/collapse" button. >:(
... It's probably more performant than my JS.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Looks like there is a bug where the event handler is cleaned up when switching between PR tabs. :(