Disable Squash and Merge on Mondays

Disable buttons with text "Squash and merge" on Mondays

当前为 2024-12-12 提交的版本,查看 最新版本

// ==UserScript==
// @name         Disable Squash and Merge on Mondays
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Disable buttons with text "Squash and merge" on Mondays
// @author       Your Name
// @match        *://*/*
// @grant        none
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    // Check if today is Monday
    const today = new Date();
    const isMonday = today.getDay() === 1;

    if (isMonday) {
        // Function to disable buttons
        const disableButtons = () => {
            const buttons = document.querySelectorAll('button');
            buttons.forEach(button => {
                if (button.textContent.trim() === 'Squash and merge' || button.textContent.trim() === 'Enable auto-merge (squash)') {
                    button.disabled = true;
                }
            });
        };

        const checkForButtonAndShowDialog = () => {
            const button = Array.from(document.querySelectorAll('button')).find(btn => btn.textContent.trim() === 'Disable auto-merge');

            if (button) {
                const userConfirmed = confirm('It is Monday and likely you should not be merging, do you want to disable auto-merge?');
                if (userConfirmed) {
                    button.click();
                }
            }
        };


        setInterval(checkForButtonAndShowDialog, 2000);
        setInterval(disableButtons, 2000);
    }
})();