ChatGPT 4o-mini Default model

This script modifies the requests to use gpt-4o mini by default

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

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.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         ChatGPT 4o-mini Default model
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  This script modifies the requests to use gpt-4o mini by default
// @match        https://chatgpt.com/*
// @grant        none
// @license      MIT
// @icon         data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJYAAACWBAMAAADOL2zRAAAAHlBMVEUCpn7+///w+ffa8eu35dqT18dtybNCu50isI0AoXffLgXfAAAFgUlEQVR42u1ZTVMbRxBVVUDRHHtXEue1g8ORjQP4qCVVEN0MBAffAOMYbhDiOLpRDrbZWx8ipPm3Sc/H9s4Se2YlnVzbVVA6aJ96ut970zPbaqKJJppoookmvp4Q8r/AhUDJzp+vX/x2twA0gWc/AABEOznOCzU5ABPfjeYEm+5DEd18vrROgSKChP71xTxQy2CD0OBnnGOFmcrqx8PDnwgK4rwlZuyn+FuV6bwlZeujgl3DzrsbIWcBywjqUj0qJ3uU2EEK8cavon5uVK34Ai07UrCxUZtr4sQpt1gq0WNUt/IJQFeUqcaxWpNr/wDAoEgLTy0zIvqwhbWWeKVIYEJeg4roUQIqLmphZQAraKH+0HV68dfdp9eqCb06iU0A4KXF/ZAoeV9Kim+3abU1EpNjgCg3UO1EixsNPYh4/eDE8O22XgdTq0umw9jRKJQPZwCqXCzL+Bi5lr8DwHpgVq8Aim+jIlZ0h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1jPWyGRui2yvCVNsidtYhDWVWV2F22jJ6sLEqgIv0V7giWo8n2OeK+yyoOQtNRA66Z8NMNi/+zyVWYAK3hXE8WRkas5lEE4bPndY0nR2WdN8oBW9047Vjd621aTfBkcB4Gwvt2bxk3uWhakaZdQNphYPFIF47Bm+JWCI/wa5WItJ6D/niHnW/M61FDhLAETkXvBPZjhDczHX54+erzhXLzzsbFmSOzc3Yil0guBbeAV1w5EIgHF09KLitljDBx6rps9xCuXavO+cIqAgj1s5hDTAyIaUW11hAt6Qfd4J8cFvTh8cydxYS80ZfNit4kmmmiiiSa+nvgX1iUJSzeRndIAAAAASUVORK5CYII=
// @run-at       document-start
// ==/UserScript==

(function() {
    'use strict';

    const originalOpen = XMLHttpRequest.prototype.open;
    XMLHttpRequest.prototype.open = function() {
        this.addEventListener('readystatechange', function() {
            if (this.readyState === 4 && this.responseURL === 'https://chatgpt.com/backend-api/conversation') {
                try {
                    const requestPayload = JSON.parse(this._requestData || '{}');
                    if (requestPayload.model && requestPayload.model !== 'gpt-4o-mini') {
                        console.log('Modifying model to gpt-4o-mini');
                        requestPayload.model = 'gpt-4o-mini';
                        this._requestData = JSON.stringify(requestPayload);
                    }
                } catch (e) {
                    console.error("Couldn't fetch payload:", e);
                }
            }
        });
        return originalOpen.apply(this, arguments);
    };

    const originalFetch = window.fetch;
    window.fetch = function() {
        const url = arguments[0];
        const options = arguments[1] || {};

        if (url === 'https://chatgpt.com/backend-api/conversation' && options.body) {
            try {
                const body = JSON.parse(options.body);
                if (body.model && body.model !== 'gpt-4o-mini') {
                    console.log('Set default model to gpt-4o-mini');
                    body.model = 'gpt-4o-mini';
                    options.body = JSON.stringify(body);
                }
            } catch (e) {
                console.error('Error modifying request payload:', e);
            }
        }

        return originalFetch.apply(this, arguments);
    };
})();