ChatGPT is GPT4 by default

ChatGPT switch The default is GPT4

Verze ze dne 18. 04. 2023. Zobrazit nejnovější verzi.

// ==UserScript==
// @name                 ChatGPT is GPT4 by default
// @name:zh-CN           ChatGPT默认为GPT4
// @description          ChatGPT switch The default is GPT4
// @description:zh-cn   ChatGPT切换默认为GPT4
// @version             0.0.1
// @match              https://chat.openai.com/
// @match              https://chat.openai.com/c?*
// @match              https://chat.openai.com/c/*
// @license MIT
// @namespace https://gf.zukizuki.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;
    window.history.pushState = function () {
      const url = arguments[2]
      if (url === DEFAULT_PATH) {
        setTimeout(switchGPT4, 100)
      }
      return originalPush.apply(this, arguments);
    };
  }
  addEvent()
})();