Skip to content

GitHub code folding

Rob Garrison edited this page Sep 22, 2017 · 29 revisions

A userscript that adds code folding to GitHub files

  • This code only works on GitHub files (with line numbers), not in markdown code.
  • Works for both space and tab indentation.
  • This code was modified from the GitHub Code Folding Chrome extension by @noam3127 (MIT license).
  • Clicking on an arrow will collapse a section of code with the same indentation level.
  • Using Shift click on an arrow will collapse all sections of the same code indentation level.
  • After collapsing a code block, click on either the arrow (left side) or on the ellipsis (right side), to re-expand the code block.
  • Click this link to install from GitHub; or, install from GreasyFork or OpenUserJS.

Screenshot

github-code-folding

Change Log

Version 1.0.6 (9/2/2017)

  • Position ellipsis above code guides.
  • Append collapse arrow (prevent interference with whitespace userscript).

Version 1.0.5 (5/16/2017)

  • Change license to MIT.

Version 1.0.4 (4/21/2017)

  • Update mutation url.

Version 1.0.1 - 1.0.3 (4/13/2017)

  • Switch to using mutations.js.

Version 1.0.0 (3/25/2017)

  • Use pjax event & fix linting.

Version 0.1.1 (1/11/2017)

  • Clean up "closest" function.
  • Use classList toggle.

Version 0.1.0 (12/28/2016)

  • Initial commit
Clone this wiki locally