Skip to content

Instantly share code, notes, and snippets.

@CodeBrauer
Last active June 20, 2023 14:33
Show Gist options
  • Save CodeBrauer/6a290a9bb5f9f362c4fe1ba14345557b to your computer and use it in GitHub Desktop.
Save CodeBrauer/6a290a9bb5f9f362c4fe1ba14345557b to your computer and use it in GitHub Desktop.
GitLab Userscript - Adds the count of approvals to the list view of merge requests. If more than 2, MR is
// ==UserScript==
// @name GitLab MR approval count
// @namespace http://tampermonkey.net/
// @version 0.6
// @description GitLab show merge request approvals count and own status in list view
// @author CodeBrauer
// @match https://gitlab.com/*/-/merge_requests*
// @run-at document-idle
// @icon https://www.google.com/s2/favicons?sz=64&domain=gitlab.com
// @grant none
// ==/UserScript==
(function() {
'use strict';
document.querySelectorAll('.issuable-meta [title*=approv]').forEach(function(row) {
let approvals = row.getAttribute('title');
let approvalsCount = approvals.match(/\d+/)[0];
row.innerHTML = row.innerHTML.replace("Approved", row.getAttribute('title'));
if (approvalsCount < 2) {
row.classList.remove("text-success");
row.classList.add("text-warning");
} else if (approvalsCount >= 2) {
row.closest('li.merge-request').style.backgroundColor = '#007f0040';
}
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment