8
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

新しいBingのAIチャットで漢字変換を確定させるときに意図せず送信されるのを防ぐ

Posted at

windowsだと大丈夫だったけどうちのM1 macbook Airくんだと海外アプリあるあるが起こってたのでブラウザ拡張で対応した

content.js
function sleep(ms) {
    return new Promise((resolve) => setTimeout(resolve, ms))
};


(async () => {
    var input = null;
    while (1) {
        try {
            input = document.getElementsByClassName('cib-serp-main')[0].shadowRoot.getElementById("cib-action-bar-main").shadowRoot.getElementById('searchbox');

            if (input) {
                console.log(input);
                input.addEventListener("keydown", event => event.stopPropagation(), true);
                input.addEventListener("keyup", event => event.stopPropagation(), true);
            }
            break;
        }
        catch (e) {
            //console.log(e);
            await sleep(500);

        }
    }
})();

ブラウザ拡張機能の詳細については省略。manifestファイルで"content_scripts"から上記スクリプトを読み込みます。
これするとEnter押すイベントそもそもから無効にしているので手動で送信ボタンをクリックしないといけないけどいちいち送信されるよりはマシ。
まだpreviewなようなので変更来たらすぐ機能しなくなると思いますがある程度参考になれば幸いです。

参考
https://stackoverflow.com/questions/35070496/can-i-remove-event-listeners-with-a-chrome-extension

8
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?