GitHub squash reminder

Replaces the button if your current selected merge strategy is a merge commit

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

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

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

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.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name        GitHub squash reminder
// @include     https://github.com/*
// @exclude     none
// @version     4
// @grant    		none
// @description   	Replaces the button if your current selected merge strategy is a merge commit
// @author      VasilisThePikachu
// @namespace    https://pikachu.systems
// @license WTFPL
// ==/UserScript==

function modifyMergeButton() {
    document.querySelectorAll('button.prc-Button-ButtonBase-c50BI').forEach(button => {
        if (button.textContent.trim() === "Confirm merge") {
            button.textContent = '⚠️ MERGE COMMIT SELECTED - Did you mean to squash? ⚠️';
            button.style.backgroundImage = 'linear-gradient(-180deg, #e02626 0%, #9F2D27 90%)';
            button.style.color = 'white';
            button.style.fontWeight = 'bold';
        }
    });
}

function observeMergeButton() {
    const observer = new MutationObserver(modifyMergeButton);
    observer.observe(document.body, { childList: true, subtree: true });

    // Run immediately in case the button is already there
    modifyMergeButton();
}

// Start the observer
observeMergeButton();