Kanka Automatic Table of Contents

Automatically adds a table of contents to Kanka entity pages under the Pins sidebar.

目前为 2024-09-29 提交的版本。查看 最新版本

作者
Salvatos
评分
0 0 0
版本
11
创建于
2021-07-15
更新于
2024-09-29
大小
7.7 KB
许可证
暂无
适用于

Automatically adds a Table of Contents block under the right-hand History sidebar of all entities on Kanka. You can customize its appearance using campaign CSS, but keep in mind that it is only visible on browsers where this script is installed. It should match the appearance of other sidebar blocks out of the box.

When clicking a link to a collapsed post, the post will automatically expand so you are scrolled to the correct position.

Back to top

The script can also add links to scroll back to the table of contents after every heading (excluding entry/post box headings), but this is turned off by default. To activate this feature, locate the following line under the /* Preferences */ section and add the desired text inside the quotation marks:

const addTopLink = "";
const addTopLink = "toc";

Note that you will need to reimplement this change each time you update the script.

Note: This script will not conflict with Kanka’s own tables of contents ({table-of-contents}). You can use it to supplement the "native" tables of contents, and create back-to-top links if enabled.


If my scripts are making your life easier, please consider tipping via Ko-fi (no account needed):

Support me on Ko-fi.com