GitHub squash reminder

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

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

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