Widen Code Container and Hide Whitespace (GitHub)

Adds buttons to allow you to widen the container when viewing files and hide whitespace when viewing pull request diffs

当前为 2016-01-15 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Widen Code Container and Hide Whitespace (GitHub)
  3. // @namespace chriskim06
  4. // @description Adds buttons to allow you to widen the container when viewing files and hide whitespace when viewing pull request diffs
  5. // @include https://github.com/*
  6. // @require http://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js
  7. // @version 1.2.9
  8. // @grant none
  9. // @locale en
  10. // ==/UserScript==
  11.  
  12. this.$ = this.jQuery = jQuery.noConflict(true);
  13.  
  14. $(function() {
  15. if ($('#user-links').length) {
  16. $('#user-links').prepend('<li class="header-nav-item"><a href="javascript:void(0)" id="hide-whitespace-button" class="header-nav-link tooltipped tooltipped-s" aria-label="Hide whitespace" onclick="return false;"><span class="octicon octicon-circle-slash"></span></a></li>');
  17. $('#user-links').prepend('<li class="header-nav-item"><a href="javascript:void(0)" id="code-widen-button" class="header-nav-link tooltipped tooltipped-s" aria-label="Widen code container" onclick="return false;"><span class="octicon octicon-mirror "></span></a></li>');
  18. $('#code-widen-button').click(function(e) {
  19. e.preventDefault();
  20. if ($('.repository-content > .file').length || $('.repository-content').find('#files').length) {
  21. if ($('#diff > #toc > .btn-group > a:nth-child(2)').hasClass('selected')) {
  22. return;
  23. }
  24. var container = $('.container.new-discussion-timeline.experiment-repo-nav');
  25. var expanded = $(window).width() * 0.75;
  26. if (container.width() < expanded) {
  27. container.css('width', expanded + 'px');
  28. } else {
  29. container.css('width', '980px');
  30. }
  31. }
  32. $(this).blur();
  33. });
  34. $('#hide-whitespace-button').click(function(e) {
  35. e.preventDefault();
  36. var url = window.location.href;
  37. if ($('#diff > #files').length && !url.endsWith('?w=1')) {
  38. window.location.href = url + '?w=1';
  39. }
  40. $(this).blur();
  41. });
  42. }
  43. });

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址