ChatGPT默认为GPT4(仅PLUS可用)

ChatGPT switch The default is GPT4

当前为 2023-04-18 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name ChatGPT is GPT4 by default(PLUS only available)
  3. // @name:zh-CN ChatGPT默认为GPT4(仅PLUS可用)
  4. // @description ChatGPT switch The default is GPT4
  5. // @description:zh-cn ChatGPT switch The default is GPT4
  6. // @version 0.0.3
  7. // @match https://chat.openai.com/*
  8. // @namespace https://greasyfork.org/users/562260
  9. // @license MIT
  10. // ==/UserScript==
  11.  
  12. (function () {
  13. 'use strict';
  14. const DEFAULT_MODEL = 'GPT-4';
  15. const BUTTON_INFO = 'ModelDefault (GPT-3.5)';
  16.  
  17. const clickListItemByTextContent = (textContent) => {
  18. const listItems = document.getElementsByTagName('li');
  19. for (let listItem of listItems) {
  20. if (listItem.textContent === textContent) {
  21. listItem.click();
  22. return;
  23. }
  24. }
  25. };
  26.  
  27. const switchModel = (model = DEFAULT_MODEL) => {
  28. setTimeout(() => clickListItemByTextContent(model), 0);
  29. };
  30.  
  31. const callback = (mutationRecords) => {
  32. for (const mutationRecord of mutationRecords) {
  33. if (mutationRecord.addedNodes.length) {
  34. for (const addedNode of mutationRecord.addedNodes) {
  35. const buttons = addedNode.querySelectorAll('button');
  36. for (let button of buttons) {
  37. if (button.textContent === BUTTON_INFO) {
  38. button.click();
  39. switchModel();
  40. return;
  41. }
  42. }
  43. }
  44. }
  45. }
  46. };
  47.  
  48. const observer = new MutationObserver(callback);
  49. observer.observe(document.getElementById('__next'), {
  50. childList: true,
  51. subtree: true,
  52. });
  53. })();