man html toc

add toc sidebar for man2html page

  1. // ==UserScript==
  2. // @name man html toc
  3. // @namespace http://www.yurenchen.com/
  4. // @version 0.1
  5. // @description add toc sidebar for man2html page
  6. // @author yurenchen
  7. // @match https://community.openvpn.net/openvpn/wiki/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. //make toc sidebox
  15. var box_st='<div id="toc" style="position: fixed; right: -1px; top: -38px; background: white; padding: 19px; border: 1px solid #cecece; width: 431px; height: 100%;">';
  16. var box_ed='</div>';
  17. var html=wikipage.innerHTML;
  18. html=html.replace(/<hr[ /]*>\s*(<a name="index">[\s\S]*?<hr[ /]*>)/, '<hr>'+box_st+'$1'+box_ed);
  19. wikipage.innerHTML=html;
  20.  
  21. //adjust body position
  22. document.body.style.cssText='margin: 0px; padding: 0; width: initial; right: 474px; position: absolute;';
  23.  
  24. })();