Skip to content

Instantly share code, notes, and snippets.

@imjared
Last active September 6, 2022 20:11
Show Gist options
  • Save imjared/81c71f0dd353e11c582b5d118282b51a to your computer and use it in GitHub Desktop.
Save imjared/81c71f0dd353e11c582b5d118282b51a to your computer and use it in GitHub Desktop.
Notion table of contents bookmarklet
/**
* Note that this only works for pages that have a table of contents. It won't magically make one for you. V2, anyone?
*
* Usage:
* 1. In Chrome, right click your bookmarks menu and click "Add page" in the popup menu
* 2. For "Name", pick something like "Notion TOC Formatter"
* 3. For "URL", paste the code below and click Save
* 4. On a Notion page that has a table of contents, click the bookmarklet and ✨✨
*
* This will only work for the page you're on. As soon as you navigate, ya gotta click again.
*
* Note: This has worked reliably for me for a few years but could stop working at any time.
*/
javascript:((el = document.createElement("style")).id = "notion-tag"),
(el.innerText =
".notion-table_of_contents-block>div { overflow: scroll; overflow-x: hidden; background-color: white; position: fixed !important; top: 4rem; left: 1rem; width: 250px !important; padding: 1rem; border: 1px solid #eee; border-radius: 5px; max-height: calc(100vh - 5rem) !important; overflow: scroll; z-index: 10000;} .notion-table_of_contents-block>div *:style { font-size: 12px !important; }"),
document.body.append(el);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment