Coder Social home page Coder Social logo

chatgptpowertoys's Introduction

ChatGPT for PowerToys Run

logo

How to install

If you simply want to install the plugin to get up and running quickly, i suggest downloading the precompiled binaries from the Release section and installing the Tampermonkey user script The installation process is as follows:

  1. Locate your PowerToys installation (eg. C:\Program Files\PowerToys)
  2. Navigate to \modules\launcher\Plugins
  3. Unpack the downloaded binaries

Compiling plugin

  1. Clone the PowerToys repository to your local disk using the command git clone https://github.com/microsoft/PowerToys.git
  2. Navigate to the PowerToys directory using cd PowerToys
  3. Initialize and update submodules with the command git submodule update --init --recursive
  4. Fork the ChatGPTPowerToys repository on GitHub
  5. Clone the fork of ChatGPTPowerToys into the local PowerToys repository by running git clone https://github.com/ferraridavide/ChatGPTPowerToys.git in the PowerToys\src\modules\launcher\Plugins directory
  6. In Visual Studio, add the local clone of ChatGPTPowerToys as an existing project to the PowerToys's Plugins folder (modules\launcher\Plugins)
  7. Compile

Unfortunately, ChatGPT does not provide a query string parameter for passing prompts. Therefore, we must utilize a browser extension to inject the prompt.

Using Tampermonkey (recommended)

Tampermonkey is a popular browser extension that allows to inject custom user scripts in webpages, visit tampermonkey.net to install it.

Install this script

// ==UserScript==
// @name         PowerToys Run ChatGPT Helper
// @version      0.3
// @description  https://github.com/ferraridavide/ChatGPTPowerToys
// @author       Davide Ferrari
// @match        https://chat.openai.com/?PTquery=*
// @icon         https://raw.githubusercontent.com/ferraridavide/ChatGPTPowerToys/master/src/PowerToys.ChatGPT.BrowserExtension/icons/icon128.png
// @grant        none
// ==/UserScript==
(function() {
    'use strict';
    console.log("PowerToys Run ChatGPT Helper script loaded");
    const searchParams = new URLSearchParams(window.location.search);
    const prompt = searchParams.get("PTquery");
    if (prompt) {
        setTimeout(() => {
            const textArea = document.querySelector("form textarea");
            if (!textArea) {
                console.error("Cannot find the textarea element");
                return;
            }
            textArea.value = prompt;
            const inputEvent = new Event('input', {
                'bubbles': true,
                'cancelable': true
            });
            textArea.dispatchEvent(inputEvent);

            setTimeout(() => {
                const submitButton = document.querySelector("form button");
                if (!submitButton) {
                    console.error("Cannot find the submit button");
                    return;
                }
                submitButton.click();
            }, 500);
        }, 1000);
    }
})();
AIPRM browser extension compatability Thanks to @babico for providing this modified script!
// ==UserScript==
// @name         PowerToys Run ChatGPT Helper
// @version      0.2
// @description  https://github.com/ferraridavide/ChatGPTPowerToys
// @author       Davide Ferrari
// @match        https://chat.openai.com/?PTquery=*
// @icon         https://raw.githubusercontent.com/ferraridavide/ChatGPTPowerToys/master/src/PowerToys.ChatGPT.BrowserExtension/icons/icon128.png
// @grant        none
// ==/UserScript==

(function() {
   'use strict';

   console.log("PowerToys Run ChatGPT Helper script loaded");

   const searchParams = new URLSearchParams(window.location.search);
   const prompt = searchParams.get("PTquery");

   if (prompt) {
       setTimeout(() => {
           const textArea = document.querySelector("form textarea");
           const submitButton = document.querySelectorAll("form button")[1]; // AIPRM add another button so change with the second button

           if (!textArea || !submitButton) {
               console.error("Cannot find required elements");
           }

           textArea.value = prompt;
           submitButton.disabled = false;
           submitButton.click();
       }, 500);
   }
})();

Using the custom browser extension

  1. Open your preferred browser and navigate to the settings or preferences menu.
  2. Locate the option for "extensions" or "add-ons" and select it.
  3. Enable developer mode in the extensions settings page.
  4. In the extensions menu, look for a button or option labeled "Load Unpacked" or "Add Unpacked Extension."
  5. Select the folder containing the extension and click "Open."

chatgptpowertoys's People

Contributors

ferraridavide avatar babico avatar navusas avatar rafared avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.