ChatGPT is GPT4 by default(PLUS only available)

ChatGPT switch The default is GPT4

Stan na 18-04-2023. Zobacz najnowsza wersja.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==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切换默认为GPT4
// @version             0.0.2
// @match              https://chat.openai.com/
// @match              https://chat.openai.com/c?*
// @match              https://chat.openai.com/c/*
// @license MIT
// @namespace https://greasyfork.org/users/562260
// ==/UserScript==

(function () {
  'use strict';
  const DEFAULT_PATH = '/'
  const switchGPT4 = () => {
    function clickButtonByTextContent(textContent) {
      const buttons = document.getElementsByTagName('button');
      for (let button of buttons) {
        if (button.textContent === textContent) {
          button.click();
          return;
        }
      }
    }

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

    clickButtonByTextContent('ModelDefault (GPT-3.5)');
    setTimeout(() => clickListItemByTextContent('GPT-4'), 0);
  }

  const addEvent = () => {
    const originalPush = window.history.pushState;
    const originalReplace = window.history.replaceState;
    window.history.pushState = function () {
      const url = arguments[2]
      if (url === DEFAULT_PATH) {
        setTimeout(switchGPT4, 100)
      }
      return originalPush.apply(this, arguments);
    };
    window.history.replaceState = function () {
      const url = arguments[2]
      if (url === DEFAULT_PATH) {
        setTimeout(switchGPT4, 100)
      }
      return originalReplace.apply(this, arguments);
    };
  }
  addEvent()
})();