Greasy Fork is available in English.

iCode Helper

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

Stan na 07-09-2018. Zobacz najnowsza wersja.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

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


})();