-
-
Notifications
You must be signed in to change notification settings - Fork 165
GitHub table of contents
Rob Garrison edited this page Nov 8, 2022
·
58 revisions
A userscript that adds a table of contents to both readme and wiki pages.
- NOTE: When updating to v2.0+, you may have to reset the popup (g + r) as the positioning method has changed.
- 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.
- Move (drag-and-drop): 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.
-
Toggle Window
- Click on the header icon to toggle the window between the upper right corner and its last position.
- Double-click on the header text to toggle the window.
- Or, use the keyboard shortcut to toggle the view.
-
Toggle Entries
- Each anchor within the rendered markdown will be included in the TOC window.
- 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.
- Some anchor link text may be truncated, hover over the link to see the full title.
- 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.
- Properly detect Gist markdown files
- Update dependencies.
- Add missing
GM.registerMenuCommand
. Thanks @darkred!
- Update mutation script.
- Update utils script.
- Make container resizable. Closes issue #132.
- Code cleanup
- Increase collapse hit box & fix redundant binding
- Fix logged out menu
- Update mutation script.
- Don't include sidebar headers. Closes issue #124.
- Double-click header to toggle. Closes issue #118.
- Hide on header double-click (fix).
- Fix Google translate broken links. Closes issue #117.
- Fix title update DOM target. See issue #102.
- Position popup based on window center:
- This may cause some issues with previously saved positions, thus the major version bump.
- Make sure to reset the position using the hot keys g + r (unless you remapped the hotkeys).
- Position is maintained even if the window is resized, except for narrower screens.
- Closes issue #102.
- When the popup is reset, it hugs the right side of the screen, even on resize.
- Update TOC position due to GitHub design update. See PR #80; thanks @ottnorml!
- Fix header alignment.
- Code Cleanup.
- Fix clickable toggle area.
- Update header selector.
- Make compatible with GM4. Fixes issue #69.
- Reduce minimum headers from 2 to 1.
- Update GitHub icon.
- Update mutation script.
- Update mutation script.
- When collapsed, add padding to header & align button.
- Darken collapsed button.
- Change class names to prevent addon conflicts. Fixes issue #48.
- Update mutation script.
- Update mutation script.
- Update mutation script url.
- Update assets.
- Update mutation script url.
- Update to use new header class.
- Change license to MIT.
- Update mutation url.
- Switch to using mutations.js.
- Include Gist pages.
- Collapse arrow now correctly groups sub-headers.
- Use pjax event & fix linting.
- Add link to docs.
- Clean up linting issues.
- Add z-index to icon (fixed header style) & convert to ES6
- Arrows will again collapse content.
- Only clicking on an arrow will toggle the sub-group.
- Shift + Click now toggles all same level items.
- Don't show TOC when less than 3 listings.
- Code cleanup.
- Prevent JS errors on pages with no ".header".
- Initial commit