您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Adds shortcuts: Ctrl+Shift+O for new chat, and Ctrl+/ to open conversation search in Gemini AI.
// ==UserScript== // @name AI Chat Shortcuts (New Chat & Search History) // @namespace AI.Chat.Shortcuts // @version 2.1 // @description Adds shortcuts: Ctrl+Shift+O for new chat, and Ctrl+/ to open conversation search in Gemini AI. // @author 3xploiton3 // @match https://gemini.google.com/* // @match https://chat.deepseek.com/* // @grant none // @license MIT // ==/UserScript== (function() { 'use strict'; document.addEventListener('keydown', function(event) { // Abaikan shortcut jika fokus sedang di dalam elemen input untuk menghindari konflik pengetikan. const isEditing = event.target.isContentEditable || ['INPUT', 'TEXTAREA'].includes(event.target.tagName); if (isEditing && event.key !== '/') { return; } let shortcutUsed = null; let actionType = null; // --- Shortcut untuk Chat Baru (hanya Ctrl+Shift+O yang tersisa) --- if (event.ctrlKey && event.shiftKey && !event.altKey && event.code === 'KeyO') { shortcutUsed = 'Ctrl+Shift+O'; actionType = 'newChat'; } // --- Shortcut untuk membuka Pencarian Riwayat (Ctrl + /) --- else if (event.ctrlKey && !event.altKey && !event.shiftKey && event.key === '/') { shortcutUsed = 'Ctrl+/'; actionType = 'searchHistory'; } if (actionType) { event.preventDefault(); event.stopPropagation(); // Mencegah event "bubble up" yang bisa memicu aksi lain const currentHost = window.location.host; if (currentHost.includes('gemini.google.com')) { if (actionType === 'newChat') { handleNewChat(currentHost, shortcutUsed); } else if (actionType === 'searchHistory') { handleSearchHistory(currentHost, shortcutUsed); } } else if (currentHost.includes('chat.deepseek.com') && actionType === 'newChat') { handleNewChat(currentHost, shortcutUsed); } } }); function handleNewChat(currentHost, shortcutUsed) { let newChatButton = null; const selectors = currentHost.includes('gemini.google.com') ? [ 'button[data-test-id="expanded-button"][aria-label="New chat"]', 'button[data-test-id="expanded-button"][aria-label="Buat obrolan baru"]', 'button[aria-label="New chat"]', 'button[aria-label="Buat obrolan baru"]', '.mat-mdc-tooltip-trigger.new-chat-button', 'button[aria-label^="New chat"]', 'button[aria-label^="Buat obrolan baru"]' ] : [ 'div.c7dddcde', 'div[class*="new-chat"]', 'button[aria-label*="New Chat"]', 'div:has(> svg[width="28"][height="28"])' ]; for (const selector of selectors) { newChatButton = document.querySelector(selector); if (newChatButton) break; } if (newChatButton) { if (!newChatButton.disabled) { newChatButton.click(); console.log(`[Shortcut] New chat created via ${shortcutUsed}.`); } else { console.warn(`[Shortcut] "New chat" button found but is disabled.`); } } else { console.warn(`[Shortcut] "New chat" button not found.`); } } function handleSearchHistory(currentHost, shortcutUsed) { let searchButton = null; const selectors = [ 'button.search-button', 'button[aria-label="Search"]', 'button[aria-label="Cari"]', 'search-nav-button button' ]; for (const selector of selectors) { searchButton = document.querySelector(selector); if (searchButton) break; } if (searchButton) { searchButton.click(); console.log(`[Shortcut] Search history button clicked via ${shortcutUsed}.`); } else { console.warn(`[Shortcut] Could not find the search history button.`); } } })();
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址