PHP Documentation Columnify & Other Improvements

View the PHP document front page in a multi-column layout and some other small improvements.

  1. // ==UserScript==
  2. // @name PHP Documentation Columnify & Other Improvements
  3. // @version 2.0
  4. // @description View the PHP document front page in a multi-column layout and some other small improvements.
  5. // @author Shakil Shahadat
  6. // @match https://www.php.net/manual/*/
  7. // @match https://www.php.net/manual/*/index.php
  8. // @namespace https://greasyfork.org/en/users/6404-shakil
  9. // ==/UserScript==
  10.  
  11. 'use strict';
  12.  
  13. // Multi-column layout
  14. document.querySelector( '.chunklist' ).style.WebkitColumnCount = 5;
  15. document.querySelector( '.chunklist' ).style.MozColumnCount = 5;
  16. document.querySelector( '.chunklist' ).style.ColumnCount = 5;
  17.  
  18. document.querySelector( '.chunklist' ).style.WebkitColumnRuleStyle = 'dotted';
  19. document.querySelector( '.chunklist' ).style.MozColumnRuleStyle = 'dotted';
  20. document.querySelector( '.chunklist' ).style.ColumnRuleStyle = 'dotted';
  21.  
  22. document.querySelector( '.chunklist' ).style.WebkitColumnRuleWidth = '1px';
  23. document.querySelector( '.chunklist' ).style.MozColumnRuleWidth = '1px';
  24. document.querySelector( '.chunklist' ).style.ColumnRuleWidth = '1px';
  25.  
  26. // Hide unnecessary segments
  27. for ( let e of [ '.headsup', '.page-tools', '.info', '.contribute', '#usernotes', 'footer' ] )
  28. {
  29. document.querySelector( e ).style.display = 'none';
  30. }
  31.  
  32. // Keep the header where it should be
  33. document.querySelector( 'nav' ).style.position = 'absolute';
  34.  
  35. // Widen the layout
  36. document.querySelector( '#layout' ).style.width = '100%';
  37.  
  38. // Add target="_blank" to all anchor tags, v 2.1
  39. for ( let x of document.links ) x.setAttribute( 'target', '_blank' );