Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vitaliidasaev/6eb76e646306b4e1cef14cf27165b773 to your computer and use it in GitHub Desktop.
Save vitaliidasaev/6eb76e646306b4e1cef14cf27165b773 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name GitHub PRs collapse all feature
// @namespace http://tampermonkey.net/
// @version 1.2.3
// @description try to take over the world!
// @author You
// @include https://github.com/LykkeCity/*/pull/*
// @grant none
// @require http://code.jquery.com/jquery-3.3.1.min.js#sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8
// @downloadURL http://bit.ly/pr-collapse
// ==/UserScript==
(function() {
'use strict';
const buttonSelector = '.js-details-container > .file-header > .file-actions > button';
const buttonSelectorNotOpen = '.js-details-container:not(.open) > .file-header > .file-actions > button';
$(function() {
$('body').append(
`<style>
.btn-collapse-all {
position: fixed;
bottom: 20px;
right: 20px;
background: transparent;
border: 1px grey solid;
border-radius: 20px;
color: #6a737d;
opacity: 0.5;
transition: background .5s;
padding: 2px 10px;
}
.btn-collapse-all:hover {
opacity: 1;
color: #fff;
background: #0366d6;
border-color: #0366d6;
}
${buttonSelector} {
width: 150px;
border: 1px lightgray solid;
border-radius: 20px;
}
</style>
<button class="btn-collapse-all tooltipped tooltipped-w" aria-label="Collapse all opened files">collapse all</button>`
);
$('.btn-collapse-all').on('click', function() {
customBtnCollapseAll();
});
});
function customBtnCollapseAll() {
const buttons = $(buttonSelectorNotOpen);
// .js-details-container.open > .file-header > .file-actions > button
console.log('collapseAll length', buttons.length);
buttons.trigger('click');
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment