Skip to content

GitHub collapse in comment

Rob Garrison edited this page Apr 21, 2017 · 29 revisions

A userscript that adds a header that can toggle long code and quote blocks in comments

  • The block header:
    • Allows the toggling of the long code & quote block views.
    • Includes the code language based on the syntax highlighting class name; if highlighting is not applied, "Block" is used as the default name.
    • Includes the number of lines within the block.
    • Click the header to toggle the view of the content immediately below the header.
    • Use Shift + Click to toggle all the view of all blocks within the same issue comment.
  • Can be used along with the GitHub-collapse-markdown userscript.
  • Use the userscript addon to change these settings (see screenshot below):
    • "Set GitHub Collapse in Comment Max Lines" to the number of lines within a block needed to add a header (set to 10 by default).
    • "Set GitHub Collapse in Comment Initial State" to expanded to not have the blocks initially collapsed (collapsed by default).
    • After changing either option, make sure to reload the page (Shift + F5) to have the updated setting take effect.
  • Click this link to install from GitHub, or install from GreasyFork.
  • Or, you can install it as a browser addon. Check out Octopatcher!

Screenshot

github-collapse-in-comment

Change Log

Version 1.0.10 (4/21/2017)

  • Update mutation url.

Version 1.0.7 - 1.0.9 (4/13/2017)

  • Switch to using mutations.js.

Version 1.0.6 (3/25/2017)

  • Use pjax & preview events.

Version 1.0.5 (1/11/2017)

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

Version 1.0.4 (10/3/2016)

  • Show current state when changing option. See issue #12.

Version 1.0.3 (10/2/2016)

  • Change initial state choices to "collapsed" or "expanded". See issue #12.

Version 1.0.2 (9/12/2016)

  • Beautify.

Version 1.0.1 (7/30/2016)

  • Improve accessibility of header.
  • Fix squished collapsed arrow.

Version 1.0.0 (6/27/2016)

  • Initial commit.
Clone this wiki locally