Greasy Fork镜像 还支持 简体中文。

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-23 提交的版本,檢視 最新版本

  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. // Add buttons in the header navbar
  17. $('#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>');
  18. $('#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>');
  19. // Toggle code container width on click
  20. $('#code-widen-button').click(function(e) {
  21. e.preventDefault();
  22. if ($('#files').length || $('.repository-content').find('.file').length) {
  23. if ($('#toc').find('.btn-group > a:nth-child(2)').hasClass('selected')) {
  24. return;
  25. }
  26. var container = $('.container.new-discussion-timeline.experiment-repo-nav');
  27. var expanded = $(window).width() * 0.9;
  28. if (container.width() < expanded) {
  29. container.css('width', expanded + 'px');
  30. } else {
  31. container.css('width', '980px');
  32. }
  33. }
  34. $(this).blur();
  35. });
  36. // Toggle page with ?w=1 appended to the url to show/hide whitespace
  37. $('#hide-whitespace-button').click(function(e) {
  38. e.preventDefault();
  39. var url = window.location.href;
  40. if ($('#files').length) {
  41. if (url.endsWith('?w=1')) {
  42. window.location.href = url.slice(0, -4);
  43. } else {
  44. window.location.href = url + '?w=1';
  45. }
  46. }
  47. $(this).blur();
  48. });
  49. // Reset container width on pull request pages if you leave the diff tab
  50. if ($('.tabnav-tab.js-pull-request-tab:last').hasClass('selected')) {
  51. $('.tabnav-tab.js-pull-request-tab:not(:last)').each(function() {
  52. $(this).click(function(e) {
  53. var container = $('.clearfix.js-issues-results.js-pull-request-tab-container');
  54. var expanded = $(window).width() * 0.9;
  55. if (container.width() >= expanded) {
  56. container.css('width', '980px');
  57. }
  58. });
  59. });
  60. }
  61. }
  62. });

QingJ © 2025

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