'use strict';

(function($){
  var changeMergeButtonState = function() {
    var $container = $('#js-repo-pjax-container');
    var issueTitle = $container.find('.js-issue-title').text();
    var $buttonMerge = $container.find('.merge-message button.merge-branch-action');
    var disabled = false;
    var buttonHtml = '';

    chrome.runtime.sendMessage({from: 'content', subject: 'localStorage'}, function(response){
      if (!response) { return; }

      var localStorage = response.localStorage;
      if ($('.merge-message .octicon-git-branch-delete').length > 0) {
        if (localStorage && localStorage.protectedBranch) {
          disabled = (new RegExp(localStorage.protectedBranch)).test($('.merge-message .css-truncate-target').text());
        }
        buttonHtml = '<span class="octicon octicon-git-branch-delete"></span> ' + (disabled ? 'Protected branch' : 'Delete branch');
      } else {
        var isWipTitle = /(\[wip\]|\[do\s*not\s*merge\])/i.test(issueTitle);
        var isWipTaksList = $container.find('.timeline-comment:first input[type="checkbox"]:not(:checked)').length > 0;
        disabled = (isWipTitle || isWipTaksList);
        buttonHtml = '<span class="octicon octicon-git-merge"></span> ' + (disabled ? 'WIP! You can\'t merge!' : 'Merge pull request');
      }

      $buttonMerge.attr('disabled', disabled);
      $buttonMerge.html(buttonHtml);
    });
  };

  changeMergeButtonState();
  setInterval(changeMergeButtonState, 1000);
})(jQuery);

@@ -1100,16 +1100,248 @@
 th %3E 0;%0A
+        var isSquashCommits = false;%0A        $container.find('#commits_bucket .commit .commit-title').each(function(i, elem)%7B%0A          isSquashCommits = isSquashCommits %7C%7C $(elem).text().match(/%5E%5Cs*(squash%7Cfixup)!%5Cs/);%0A        %7D);%0A
         
@@ -1379,16 +1379,35 @@
 TaksList
+ %7C%7C isSquashCommits
 );%0A     

Check un-squashed commits