Skip to content

GitHub table of contents

Rob Garrison edited this page Feb 17, 2019 · 58 revisions

A userscript that adds a table of contents to both readme and wiki pages.

  • A draggable popup window is automatically added when rendered markdown is detected; there must be at least three anchors before the TOC is created.
  • The TOC will refresh while switching between pages, and previewing markdown changes.
  • Click and hold on the header to move the TOC window. If it gets moved and you can't get it back, use the keyboard shortcut to reset the position.
  • Click on the header icon to toggle the window between the upper right corner and its last position. Or use the keyboard shortcut to toggle the view.
  • Each anchor within the rendered markdown will be included in the TOC window.
  • Some anchor link text may be truncated, hover over the link to see the full title.
  • Click on the arrow next to the anchor link to toggle the sub-group.
  • Shift + Click on the arrow next to the anchor to toggle all same level items.
  • To modify the "Table of Contents" text, open the userscript addon popup window and look for the "Set Table of Contents Title" setting.
  • Keyboard commands:
    • Press Esc to "hide" the TOC in the upper right corner.
    • Press g + t, within one second of each other, to toggle the TOC view.
    • Press g + r, within one second of each other, to reset the TOC position.
  • Click this link to install from GitHub; or, install from GreasyFork or OpenUserJS.
  • Then test it on this page.

Screenshot

github-toc

Change Log

Version 1.3.0 (2019-02-16)

  • Make compatible with GM4. Fixes issue #69.
  • Reduce minimum headers from 2 to 1.
  • Update GitHub icon.

Version 1.2.21 (2019-01-28)

  • Update mutation script.

Version 1.2.20 (2018-10-05)

  • Update mutation script.

Version 1.2.19 (2018-09-19)

Version 1.2.18 (2018-08-01)

  • When collapsed, add padding to header & align button.
  • Darken collapsed button.

Version 1.2.17 (2018-06-16)

  • Change class names to prevent addon conflicts. Fixes issue #48.

Version 1.2.16 (2018-05-17)

  • Update mutation script.

Version 1.2.15 (2018-05-10)

  • Update mutation script.

Version 1.2.14 (2018-04-16)

Version 1.2.13 (2018-04-09)

  • Update mutation script url.

Version 1.2.12 (2018-01-18)

  • Update assets.

Version 1.2.11 (2017-10-08)

  • Update mutation script url.

Version 1.2.10 (2017-08-22)

  • Update to use new header class.

Version 1.2.9 (2017-05-16)

  • Change license to MIT.

Version 1.2.8 (2017-04-21)

  • Update mutation url.

Version 1.2.5 - 1.2.7 (2017-04-13)

  • Switch to using mutations.js.

Version 1.2.4 (2017-04-04)

  • Include Gist pages.

Version 1.2.3 (2017-03-31)

  • Collapse arrow now correctly groups sub-headers.

Version 1.2.2 (2017-03-25)

  • Use pjax event & fix linting.
  • Add link to docs.

Version 1.2.1 (2016-12-28)

  • Clean up linting issues.

Version 1.2.0 (2016-07-29)

Version 1.1.2 (2016-07-05)

  • Arrows will again collapse content.

Version 1.1.1 (2016-06-06)

  • Only clicking on an arrow will toggle the sub-group.

Version 1.1.0 (2016-06-06)

  • Shift + Click now toggles all same level items.
  • Don't show TOC when less than 3 listings.
  • Code cleanup.

Version 1.0.1 (2016-05-25)

  • Prevent JS errors on pages with no ".header".

Version 1.0.0 (2016-03-28)

  • Initial commit
Clone this wiki locally