GitHub Copilot - Unhide MiniMax Models

Injects MiniMax M2.5 models into GitHub Copilot model picker

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         GitHub Copilot - Unhide MiniMax Models
// @namespace    creos
// @version      1.3
// @description  Injects MiniMax M2.5 models into GitHub Copilot model picker
// @match        https://github.com/*
// @run-at       document-start
// @grant        none
// ==/UserScript==

(function () {
  'use strict';

  const script = document.createElement('script');
  script.textContent = `
(function () {
  const MINIMAX_MODELS = [
    {
      "id": "minimax-m2p5-fw",
      "name": "MiniMax M2.5",
      "object": "model",
      "vendor": "Fireworks",
      "version": "minimax-m2p5-fw",
      "preview": false,
      "model_picker_enabled": true,
      "model_picker_category": "powerful",
      "is_chat_default": false,
      "is_chat_fallback": false,
      "policy": { "state": "enabled", "terms": "" },
      "supported_endpoints": ["/chat/completions"],
      "capabilities": {
        "family": "minimax-m2p5-fw",
        "object": "model_capabilities",
        "type": "chat",
        "tokenizer": "o200k_base",
        "limits": {
          "max_context_window_tokens": 196608,
          "max_output_tokens": 32000,
          "max_prompt_tokens": 164000
        },
        "supports": {
          "streaming": true,
          "tool_calls": true,
          "parallel_tool_calls": true,
          "structured_outputs": true,
          "reasoning_effort": ["low", "medium", "high"]
        }
      },
      "billing": { "is_premium": false, "multiplier": 1 }
    },
    {
      "id": "minimax-m2p5-cb",
      "name": "MiniMax M2.5 (Fast)",
      "object": "model",
      "vendor": "Cerebras",
      "version": "minimax-m2p5-cb",
      "preview": false,
      "model_picker_enabled": true,
      "model_picker_category": "powerful",
      "is_chat_default": false,
      "is_chat_fallback": false,
      "policy": { "state": "enabled", "terms": "" },
      "supported_endpoints": ["/chat/completions"],
      "capabilities": {
        "family": "minimax-m2p5-cb",
        "object": "model_capabilities",
        "type": "chat",
        "tokenizer": "o200k_base",
        "limits": {
          "max_context_window_tokens": 196608,
          "max_output_tokens": 32000,
          "max_prompt_tokens": 164000
        },
        "supports": {
          "streaming": true,
          "tool_calls": true,
          "parallel_tool_calls": true,
          "structured_outputs": true,
          "reasoning_effort": ["low", "medium", "high"]
        }
      },
      "billing": { "is_premium": false, "multiplier": 1 }
    }
  ];

  function injectOrPatch(json) {
    const list = json?.data ?? (Array.isArray(json) ? json : null);
    if (!list) return null;

    // Patch existing MiniMax entries, or inject if missing
    const existingIds = new Set(list.map(m => m.id));
    const patched = list.map(m =>
      m.id?.includes('minimax') || m.id?.includes('m2p5')
        ? { ...m, model_picker_enabled: true, preview: false }
        : m
    );

    MINIMAX_MODELS.forEach(m => {
      if (!existingIds.has(m.id)) {
        console.log('[MiniMax Unhide] Injecting:', m.name);
        patched.push(m);
      }
    });

    return Array.isArray(json) ? patched : { ...json, data: patched };
  }

  const MODELS_URL = 'api.individual.githubcopilot.com/models';

  const _fetch = window.fetch;
  window.fetch = async function (...args) {
    const url = (typeof args[0] === 'string' ? args[0] : args[0]?.url) ?? '';
    const res = await _fetch.apply(this, args);

    if (url.includes(MODELS_URL)) {
      console.log('[MiniMax Unhide] Intercepted models API');
      try {
        const json = await res.clone().json();
        const result = injectOrPatch(json);
        if (result) {
          console.log('[MiniMax Unhide] Injected MiniMax models successfully');
          return new Response(JSON.stringify(result), {
            status: res.status,
            statusText: res.statusText,
            headers: res.headers,
          });
        }
      } catch (e) {
        console.error('[MiniMax Unhide] Error:', e);
      }
    }
    return res;
  };

  console.log('[MiniMax Unhide] v1.3 ready — watching for models API call');
})();
  `;

  (document.head || document.documentElement).appendChild(script);
  script.remove();
})();