允许在 Gemini 的对话历史记录上使用鼠标中键点击,从而在新标签页中打开它们。
当前为
// ==UserScript==
// @name Gemini - Middle-click to open chat in new tab
// @name:zh-CN Gemini - 中键点击在新标签页打开对话
// @namespace http://tampermonkey.net/
// @version 1.3
// @description Allows middle-clicking on conversation history items in Gemini to open them in a new tab.
// @description:zh-CN 允许在 Gemini 的对话历史记录上使用鼠标中键点击,从而在新标签页中打开它们。
// @author Gemini & contributors
// @match https://gemini.google.com/app*
// @icon https://www.google.com/s2/favicons?sz=64&domain=gemini.google.com
// @grant GM_openInTab
// @license MIT
// ==/UserScript==
(function() {
'use strict';
document.addEventListener('mousedown', function(event) {
// event.button === 1 代表鼠标中键点击
if (event.button === 1) {
const conversationElement = event.target.closest('[data-test-id="conversation"]');
if (conversationElement) {
const jslog = conversationElement.getAttribute('jslog');
if (jslog) {
// 正确的正则表达式:通过匹配ID的格式(16位以上的十六进制字符)来捕获ID
const match = jslog.match(/([a-f0-9]{16,})/);
if (match && match[1]) {
// 阻止浏览器的默认中键行为
event.preventDefault();
event.stopPropagation();
const conversationId = match[1];
// 构建不含 "c_" 前缀的正确URL
const url = `https://gemini.google.com/app/${conversationId}`;
console.log('Opening Gemini conversation in new background tab:', url);
// 【功能修改】
// 将 active 设置为 false,实现在后台打开新标签页
GM_openInTab(url, { active: false });
}
}
}
}
}, true);
})();
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址