# ChatGPT Webview x JS

**URL:** <https://community.folivora.ai/t/chatgpt-webview-x-js/33939>\
**Category:** Configuration Help & General Discussion\
**Created:** [October 26, 2023, 3:47pm UTC](https://community.folivora.ai/t/chatgpt-webview-x-js/33939 "2023-10-26T15:47:58Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![devonair](https://community.folivora.ai/user_avatar/community.folivora.ai/devonair/32/26569_2.png) [@devonair](https://community.folivora.ai/u/devonair)\
**Post date:** [October 26, 2023, 3:47pm UTC](https://community.folivora.ai/t/chatgpt-webview-x-js/33939/1 "2023-10-26T15:47:58Z")

</div>

Heavy user of chatGPT, and tried the shared preset, but not sure how to activate the webview... is the preset already packaged with a trigger to view it?

Apart from that, more interested in combining this preset/webview with the floating menu functionality to allow for applescript, javascript, shellscript injections into chatGPT... I think this would be a powerful feature and I'd like to put it together and share it with the community here... any thoughts or advice to this end would be appreciated.

---

<div class="post-metadata">

**Author:** ![Andreas\_Hegenberg](https://community.folivora.ai/user_avatar/community.folivora.ai/andreas_hegenberg/32/39221_2.png) [@Andreas\_Hegenberg](https://community.folivora.ai/u/Andreas_Hegenberg)\
**Post date:** [November 3, 2023, 1:41pm UTC](https://community.folivora.ai/t/chatgpt-webview-x-js/33939/2 "2023-11-03T13:41:12Z")

</div>

I just needed something similar. There was an issue with the ChatGPT security policies, which previously prevented the BTT scripting from working on the chatgpt webview. With version 4.316 this should be resolved now.

Here is an example preset:  
[ChatGPT.bttpreset](https://community.folivora.ai/uploads/short-url/bbqwhTa14wZZi1RZyOZTCwkTCRy.bttpreset) (23.2 KB)

Pressing cmd+r shows the ChatGPT floating menu  
Pressing cmd+t executes a script on the webview, which gets the currently selected text, puts it into the prompt field and clicks the send button.

```auto
(async () => {

let selectedText = await get_string_variable({variable_name:'selected_text'})

let propmptTextArea = document.getElementById("prompt-textarea");
propmptTextArea.value = selectedText;

let fakeInputEvent = new Event('input', { bubbles: true});
propmptTextArea.dispatchEvent(fakeInputEvent);

let sendButton = document.querySelector('button.absolute');
sendButton.click()
setTimeout(() => {
  sendButton.click()

},100)
})();

```

You can use any scripting calls described here  
[http://docs.folivora.ai/docs/10\_2\_floating\_menu\_javascript.html](http://docs.folivora.ai/docs/10_2_floating_menu_javascript.html)

[http://docs.folivora.ai/docs/10\_3\_webview\_scripts.html](http://docs.folivora.ai/docs/10_3_webview_scripts.html)

---

<div class="post-metadata">

**Author:** ![devonair](https://community.folivora.ai/user_avatar/community.folivora.ai/devonair/32/26569_2.png) [@devonair](https://community.folivora.ai/u/devonair)\
**Post date:** [November 4, 2023, 3:53pm UTC](https://community.folivora.ai/t/chatgpt-webview-x-js/33939/3 "2023-11-04T15:53:50Z")

</div>

a kind of roadmap I put together for how this could grow... its a bunch of text so I paste it here:

> **[Creating a setup where two instances of ChatGPT interact with you and each...](https://pastebin.com/0xLsSXDg)**
>
> Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.

---

<div class="post-metadata">

**Author:** ![Andreas\_Hegenberg](https://community.folivora.ai/user_avatar/community.folivora.ai/andreas_hegenberg/32/39221_2.png) [@Andreas\_Hegenberg](https://community.folivora.ai/u/Andreas_Hegenberg)\
**Post date:** [November 4, 2023, 7:20pm UTC](https://community.folivora.ai/t/chatgpt-webview-x-js/33939/4 "2023-11-04T19:20:24Z")

</div>

just in case you haven't considered it: I think the OpenAI APIs are better suited for at least some of these things.

---

<div class="post-metadata">

**Author:** ![devonair](https://community.folivora.ai/user_avatar/community.folivora.ai/devonair/32/26569_2.png) [@devonair](https://community.folivora.ai/u/devonair)\
**Post date:** [November 4, 2023, 8:15pm UTC](https://community.folivora.ai/t/chatgpt-webview-x-js/33939/5 "2023-11-04T20:15:55Z")

</div>

i did ask GPT itself what was more economical, their subscription service ('plus') or API calls... seems as though if there's going to be a lot of messages and crosstalk back-and-forth, the plus starts to win out, as the API costs start to climb.... but apart from that if you just mean in terms of flexibility for a use-case like this, yea im sure youre right...would be cool to still enable a more intelligent chatgpt via some or all of these features i listed tho... i havent started on this yet... if the api makes things significantly easier then i may just go in that direction...
