Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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