-
-
Save souljazzfunk/5c9eeec65331fbac0a555e885dd11fa4 to your computer and use it in GitHub Desktop.
Prevent ChatGPT/BingChat from submitting LineBreak when using Japanese Input. 日本語変換の確定時に送信されないようにするためのChrome拡張機能です。ChatGPTとBing Chatで使えます。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "name": "No-IME-Submit for ChatGPT / Bing Chat", | |
| "version": "1.0", | |
| "manifest_version": 3, | |
| "description": "Prevent ChatGPT/BingChat from submitting LineBreak when using Japanese Input", | |
| "host_permissions": [ | |
| "https://chat.openai.com/*", | |
| "https://www.bing.com/*" | |
| ], | |
| "content_scripts": [ | |
| { | |
| "matches": [ | |
| "https://chat.openai.com/*", | |
| "https://www.bing.com/*" | |
| ], | |
| "js": ["noIMESubmit.js"] | |
| } | |
| ] | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (function() { | |
| const hostname = window.location.hostname | |
| const suppressSubmit = () => { | |
| let input | |
| let isLastKeyDownIME = false | |
| // console.log(hostname) | |
| if (hostname === 'www.bing.com') { | |
| input = document.getElementsByClassName('cib-serp-main')[0].shadowRoot.getElementById("cib-action-bar-main").shadowRoot.getElementById('searchbox') | |
| } | |
| else if (hostname === 'chat.openai.com') { | |
| input = document.querySelector('textarea') | |
| } | |
| input.addEventListener('keydown', e => { | |
| // console.log('DOWN: ' + e.key, e.keyCode, e.isComposing) | |
| if(e.isComposing) { | |
| isLastKeyDownIME = true | |
| if(e.key === 'Enter') { | |
| e.stopPropagation() | |
| // console.log('IME Enter: DOWN') | |
| } | |
| } | |
| }, true) | |
| input.addEventListener('keyup', e => { | |
| // console.log('UP: ' + e.key, e.keyCode, e.isComposing) | |
| if(e.key === 'Enter' && isLastKeyDownIME) { | |
| e.stopPropagation() | |
| // console.log('IME Enter: UP') | |
| } | |
| }, true) | |
| } | |
| const waitForInput = (wait) => { | |
| setTimeout(() => { | |
| try { | |
| suppressSubmit() | |
| } catch (e) { | |
| console.log(e) | |
| if (wait < 5000) { | |
| waitForInput(wait + 500) | |
| } | |
| } | |
| }, wait) | |
| } | |
| waitForInput(500); | |
| })() | |
Author
souljazzfunk
commented
Feb 24, 2023

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