Better Jira

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

目前為 2019-05-13 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==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));
        }
    });
})();