Skip to content

Instantly share code, notes, and snippets.

@BoQsc
Last active May 17, 2023 17:49
Show Gist options
  • Save BoQsc/988a62537c5a49b0506316b6087cf9da to your computer and use it in GitHub Desktop.
Save BoQsc/988a62537c5a49b0506316b6087cf9da to your computer and use it in GitHub Desktop.
ChatGPT Plus: default GPT4 web browsing. Userscript for Tampermonkey or Greasemonkey that sets the LLM default model in the https://chat.openai.com/ User Interface.
const clickElement = (selector) => {
const element = document.querySelector(selector);
if (element) {
element.click();
} else {
setTimeout(() => clickElement(selector), 100);
}
};
clickElement("[id*='trigger-gpt-4']");
clickElement("[id*='trigger-gpt-4-browsing']");
// ==UserScript==
// @name Chat OpenAI Auto Click
// @match https://chat.openai.com/
// @match https://chat.openai.com/?model=text-davinci-002-render-sha
// ==/UserScript==
(function() {
const clickElement = (selector) => {
const element = document.querySelector(selector);
if (element) {
element.click();
} else {
setTimeout(() => clickElement(selector), 100);
}
};
clickElement("[id*='trigger-gpt-4']");
clickElement("[id*='trigger-gpt-4-browsing']");
})();
// ==UserScript==
// @name GPT-4 Button Auto Click
// @match https://chat.openai.com/
// @match https://chat.openai.com/?model=text-davinci-002-render-sha
// ==/UserScript==
const clickFirstDivInsideButton = () => {
let buttonNode = document.evaluate("//button[contains(., 'GPT-4')]", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
if (buttonNode) {
let firstDivInsideButton = buttonNode.querySelector('div');
firstDivInsideButton ? firstDivInsideButton.click() : setTimeout(() => clickFirstDivInsideButton(), 100);
} else {
setTimeout(() => clickFirstDivInsideButton(), 100);
}
};
clickFirstDivInsideButton();
@BoQsc
Copy link
Author

BoQsc commented May 17, 2023

Enforces ChatGPT4 | does not even allow for the user to change to GPT3.5

// ==UserScript==
// @name         Chat OpenAI Auto Click
// @match        https://chat.openai.com/
// @match        https://chat.openai.com/?model=text-davinci-002-render-sha
// ==/UserScript==
const clickFirstDivInsideButton = () => {
  const clickHandler = () => {
    const buttonNode = document.evaluate(
      "//button[contains(., 'GPT-4')]",
      document,
      null,
      XPathResult.FIRST_ORDERED_NODE_TYPE,
      null
    ).singleNodeValue;

    if (buttonNode) {
      const firstDivInsideButton = buttonNode.querySelector('div');
      if (firstDivInsideButton) {
        firstDivInsideButton.click();
      }
    }
  };

  const observer = new MutationObserver((mutationsList) => {
    for (const mutation of mutationsList) {
      if (mutation.type === 'childList') {
        clickHandler();
        break; // Break the loop after the first mutation is detected
      }
    }
  });

  observer.observe(document.documentElement, { childList: true, subtree: true });
};

clickFirstDivInsideButton();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment