Better Jira

更好的Jira,以下优化:1、Jira创建Branch时中文自动翻译成英文;2、创建Branch时如果是Improvment时,将分支类型改成Feature。

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

You will need to install an extension such as Tampermonkey to install this script.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

You will need to install an extension such as Tampermonkey to install this script.

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name         Better Jira
// @namespace    https://www.ruijc.com/
// @version      1.0.2
// @description  更好的Jira,以下优化:1、Jira创建Branch时中文自动翻译成英文;2、创建Branch时如果是Improvment时,将分支类型改成Feature。
// @author       Storezhang
// @match        https://*/plugins/servlet/create-branch*
// @match        http://*/plugins/servlet/create-branch*
// @grant        GM_xmlhttpRequest
// ==/UserScript==

(function() {
    'use strict';

    var url = document.URL + '&';
    var issueKey = url.match (/[\?\&]issueKey=([^\&\#]+)[\&\#]/i) [1];
    var issueSummary = url.match (/[\?\&]issueSummary=([^\&\#]+)[\&\#]/i)[1];
    var issueType = url.match (/[\?\&]issueType=([^\&\#]+)[\&\#]/i)[1];

    // 如果为Improvement时,将分支类型改成Feature
    if ("Improvement" === issueType) {
        $("#branch-type").val("feature");
    }

    // 中文自动翻译成英文
    GM_xmlhttpRequest({
        method: "GET",
        url: 'https://fanyi.youdao.com/translate?&doctype=json&type=ZH_CN2EN&i=' + issueSummary,
        onload: function(rsp) {
            var data = JSON.parse(rsp.responseText);
            var tanslatedArray = data.translateResult[0][0].tgt.split(/\s+/);
            var translated = "";
            tanslatedArray.forEach(function (word){
                translated += word.toLowerCase() + "-";
            });
            $("#branch-name").val (issueKey + "-" + translated.slice(0, -1));
        }
    });
})();