ChatGPT Temporary Chat Toggle without reloading the web

Toggle temporary chat mode on chaptgpt with double shift key press without reloading

< 腳本ChatGPT Temporary Chat Toggle without reloading the web的回應

評論:正評 - 腳本一切正常

§
發表於:2025-09-23

Here's a way to fix the problem you're having when returning to the non-temporary chat:

You currently have:

                window.location.href = 'https://chatgpt.com';

You can replace it with:

                const root = new URL('/', url.origin);
                history.replaceState(null, '', root.toString());

This will stop the full page reload and go to the root on the same origin to avoid any cross-origin navigation.

Also, a small bug in your code, although it shouldn't affect things too much with your current code:

if (e.key !== 'Shift'&& e.location===KeyboardEvent.DOM_KEY_LOCATION_LEFT) return;

...this line allows almost any keystroke to get past it. The only ones it will stop are Left Alt, Left Ctrl and Left Meta/Windows. But your isShiftHeld flag does block all those other keystrokes, so the bug doesn't really harm anything.

To write that line properly, change it to:

if (e.key !== 'Shift' || e.location !== KeyboardEvent.DOM_KEY_LOCATION_LEFT) return;

or if you want it even simpler, write:

if (e.code !== 'ShiftLeft') return;

發表回覆

登入以回覆

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址