Skip to content

Instantly share code, notes, and snippets.

@svenwin
Created January 23, 2018 14:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save svenwin/f89d122680e452e6ab24ae27ded589e3 to your computer and use it in GitHub Desktop.
Save svenwin/f89d122680e452e6ab24ae27ded589e3 to your computer and use it in GitHub Desktop.
Bitbucket Reviews
// ==UserScript==
// @name Bitbucket Approver
// @namespace http://tampermonkey.net/
// @version 0.3.1
// @description Fades out already approved commits …
// @author Sven Winkler
// @include https://bitbucket.org/*
// @grant none
// @updateURL https://gist.githubusercontent.com/svenwin/f89d122680e452e6ab24ae27ded589e3/raw
// ==/UserScript==
(function() {
// OK button under comments
$("li.comment article ul.comment-actions li:last-of-type")
.before("<li><a href='#reply-ok' class='reply-ok'>OK</a></li>");
$(document).on("click", "li a.reply-ok", function(event) {
$(this).parents(".comment-actions").find("a.reply-link").click();
var newComment = $("ol.child-comments li.new-comment",
$(this).parents("li.comment").first());
$("textarea", newComment).val("Ok.");
$("button[type=submit]", newComment).click();
return false;
});
// Hightlight commit approval status
if ($('.commit-list .iterable-item').length === 0) { return; }
makeTransparent = function(elements) { elements.fadeTo("slow", 0.4); };
makeRed = function(elements) { elements.css({"background-color": "#fff5e6"}); };
makeGreen = function(elements) { elements.css({"background-color":"#e6ffe6"});};
work = function() {
var all = $('.commit-list .iterable-item');
var approved = all.has('.approval-link');
var commented = all.has('.comments-link');
var pending = commented.not(approved);
var fresh = all.not(approved).not(commented);
makeTransparent(approved);
makeRed(pending);
makeGreen(fresh);
};
$(work);
$(document).on("pjax:complete", work);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment