ChatGPT is GPT4 by default(PLUS only available)

ChatGPT switch The default is GPT4

Versione datata 18/04/2023. Vedi la nuova versione l'ultima versione.

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

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

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==UserScript==
// @name                 ChatGPT is GPT4 by default(PLUS only available)
// @name:zh-CN           ChatGPT默认为GPT4(仅PLUS可用)
// @description          ChatGPT switch The default is GPT4
// @description:zh-cn   ChatGPT switch The default is GPT4
// @version             0.0.3
// @match              https://chat.openai.com/*
// @namespace https://greatest.deepsurf.us/users/562260
// @license MIT
// ==/UserScript==

(function () {
  'use strict';
  const DEFAULT_MODEL = 'GPT-4';
  const BUTTON_INFO = 'ModelDefault (GPT-3.5)';

  const clickListItemByTextContent = (textContent) => {
    const listItems = document.getElementsByTagName('li');
    for (let listItem of listItems) {
      if (listItem.textContent === textContent) {
        listItem.click();
        return;
      }
    }
  };

  const switchModel = (model = DEFAULT_MODEL) => {
    setTimeout(() => clickListItemByTextContent(model), 0);
  };

  const callback = (mutationRecords) => {
    for (const mutationRecord of mutationRecords) {
      if (mutationRecord.addedNodes.length) {
        for (const addedNode of mutationRecord.addedNodes) {
          const buttons = addedNode.querySelectorAll('button');
          for (let button of buttons) {
            if (button.textContent === BUTTON_INFO) {
              button.click();
              switchModel();
              return;
            }
          }
        }
      }
    }
  };

  const observer = new MutationObserver(callback);
  observer.observe(document.getElementById('__next'), {
    childList: true,
    subtree: true,
  });
})();