Gitlab Copy Commit Link Instead of SHA

This is a Tampermonkey user script that enhances the Gitlab user interface by adding a button that copies the commit link to the clipboard instead of just the commit SHA.

Από την 05/04/2023. Δείτε την τελευταία έκδοση.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name         Gitlab Copy Commit Link Instead of SHA
// @license MIT
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  This is a Tampermonkey user script that enhances the Gitlab user interface by adding a button that copies the commit link to the clipboard instead of just the commit SHA.
// @author       You
// @match        https://gitlab.com/*/commits/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=gitlab.com
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    document.querySelectorAll('li.commit').forEach(function (commit) {
        let commitLink = commit.querySelector('a.item-title').getAttribute('href');
        let avatarCell = commit.querySelector('div.avatar-cell');
        // add a button to copy the commit link
        let copyBtn = commit.querySelector('button[aria-label="Copy commit SHA"]');
        // duplicate the button
        let copyBtnClone = copyBtn.cloneNode(true);
        // add the clone to the avatar cell
        avatarCell.appendChild(copyBtnClone);
        // apply     margin-right: 0.8rem; margin-top: 0.2rem;
        copyBtnClone.style.marginRight = '0.8rem';
        copyBtnClone.style.marginTop = '0.25rem';
        let commitUrl = window.location.origin + commitLink;
        copyBtnClone.setAttribute('data-clipboard-text', commitUrl);
    });
})();