iCode Helper

一键复制iCafe单信息,形成Git Commit Msg

07.09.2018 itibariyledir. En son verisyonu görün.

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         iCode Helper
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  一键复制iCafe单信息,形成Git Commit Msg
// @author       [email protected]
// @match        http://newicafe.baidu.com/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Your code here...
document.addEventListener(
    'click',
    function(e) {
        // console.log(e.target);
        if (e.target) {
            if (e.target.matches('.titleValue.showIssueView.value')) {
                const item = event.target;
                const fullTitle = item.getAttribute('title');
                const matchedScope = fullTitle
                    .match(/【(.*?)】/g)
                    .map(t => t.match(/【(.*)】/)[1]);
                const issueId = item.getAttribute('data-issueid');
                const scope = `(${matchedScope.join(',')})`;
                const title = fullTitle.match(/【.*】(.*)/)[1];
                const result = `fix:${scope}:[${issueId}] ${title}`;
                console.log(result);
                const el = document.createElement('textarea');
                el.value = result;
                document.body.appendChild(el);
                el.select();
                document.execCommand('copy');
                document.body.removeChild(el);
            }
        }
    },
    true
);


})();