您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Disable merge buttons for the base branches you wish to restrict.
- // ==UserScript==
- // @name github merge blocker
- // @namespace maoanran@gmail.com
- // @version 2024-05-10
- // @description Disable merge buttons for the base branches you wish to restrict.
- // @author maoanran
- // @match https://github.com/*
- // @grant none
- // @license MIT
- // ==/UserScript==
- (function() {
- 'use strict';
- let RESTRICTED_BASE_BRANCHES = ['main', 'master'] // Change the array to add more branches to prevent merging
- function runWhenReady(readySelector, callback) {
- var numAttempts = 0;
- var tryNow = function() {
- var elem = document.querySelector(readySelector);
- if (elem) {
- callback(elem);
- } else {
- numAttempts++;
- if (numAttempts >= 10) {
- console.warn('Giving up after 10 attempts. Could not find: ' + readySelector);
- } else {
- setTimeout(tryNow, 250 * Math.pow(1.1, numAttempts));
- }
- }
- };
- tryNow();
- }
- let baseBranch = document.querySelectorAll('.commit-ref.base-ref span');
- if (baseBranch.length == 1 && RESTRICTED_BASE_BRANCHES.includes(baseBranch[0].innerText)) {
- runWhenReady('.BtnGroup button', function() {
- document.querySelectorAll('.BtnGroup button').forEach(button => button.setAttribute("disabled","disabled"));
- })
- }
- })();
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址