Skip to content

Instantly share code, notes, and snippets.

@Lunaphied
Last active November 17, 2021 12:55
Show Gist options
  • Select an option

  • Save Lunaphied/8df9f133b3a812552b501db3b9d3ff9d to your computer and use it in GitHub Desktop.

Select an option

Save Lunaphied/8df9f133b3a812552b501db3b9d3ff9d to your computer and use it in GitHub Desktop.
Fix Nix Help
// ==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