// ==UserScript== // @name GitHub - Make the site better (and wider) // @namespace http://adamwknox.com // @version 0.3 // @description Makes github full width in a few views, and makes PR diffs easier to browse // @author DrKnoxy // @include https://github.com/* // @grant none // @downloadURL none // ==/UserScript== var styleTemplate = [ '', ].join(''); function workStyleTemplate(url) { var pattern = /https:\/\/github.com\/.*\/.*\/(pull|compare|wiki).*/g; var reg = new RegExp(pattern); if ( url.match(reg) ) { $('head').append(styleTemplate); } else { $('head').find('#knoxyTemplate').remove(); } } $(function(){ $(document).on('click', '.file-header', function(e){ $(this).next('.blob-wrapper').toggle(); }); // Update stylesheet on page load workStyleTemplate(window.location.href); // When pjax finishes, update our stylesheet $(document).on('pjax:success', function(e){ var url = e.delegateTarget.URL; workStyleTemplate(url); }); });