Greasy Fork is available in English.

Collapsable Diffs (GitHub)

Adds a button that allows you to collapse an individual diff in a pull request

Pada tanggal 19 Desember 2015. Lihat %(latest_version_link).

  1. // ==UserScript==
  2. // @name Collapsable Diffs (GitHub)
  3. // @namespace chriskim06
  4. // @description Adds a button that allows you to collapse an individual diff in a pull request
  5. // @include https://github.com/*/*/pull/*
  6. // @require http://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js
  7. // @version 1.2
  8. // @grant none
  9. // @locale en
  10. // ==/UserScript==
  11.  
  12. this.$ = this.jQuery = jQuery.noConflict(true);
  13.  
  14. $(function() {
  15. if ($('#diff').length) {
  16. var expanded = '<a class="octicon-btn custom-collapsable" href="javascript:void(0)" onclick="return false;"><span class="octicon octicon-triangle-down "></span></a>';
  17. $('#diff').find('#files > div[id^="diff-"]').each(function() {
  18. $(this).find('.file-info').prepend(expanded);
  19. var area = $(this).children('.data.highlight.blob-wrapper');
  20. $(this).find('.octicon-btn.custom-collapsable').on('click', function() {
  21. var icon = $(this).children(':first');
  22. if (icon.hasClass('octicon-triangle-down')) {
  23. icon.attr('class', 'octicon octicon-triangle-right');
  24. } else {
  25. icon.attr('class', 'octicon octicon-triangle-down');
  26. }
  27. area.slideToggle('fast');
  28. });
  29. });
  30. }
  31. });