Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@micho
Last active October 9, 2015 14:08
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save micho/855b272d2f408f04729e to your computer and use it in GitHub Desktop.
Save micho/855b272d2f408f04729e to your computer and use it in GitHub Desktop.
Github PRs: Collapse/expand file
// Add a button to Collapse or Expand files in a Github PR
//
// See it in action: http://cl.ly/image/1r3q3d0d3b0p
//
// Install Tampermonkey and add this as a script
// ==UserScript==
// @name Github PRs: Collapse/expand file
// @namespace https://gist.github.com/micho/855b272d2f408f04729e
// @version 0.1
// @description Add a button to expand or collapse files in PRs
// @author You
// @match https://github.com/*/pull/*/files
// @grant none
// ==/UserScript==
$(function () {
$(".js-conduit-openfile-check").remove();
$(".file .actions").prepend(function () {
$button = $('<a href="#" class="minibutton">Collapse</a>')
$button.click(function (e) {
e.preventDefault();
$(this).parents(".file").find(".data").toggle()
$(this).text($(this).text() == "Collapse" ? "Expand" : "Collapse");
});
$(this).find(".minibutton").after($button).after(" ");
})
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment