Last active
November 17, 2021 12:55
-
-
Save Lunaphied/8df9f133b3a812552b501db3b9d3ff9d to your computer and use it in GitHub Desktop.
Fix Nix Help
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
| // ==UserScript== | |
| // @name Fix Nix Help - nixos.org | |
| // @namespace Violentmonkey Scripts | |
| // @match https://nixos.org/manual/* | |
| // @grant none | |
| // @version 1.0 | |
| // @author modwizcode | |
| // @description Patches the Nix documention to actually have entries in the TOC for subcommands | |
| // @require https://cdn.jsdelivr.net/npm/@violentmonkey/dom@1 | |
| // ==/UserScript== | |
| const node = document.querySelector('.active'); | |
| const targets = document.querySelectorAll('a.header[href^="#operation"]'); | |
| const list = document.createElement('ol'); | |
| list.classList.add('section'); | |
| targets.forEach(target => { | |
| const listEntry = document.createElement('li'); | |
| listEntry.classList.add('chapter-item'); | |
| listEntry.classList.add('expanded'); | |
| const link = document.createElement('a'); | |
| link.textContent = target.textContent; | |
| link.href = target.href; | |
| listEntry.append(link); | |
| list.append(listEntry); | |
| }); | |
| node.parentElement.after(list); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment