Skip to content

Instantly share code, notes, and snippets.

@ondrajz
Created November 28, 2017 22:12
Show Gist options
  • Save ondrajz/06def9312417ba72cedd8cb23663507b to your computer and use it in GitHub Desktop.
Save ondrajz/06def9312417ba72cedd8cb23663507b to your computer and use it in GitHub Desktop.
Github HideFiles
// ==UserScript==
// @name Github HideFiles
// @namespace http://tampermonkey.net/
// @version 0.1
// @description hide files
// @author TrueFurby
// @match https://github.com/*
// @grant none
// @require http://code.jquery.com/jquery-latest.js
// ==/UserScript==
(function() {
'use strict';
var fileTable = $('.file-wrap>table>tbody:last');
var count = fileTable.children().length;
//background: linear-gradient(to bottom, #ebf1f6 0%,#abd3ee 50%,#89c3eb 51%,#d5ebfb 100%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
var showBtn = $('<button class="btn" style="background: linear-gradient(to bottom, #3f8faf 0%,#153355 100%) !important;">Hide files</button>');
$(showBtn).click(function(){
fileTable.toggle();
if (fileTable.css('display') == 'none') {
$(showBtn).text('Show files');
$(showBtn).removeClass('btn-sm');
}else{
$(showBtn).text('Hide files');
$(showBtn).addClass('btn-sm');
}
});
fileTable.after(function(){
return '<tfoot class="boxed-group"><tr style="vertical-align:center;"><td style="padding: 0;margin:0;" colspan="4"><span class="text-gray" style="padding:5px 5px;">'+ count +' files</span></td></tr></tfoot>';
});
$('.file-wrap>table>tfoot>tr>td>span').before(showBtn);
if ($('#readme').length && count > 10) {
showBtn.click();
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment