Skip to content

Instantly share code, notes, and snippets.

@deniskrumko
Created April 12, 2022 12:05
Show Gist options
  • Save deniskrumko/d802ca53daf3e7e6ff564fe51704e6cb to your computer and use it in GitHub Desktop.
Save deniskrumko/d802ca53daf3e7e6ff564fe51704e6cb to your computer and use it in GitHub Desktop.
Bitbucket Review Tampermonkey
// ==UserScript==
// @name Bitbucket Review
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Highlight and fold replies
// @author You
// @match https://stash.dev.itc.homecredit.ru/*/pull-requests/*
// @require http://code.jquery.com/jquery-3.4.1.min.js
// @run-at document-body
// @grant none
// ==/UserScript==
$(document).ready(function () {
function toggleReplies (e) {
// Fold/unfold replies in clicked comment
let root_comment = $(this).closest('.comment-with-replies');
root_comment.find('.replies').toggle();
}
function initialHideReplies () {
// Hide all replies and add buttons
$('.comment-with-replies.is-root-comment').each(function(index) {
let all_replies = $(this).find('.replies');
if (all_replies.length != 0) {
let comment_actions = $(this).find('.comment-actions').first();
comment_actions.append('<button style="margin-left: 10px;" class="replyButton comment-add-reaction">Показать ответы (' + all_replies.length + ')</button>');
all_replies.hide();
}
let marked = $(this).find('.reaction-content.white_check_mark');
if (marked.length != 0) {
$(this).css('background', '#BCF49B');
$(this).parent().css('border-color', '#B1E491');
} else {
$(this).parent().css('border-color', '#F16372');
}
});
$('.replyButton').on('click', toggleReplies);
}
function delayedInitialHideReplies () {
// delay function before content is loaded
setTimeout(initialHideReplies, 900);
}
// page open
delayedInitialHideReplies();
// tab click
$('.menu-item').on('click', delayedInitialHideReplies);
});
@deniskrumko
Copy link
Author

Все треды с комментами сворачиваются по умолчанию

Отмечает зеленым цветом "зарезолвленные" комменты
image

А остальные выделяет красным цветом рамки
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment