LinearB metrics comparison

Add metrics WW is striving for

当前为 2022-06-16 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         LinearB metrics comparison
// @author       Rolandas Valantinas
// @description  Add metrics WW is striving for
// @include      *app.linearb.io/performance*
// @namespace    https://greasyfork.org/users/157178
// @require      https://code.jquery.com/jquery-3.2.1.min.js
// @supportURL   https://github.com/rolandas-valantinas/gists/issues
// @version      1.5
// ==/UserScript==

(function () {
    var metricsButton = `<input type="button" id="add-ww-metrics" value="Add WW Metrics">`;
    var intervalButton = setInterval(addButton, 2000);
    var attempts = 0;

    function appendData(title, value) {
        $("p:contains('"+title+"')").first().parent().parent().find("p").eq(1).append(value);
    };

    function addMetrics() {
        console.log('add addMetrics');

        appendData('CODING TIME', ' / <24h');
        appendData('PICKUP TIME', ' / <12h');
        appendData('REVIEW TIME', ' / <4h');
        appendData('PRS OPENED', ' / >2 per day');
        appendData('PR SIZE', ' / <500');
        appendData('REVIEW DEPTH', ' / 2-4');
        appendData('NEW CODE', ' / >70%');
        appendData('REFACTOR', ' / <25%');
        appendData('REWORK', ' / <5%');

        appendData('CYCLE TIME', ' / <2 days');
        appendData('DEPLOY FREQUENCY', ' / >1 per day');
        appendData('DEPLOY TIME', ' / <6h');
        appendData('MTTR', ' / <4h');
    }


    function addButton() {
        console.log('add button');
        attempts++;
        var toolbar = $('div.MuiInputBase-root');

        if (toolbar.length > 0) {
            toolbar.parent().parent().append(metricsButton);
            $('#add-ww-metrics').click(addMetrics);
            attempts = 10;
        }

        if (attempts > 5) {
            clearInterval(intervalButton);
        }
    }
})();