Created
October 14, 2022 09:25
-
-
Save hogashi/c239868c00cb412626b0378e914a53d7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:(() => { | |
const toc = [...document.querySelector('#readme').querySelectorAll('h1, h2, h3, h4, h5, h6')].map(h => | |
`${ | |
' '.repeat( | |
/* "H1" などから "1" を取ってきて 1 引いて行頭の空白の個数に使う */ | |
parseInt(h.tagName.match(/[0-9]+/)[0], 10) - 1 | |
) | |
}- [${h.innerText}](${h.querySelector('a').href})` | |
).join('\n'); | |
console.log(toc); | |
navigator.clipboard.writeText(toc); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment