GitHub - Make the site better (and wider)

Makes github full width in a few views, and makes PR diffs easier to browse

As of 2015-08-18. See the latest version.

  1. // ==UserScript==
  2. // @name GitHub - Make the site better (and wider)
  3. // @namespace http://adamwknox.com
  4. // @version 0.5
  5. // @description Makes github full width in a few views, and makes PR diffs easier to browse
  6. // @author DrKnoxy
  7. // @include https://github.com/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. var styleTemplate = [
  12. '<style id="knoxyTemplate">',
  13. // General
  14. '.container {',
  15. 'width: 100%;',
  16. 'padding-left: 15px;',
  17. 'padding-right: 15px;',
  18. '}',
  19. '.repository-with-sidebar .repository-content {',
  20. 'margin-right: 60px;',
  21. 'float: none;',
  22. 'width: auto;',
  23. '}',
  24. // PR / Compare
  25. '.blob-wrapper { display:none; }',
  26. '.file-header { max-height: 42px; }',
  27. '.subnav { max-height: 34px; }',
  28. '.table-list-header { max-height: 44px; }',
  29. // wiki pages
  30. '.wiki-wrapper #wiki-content {clear: none;}',
  31. '</style>',
  32. ].join('');
  33.  
  34. function workStyleTemplate(url) {
  35. var pattern = /https:\/\/github.com\/.*\/.*\/(pull|compare|wiki).*/g;
  36. var reg = new RegExp(pattern);
  37. if ( url.match(reg) ) {
  38. $('head').append(styleTemplate);
  39. } else {
  40. $('head').find('#knoxyTemplate').remove();
  41. }
  42. }
  43.  
  44. $(function(){
  45.  
  46. $(document).on('click', '.file-header', function(e){
  47. $(this).next('.blob-wrapper').toggle();
  48. });
  49.  
  50. // Update stylesheet on page load
  51. workStyleTemplate(window.location.href);
  52.  
  53. // When pjax finishes, update our stylesheet
  54. $(document).on('pjax:complete pjax:popstate', function(e){
  55. var url = e.delegateTarget.URL;
  56. workStyleTemplate(url);
  57. });
  58. });