Github Pull Request Rebase Checker

Checks each pull requests and see if they need a rebase.

  1. // ==UserScript==
  2. // @name Github Pull Request Rebase Checker
  3. // @version 0.1
  4. // @description Checks each pull requests and see if they need a rebase.
  5. // @author kjung
  6. // @match https://github.com/pulls
  7. // @match https://github.com/*/*/pulls
  8. // @match https://github.com/*/*/issues*
  9. // @require https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js
  10. // @grant none
  11. // @namespace https://greasyfork.org/en/users/6863
  12. // ==/UserScript==
  13.  
  14. (function() {
  15. 'use strict';
  16. var needsRebaseColour = '255, 0, 0, 0.3'; // RGB
  17.  
  18. var pullRequestsThatNeedsRebase = [];
  19. var pullRequests = $('ul.js-active-navigation-container li');
  20.  
  21. $.when.apply(null, $.map(pullRequests, function (pr) {
  22. var pullReuqest = $(pr);
  23. var pullRequestUrl = pullReuqest.find('.js-navigation-open').attr('href');
  24.  
  25. return $.get(pullRequestUrl, function (response) {
  26. var pullRequestNeedsRebase = $(response).find('.completeness-indicator-problem').length;
  27. if (pullRequestNeedsRebase) {
  28. pullRequestsThatNeedsRebase.push(pullReuqest);
  29. }
  30. });
  31. })).done(function () {
  32. pullRequestsThatNeedsRebase.forEach(function(pr) {
  33. pr.css('cssText', 'background-color: rgba('+needsRebaseColour+') !important;');
  34. });
  35. });
  36. })();