ChatGPT Search Shortcut

Search ChatGPT From Your Address Bar Without Having To Go To The Website

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

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

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 Search Shortcut
// @namespace    https://greasyfork.org/en/users/943407-webchantment
// @version      1.2
// @description  Search ChatGPT From Your Address Bar Without Having To Go To The Website
// @author       Webchantment
// @match        https://chat.openai.com/?search=*
// @grant        none
// ==/UserScript==

(async () => {

	const timeout = 500; //milliseconds

	const urlParams = new URLSearchParams(window.location.search);
	const searchInput = urlParams.get("search");

	const textarea = document.querySelector("form > * textarea");
	const button = document.querySelector("form > * button");

	if (searchInput && textarea && button) {
		setValue(textarea, searchInput);
		setTimeout(() => { button.click(); }, timeout);
	}

	//special method to set react input box values
	function setValue(input, value) {
		let nativeInputValueSetter = Object.getOwnPropertyDescriptor(input, "value").set;
		nativeInputValueSetter.call(input, value);

		let inputEvent = new Event("input", { bubbles: true });
		input.dispatchEvent(inputEvent);
	}

})();